Skip to content

Commit

Permalink
Update api request script
Browse files Browse the repository at this point in the history
  • Loading branch information
nkostoulas committed Feb 28, 2020
1 parent b0b9b64 commit 1ccc390
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions scripts/api_request.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
#!/bin/bash

NUM=1 # set $1 for load testing
if [ ! -z "$1" ]; then
NUM=$1
echo "a"
fi

for ((i=1;i<=$NUM;i++)); do
RESP=$(curl -s -S -X POST -H "Content-Type: application/json"\
-d "{\"jsonrpc\": \"2.0\", \"method\": \"getrequests\", \"params\" : {}, \"id\":1 }"\
userApi:passwordApi@localhost:3333)
echo $i
if [ $i == 1 ]; then
echo $RESP | jq -r '.result' | jq -r .
fi
done
echo "Getting all requests..."
RESP=$(curl -s -S -X POST -H "Content-Type: application/json"\
-d "{\"jsonrpc\": \"2.0\", \"method\": \"getrequests\", \"params\" : {}, \"id\":1 }" -u $1 $2)
echo $RESP | jq -r '.result' | jq -r .

TXID=$(echo $RESP | jq -r ".result" | jq -r ".requests[0].request.txid")
if [ ! -z $3 ]; then
TXID=$3
fi

echo "Getting request $TXID..."
RESP=$(curl -s -S -X POST -H "Content-Type: application/json"\
-d "{\"jsonrpc\": \"2.0\", \"method\": \"getrequestresponses\", \"params\" : {\"txid\": \"$TXID\"}, \"id\":2 }"\
userApi:passwordApi@localhost:3333)
-d "{\"jsonrpc\": \"2.0\", \"method\": \"getrequestresponse\", \"params\" : {\"txid\": \"$TXID\"}, \"id\":2 }" -u $1 $2)

echo $RESP | jq -r '.'

RESP=$(curl -s -S -X POST -H "Content-Type: application/json"\
-d "{\"jsonrpc\": \"2.0\", \"method\": \"getrequest\", \"params\" : {\"txid\": \"$TXID\"}, \"id\":3 }"\
userApi:passwordApi@localhost:3333)
-d "{\"jsonrpc\": \"2.0\", \"method\": \"getrequest\", \"params\" : {\"txid\": \"$TXID\"}, \"id\":3 }" -u $1 $2)

echo $RESP | jq -r '.'

0 comments on commit 1ccc390

Please sign in to comment.