Merge pull request #904 from tendermint/fix-atomic-broadcast-test

test/p2p/atomic_broadcast: wait for node heights before checking app hash
This commit is contained in:
Ethan Buchman
2017-11-28 08:21:15 +00:00
committed by GitHub

View File

@ -14,46 +14,60 @@ N=$1
echo "" echo ""
# run the test on each of them # run the test on each of them
for i in $(seq 1 "$N"); do for i in $(seq 1 "$N"); do
addr=$(test/p2p/ip.sh "$i"):46657 addr=$(test/p2p/ip.sh "$i"):46657
# current state # current state
HASH1=$(curl -s "$addr/status" | jq .result.latest_app_hash) HASH1=$(curl -s "$addr/status" | jq .result.latest_app_hash)
# - send a tx # - send a tx
TX=aadeadbeefbeefbeef0$i TX=aadeadbeefbeefbeef0$i
echo "Broadcast Tx $TX" echo "Broadcast Tx $TX"
curl -s "$addr/broadcast_tx_commit?tx=0x$TX" curl -s "$addr/broadcast_tx_commit?tx=0x$TX"
echo "" echo ""
# we need to wait another block to get the new app_hash # we need to wait another block to get the new app_hash
h1=$(curl -s "$addr/status" | jq .result.latest_block_height) h1=$(curl -s "$addr/status" | jq .result.latest_block_height)
h2=$h1 h2=$h1
while [ "$h2" == "$h1" ]; do while [ "$h2" == "$h1" ]; do
sleep 1 sleep 1
h2=$(curl -s "$addr/status" | jq .result.latest_block_height) h2=$(curl -s "$addr/status" | jq .result.latest_block_height)
done done
# check that hash was updated # wait for all other peers to get to this height
HASH2=$(curl -s "$addr/status" | jq .result.latest_app_hash) minHeight=$h2
if [[ "$HASH1" == "$HASH2" ]]; then for j in $(seq 1 "$N"); do
echo "Expected state hash to update from $HASH1. Got $HASH2" if [[ "$i" != "$j" ]]; then
exit 1 addrJ=$(test/p2p/ip.sh "$j"):46657
fi
# check we get the same new hash on all other nodes h=$(curl -s "$addrJ/status" | jq .result.latest_block_height)
for j in $(seq 1 "$N"); do while [ "$h" -lt "$minHeight" ]; do
if [[ "$i" != "$j" ]]; then sleep 1
addrJ=$(test/p2p/ip.sh "$j"):46657 h=$(curl -s "$addrJ/status" | jq .result.latest_block_height)
HASH3=$(curl -s "$addrJ/status" | jq .result.latest_app_hash) done
fi
done
if [[ "$HASH2" != "$HASH3" ]]; then # check that hash was updated
echo "App hash for node $j doesn't match. Got $HASH3, expected $HASH2" HASH2=$(curl -s "$addr/status" | jq .result.latest_app_hash)
exit 1 if [[ "$HASH1" == "$HASH2" ]]; then
fi echo "Expected state hash to update from $HASH1. Got $HASH2"
fi exit 1
done fi
echo "All nodes are up to date" # check we get the same new hash on all other nodes
for j in $(seq 1 "$N"); do
if [[ "$i" != "$j" ]]; then
addrJ=$(test/p2p/ip.sh "$j"):46657
HASH3=$(curl -s "$addrJ/status" | jq .result.latest_app_hash)
if [[ "$HASH2" != "$HASH3" ]]; then
echo "App hash for node $j doesn't match. Got $HASH3, expected $HASH2"
exit 1
fi
fi
done
echo "All nodes are up to date"
done done
echo "" echo ""