Browse Source

we now omit error if empty

pull/521/head
Anton Kaliaev 8 years ago
committed by Ethan Buchman
parent
commit
e1fd587ddd
1 changed files with 16 additions and 13 deletions
  1. +16
    -13
      test/app/counter_test.sh

+ 16
- 13
test/app/counter_test.sh View File

@ -23,39 +23,42 @@ function getCode() {
else else
# this wont actually work if theres an error ... # this wont actually work if theres an error ...
echo "$R" | jq .code echo "$R" | jq .code
fi
fi
} }
function sendTx() { function sendTx() {
TX=$1 TX=$1
if [[ "$GRPC_BROADCAST_TX" == "" ]]; then if [[ "$GRPC_BROADCAST_TX" == "" ]]; then
RESPONSE=`curl -s localhost:46657/broadcast_tx_commit?tx=0x$TX`
ERROR=`echo $RESPONSE | jq .error`
RESPONSE=$(curl -s localhost:46657/broadcast_tx_commit?tx=0x"$TX")
IS_ERR=$(echo "$RESPONSE" | jq 'has("error")')
ERROR=$(echo "$RESPONSE" | jq '.error')
ERROR=$(echo "$ERROR" | tr -d '"') # remove surrounding quotes ERROR=$(echo "$ERROR" | tr -d '"') # remove surrounding quotes
RESPONSE=`echo $RESPONSE | jq .result`
RESPONSE=$(echo "$RESPONSE" | jq '.result')
else else
if [ -f grpc_client ]; then if [ -f grpc_client ]; then
rm grpc_client rm grpc_client
fi fi
echo "... building grpc_client" echo "... building grpc_client"
go build -o grpc_client grpc_client.go
RESPONSE=`./grpc_client $TX`
go build -o grpc_client grpc_client.go
RESPONSE=$(./grpc_client "$TX")
IS_ERR=false
ERROR="" ERROR=""
fi fi
echo "RESPONSE" echo "RESPONSE"
echo $RESPONSE
echo "$RESPONSE"
echo $RESPONSE | jq . &> /dev/null
echo "$RESPONSE" | jq . &> /dev/null
IS_JSON=$? IS_JSON=$?
if [[ "$IS_JSON" != "0" ]]; then if [[ "$IS_JSON" != "0" ]]; then
IS_ERR=true
ERROR="$RESPONSE" ERROR="$RESPONSE"
fi fi
APPEND_TX_RESPONSE=`echo $RESPONSE | jq .deliver_tx`
APPEND_TX_CODE=`getCode "$APPEND_TX_RESPONSE"`
CHECK_TX_RESPONSE=`echo $RESPONSE | jq .check_tx`
CHECK_TX_CODE=`getCode "$CHECK_TX_RESPONSE"`
APPEND_TX_RESPONSE=$(echo "$RESPONSE" | jq '.deliver_tx')
APPEND_TX_CODE=$(getCode "$APPEND_TX_RESPONSE")
CHECK_TX_RESPONSE=$(echo "$RESPONSE" | jq '.check_tx')
CHECK_TX_CODE=$(getCode "$CHECK_TX_RESPONSE")
echo "-------" echo "-------"
echo "TX $TX" echo "TX $TX"
@ -63,7 +66,7 @@ function sendTx() {
echo "ERROR $ERROR" echo "ERROR $ERROR"
echo "----" echo "----"
if [[ "$ERROR" != "" ]]; then
if $IS_ERR; then
echo "Unexpected error sending tx ($TX): $ERROR" echo "Unexpected error sending tx ($TX): $ERROR"
exit 1 exit 1
fi fi


Loading…
Cancel
Save