tests: cleanup and fix scripts
This commit is contained in:
parent
69ef1da58c
commit
2abcde03ad
|
@ -1,4 +1,9 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
|
if [[ "$GRPC_BROADCAST_TX" == "" ]]; then
|
||||||
|
GRPC_BROADCAST_TX=""
|
||||||
|
fi
|
||||||
|
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
@ -25,20 +30,25 @@ 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=\"$TX\"`
|
RESPONSE=`curl -s localhost:46657/broadcast_tx_commit?tx=\"$TX\"`
|
||||||
CODE=`echo $RESPONSE | jq .result[1].code`
|
|
||||||
ERROR=`echo $RESPONSE | jq .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[1]`
|
||||||
else
|
else
|
||||||
if [ ! -f grpc_client ]; then
|
if [ ! -f grpc_client ]; then
|
||||||
go build -o grpc_client grpc_client.go
|
go build -o grpc_client grpc_client.go
|
||||||
fi
|
fi
|
||||||
RESPONSE=`./grpc_client $TX`
|
RESPONSE=`./grpc_client $TX`
|
||||||
|
ERROR=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
ERROR="$RESPONSE"
|
ERROR="$RESPONSE"
|
||||||
else
|
|
||||||
ERROR="" # reset
|
|
||||||
fi
|
fi
|
||||||
APPEND_TX_RESPONSE=`echo $RESPONSE | jq .append_tx`
|
APPEND_TX_RESPONSE=`echo $RESPONSE | jq .append_tx`
|
||||||
APPEND_TX_CODE=`getCode "$APPEND_TX_RESPONSE"`
|
APPEND_TX_CODE=`getCode "$APPEND_TX_RESPONSE"`
|
||||||
|
@ -48,11 +58,12 @@ function sendTx() {
|
||||||
echo "-------"
|
echo "-------"
|
||||||
echo "TX $TX"
|
echo "TX $TX"
|
||||||
echo "RESPONSE $RESPONSE"
|
echo "RESPONSE $RESPONSE"
|
||||||
echo "CHECK_TX_RESPONSE $CHECK_TX_RESPONSE"
|
echo "ERROR $ERROR"
|
||||||
echo "APPEND_TX_RESPONSE $APPEND_TX_RESPONSE"
|
|
||||||
echo "CHECK_TX_CODE $CHECK_TX_CODE"
|
|
||||||
echo "APPEND_TX_CODE $APPEND_TX_CODE"
|
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
|
if [[ "$ERROR" != "" ]]; then
|
||||||
|
echo "Unexpected error sending tx ($TX): $ERROR"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,10 +77,6 @@ if [[ $APPEND_TX_CODE != 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$GRPC_BROADCAST_TX" == "" && "$ERROR" != "" ]]; then
|
|
||||||
echo "Unexpected error. Tx $TX should have been included in a block. $ERROR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "... sending tx. expect error"
|
echo "... sending tx. expect error"
|
||||||
|
|
||||||
|
@ -80,11 +87,6 @@ if [[ "$CHECK_TX_CODE" == 0 ]]; then
|
||||||
echo "Got zero exit code for $TX. Expected tx to be rejected by mempool. $RESPONSE"
|
echo "Got zero exit code for $TX. Expected tx to be rejected by mempool. $RESPONSE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ "$GRPC_BROADCAST_TX" == "" && "$ERROR" == "" ]]; then
|
|
||||||
echo "Expected to get an error - tx $TX should have been rejected from mempool"
|
|
||||||
echo "$RESPONSE"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
echo "... sending tx. expect no error"
|
echo "... sending tx. expect no error"
|
||||||
|
@ -96,10 +98,6 @@ if [[ $APPEND_TX_CODE != 0 ]]; then
|
||||||
echo "Got non-zero exit code for $TX. $RESPONSE"
|
echo "Got non-zero exit code for $TX. $RESPONSE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ "$GRPC_BROADCAST_TX" == "" && "$ERROR" != "" ]]; then
|
|
||||||
echo "Unexpected error. Tx $TX should have been accepted in block. $ERROR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "... sending tx. expect no error, but invalid"
|
echo "... sending tx. expect no error, but invalid"
|
||||||
|
|
||||||
|
@ -114,9 +112,5 @@ if [[ $APPEND_TX_CODE == 0 ]]; then
|
||||||
echo "Got zero exit code for $TX. Should have been bad nonce. $RESPONSE"
|
echo "Got zero exit code for $TX. Should have been bad nonce. $RESPONSE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ "$GRPC_BROADCAST_TX" == "" && "$ERROR" != "" ]]; then
|
|
||||||
echo "Unexpected error. Tx $TX should have been included in a block. $ERROR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Passed Test: $TESTNAME"
|
echo "Passed Test: $TESTNAME"
|
||||||
|
|
|
@ -13,7 +13,7 @@ export TMROOT=$HOME/.tendermint_app
|
||||||
function dummy_over_socket(){
|
function dummy_over_socket(){
|
||||||
rm -rf $TMROOT
|
rm -rf $TMROOT
|
||||||
tendermint init
|
tendermint init
|
||||||
echo "Starting dummy and tendermint"
|
echo "Starting dummy_over_socket"
|
||||||
dummy > /dev/null &
|
dummy > /dev/null &
|
||||||
pid_dummy=$!
|
pid_dummy=$!
|
||||||
tendermint node > tendermint.log &
|
tendermint node > tendermint.log &
|
||||||
|
@ -30,7 +30,7 @@ function dummy_over_socket(){
|
||||||
function dummy_over_socket_reorder(){
|
function dummy_over_socket_reorder(){
|
||||||
rm -rf $TMROOT
|
rm -rf $TMROOT
|
||||||
tendermint init
|
tendermint init
|
||||||
echo "Starting tendermint and dummy"
|
echo "Starting dummy_over_socket_reorder (ie. start tendermint first)"
|
||||||
tendermint node > tendermint.log &
|
tendermint node > tendermint.log &
|
||||||
pid_tendermint=$!
|
pid_tendermint=$!
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -48,7 +48,7 @@ function dummy_over_socket_reorder(){
|
||||||
function counter_over_socket() {
|
function counter_over_socket() {
|
||||||
rm -rf $TMROOT
|
rm -rf $TMROOT
|
||||||
tendermint init
|
tendermint init
|
||||||
echo "Starting counter and tendermint"
|
echo "Starting counter_over_socket"
|
||||||
counter --serial > /dev/null &
|
counter --serial > /dev/null &
|
||||||
pid_counter=$!
|
pid_counter=$!
|
||||||
tendermint node > tendermint.log &
|
tendermint node > tendermint.log &
|
||||||
|
@ -64,7 +64,7 @@ function counter_over_socket() {
|
||||||
function counter_over_grpc() {
|
function counter_over_grpc() {
|
||||||
rm -rf $TMROOT
|
rm -rf $TMROOT
|
||||||
tendermint init
|
tendermint init
|
||||||
echo "Starting counter and tendermint"
|
echo "Starting counter_over_grpc"
|
||||||
counter --serial --tmsp grpc > /dev/null &
|
counter --serial --tmsp grpc > /dev/null &
|
||||||
pid_counter=$!
|
pid_counter=$!
|
||||||
tendermint node --tmsp grpc > tendermint.log &
|
tendermint node --tmsp grpc > tendermint.log &
|
||||||
|
@ -80,7 +80,7 @@ function counter_over_grpc() {
|
||||||
function counter_over_grpc_grpc() {
|
function counter_over_grpc_grpc() {
|
||||||
rm -rf $TMROOT
|
rm -rf $TMROOT
|
||||||
tendermint init
|
tendermint init
|
||||||
echo "Starting counter and tendermint"
|
echo "Starting counter_over_grpc_grpc (ie. with grpc broadcast_tx)"
|
||||||
counter --serial --tmsp grpc > /dev/null &
|
counter --serial --tmsp grpc > /dev/null &
|
||||||
pid_counter=$!
|
pid_counter=$!
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
|
@ -1,44 +1,28 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
set -eu
|
set -eu
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
###############################################################
|
DOCKER_IMAGE=$1
|
||||||
# for each peer:
|
NETWORK_NAME=$2
|
||||||
|
COUNT=$3
|
||||||
|
N=$4
|
||||||
|
|
||||||
|
echo "Testing fasysync on node $COUNT"
|
||||||
|
|
||||||
# kill peer
|
# kill peer
|
||||||
# bring it back online via fast sync
|
set +e # circle sigh :(
|
||||||
# check app hash
|
docker rm -vf local_testnet_$COUNT
|
||||||
###############################################################
|
set -e
|
||||||
|
|
||||||
ID=$1
|
# restart peer - should have an empty blockchain
|
||||||
|
SEEDS="$(test/p2p/ip.sh 1):46656"
|
||||||
addr=$(test/p2p/ip.sh $ID):46657
|
for j in `seq 2 $N`; do
|
||||||
peerID=$(( $(($ID % 4)) + 1 )) # 1->2 ... 3->4 ... 4->1
|
SEEDS="$SEEDS,$(test/p2p/ip.sh $j):46656"
|
||||||
peer_addr=$(test/p2p/ip.sh $peerID):46657
|
|
||||||
|
|
||||||
# get another peer's height
|
|
||||||
h1=`curl -s $peer_addr/status | jq .result[1].latest_block_height`
|
|
||||||
|
|
||||||
# get another peer's state
|
|
||||||
root1=`curl -s $peer_addr/status | jq .result[1].latest_app_hash`
|
|
||||||
|
|
||||||
echo "Other peer is on height $h1 with state $root1"
|
|
||||||
echo "Waiting for peer $ID to catch up"
|
|
||||||
|
|
||||||
# wait for it to sync to past its previous height
|
|
||||||
set +e
|
|
||||||
set +o pipefail
|
|
||||||
h2="0"
|
|
||||||
while [[ "$h2" -lt "$(($h1+3))" ]]; do
|
|
||||||
sleep 1
|
|
||||||
h2=`curl -s $addr/status | jq .result[1].latest_block_height`
|
|
||||||
echo "... $h2"
|
|
||||||
done
|
done
|
||||||
|
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $COUNT $SEEDS
|
||||||
|
|
||||||
# check the app hash
|
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME fs_$COUNT "test/p2p/fast_sync/restart_peer.sh $COUNT"
|
||||||
root2=`curl -s $addr/status | jq .result[1].latest_app_hash`
|
|
||||||
|
echo ""
|
||||||
|
echo "PASS"
|
||||||
|
echo ""
|
||||||
|
|
||||||
if [[ "$root1" != "$root2" ]]; then
|
|
||||||
echo "App hash after fast sync does not match. Got $root2; expected $root1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "... fast sync successful"
|
|
||||||
|
|
|
@ -16,23 +16,5 @@ bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME ab test/p2p/atomic_broadcast
|
||||||
# run it on each of them
|
# run it on each of them
|
||||||
N=4
|
N=4
|
||||||
for i in `seq 1 $N`; do
|
for i in `seq 1 $N`; do
|
||||||
echo "Testing fasysync on node $i"
|
bash test/p2p/fast_sync/test.sh $DOCKER_IMAGE $NETWORK_NAME $i $N
|
||||||
|
|
||||||
# kill peer
|
|
||||||
set +e # circle sigh :(
|
|
||||||
docker rm -vf local_testnet_$i
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# restart peer - should have an empty blockchain
|
|
||||||
SEEDS="$(test/p2p/ip.sh 1):46656"
|
|
||||||
for j in `seq 2 $N`; do
|
|
||||||
SEEDS="$SEEDS,$(test/p2p/ip.sh $j):46656"
|
|
||||||
done
|
done
|
||||||
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $i $SEEDS
|
|
||||||
|
|
||||||
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME fs_$i "test/p2p/fast_sync/test.sh $i"
|
|
||||||
done
|
|
||||||
echo ""
|
|
||||||
echo "PASS"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ function send_txs(){
|
||||||
start_procs 1
|
start_procs 1
|
||||||
send_txs
|
send_txs
|
||||||
kill_procs
|
kill_procs
|
||||||
|
|
||||||
start_procs 2
|
start_procs 2
|
||||||
|
|
||||||
# wait for node to handshake and make a new block
|
# wait for node to handshake and make a new block
|
||||||
|
@ -64,5 +65,6 @@ while [ "$h2" == "$h1" ]; do
|
||||||
done
|
done
|
||||||
|
|
||||||
kill_procs
|
kill_procs
|
||||||
|
sleep 2
|
||||||
|
|
||||||
echo "Passed Test: Persistence"
|
echo "Passed Test: Persistence"
|
||||||
|
|
Loading…
Reference in New Issue