@ -0,0 +1,3 @@ | |||
killall tendermint | |||
killall dummy | |||
killall counter |
@ -0,0 +1,72 @@ | |||
#! /bin/bash | |||
##################### | |||
# counter over socket | |||
##################### | |||
TESTNAME=$1 | |||
# Send some txs | |||
function sendTx() { | |||
TX=$1 | |||
RESPONSE=`curl -s localhost:46657/broadcast_tx_commit?tx=\"$TX\"` | |||
CODE=`echo $RESPONSE | jq .result[1].code` | |||
ERROR=`echo $RESPONSE | jq .error` | |||
ERROR=$(echo "$ERROR" | tr -d '"') # remove surrounding quotes | |||
echo "ERROR: $ERROR" | |||
echo "CODE: $CODE" | |||
echo "" | |||
} | |||
# 0 should pass once and get in block, with no error | |||
TX=00 | |||
sendTx $TX | |||
if [[ $CODE != 0 ]]; then | |||
echo "Got non-zero exit code for $TX. $RESPONSE" | |||
exit 1 | |||
fi | |||
if [[ "$ERROR" != "" ]]; then | |||
echo "Unexpected error. Tx $TX should have been included in a block. $ERROR" | |||
exit 1 | |||
fi | |||
# second time should get rejected by the mempool (return error and non-zero code) | |||
sendTx $TX | |||
if [[ $CODE == 0 ]]; then | |||
echo "Got zero exit code for $TX. Expected tx to be rejected by mempool. $RESPONSE" | |||
exit 1 | |||
fi | |||
if [[ "$ERROR" == "" ]]; then | |||
echo "Expected to get an error - tx $TX should have been rejected from mempool" | |||
echo "$RESPONSE" | |||
exit 1 | |||
fi | |||
# now, TX=01 should pass, with no error | |||
TX=01 | |||
sendTx $TX | |||
if [[ $CODE != 0 ]]; then | |||
echo "Got non-zero exit code for $TX. $RESPONSE" | |||
exit 1 | |||
fi | |||
if [[ "$ERROR" != "" ]]; then | |||
echo "Unexpected error. Tx $TX should have been accepted in block. $ERROR" | |||
exit 1 | |||
fi | |||
# now, TX=03 should get in a block (passes CheckTx, no error), but is invalid | |||
TX=03 | |||
sendTx $TX | |||
if [[ $CODE == 0 ]]; then | |||
echo "Got zero exit code for $TX. Should have been bad nonce. $RESPONSE" | |||
exit 1 | |||
fi | |||
if [[ "$ERROR" != "" ]]; then | |||
echo "Unexpected error. Tx $TX should have been included in a block. $ERROR" | |||
exit 1 | |||
fi | |||
echo "Passed Test: $TESTNAME" |
@ -0,0 +1,34 @@ | |||
#! /bin/bash | |||
function toHex() { | |||
echo -n $1 | hexdump -ve '1/1 "%.2X"' | |||
} | |||
##################### | |||
# dummy with curl | |||
##################### | |||
TESTNAME=$1 | |||
# store key value pair | |||
KEY="abcd" | |||
VALUE="dcba" | |||
curl localhost:46657/broadcast_tx_commit?tx=\"$(toHex $KEY=$VALUE)\" | |||
echo "" | |||
# we should be able to look up the key | |||
RESPONSE=`tmsp-cli query $KEY` | |||
A=`echo $RESPONSE | grep exists=true` | |||
if [[ $? != 0 ]]; then | |||
echo "Failed to find 'exists=true' for $KEY. Response:" | |||
echo "$RESPONSE" | |||
fi | |||
# we should not be able to look up the value | |||
RESPONSE=`tmsp-cli query $VALUE` | |||
A=`echo $RESPONSE | grep exists=true` | |||
if [[ $? == 0 ]]; then | |||
echo "Found 'exists=true' for $VALUE when we should not have. Response:" | |||
echo "$RESPONSE" | |||
fi | |||
echo "Passed Test: $TESTNAME" |
@ -0,0 +1,57 @@ | |||
#! /bin/bash | |||
set -e | |||
#- dummy over socket, curl | |||
#- counter over socket, curl | |||
#- counter over grpc, curl | |||
#- counter over grpc, grpc | |||
# TODO: install everything | |||
function dummy_over_socket(){ | |||
dummy > /dev/null & | |||
tendermint node > tendermint.log & | |||
sleep 3 | |||
bash dummy_test.sh "Dummy over Socket" | |||
killall dummy tendermint | |||
} | |||
function counter_over_socket() { | |||
counter --serial > /dev/null & | |||
tendermint node > tendermint.log & | |||
sleep 3 | |||
bash counter_test.sh "Counter over Socket" | |||
killall counter tendermint | |||
} | |||
function counter_over_grpc() { | |||
counter --serial --tmsp grpc > /dev/null & | |||
tendermint node --tmsp grpc > tendermint.log & | |||
sleep 3 | |||
bash counter_test.sh "Counter over GRPC" | |||
killall counter tendermint | |||
} | |||
case "$1" in | |||
"dummy_over_socket") | |||
dummy_over_socket | |||
;; | |||
"counter_over_socket") | |||
counter_over_socket | |||
;; | |||
"counter_over_grpc") | |||
counter_over_grpc | |||
;; | |||
*) | |||
dummy_over_socket | |||
counter_over_socket | |||
counter_over_grpc | |||
esac | |||