You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

8 years ago
8 years ago
  1. #! /bin/bash
  2. set -u
  3. N=$1
  4. ###################################################################
  5. # assumes peers are already synced up
  6. # test sending txs
  7. # for each peer:
  8. # send a tx, wait for commit
  9. # assert app hash on every peer reflects the post tx state
  10. ###################################################################
  11. echo ""
  12. # run the test on each of them
  13. for i in `seq 1 $N`; do
  14. addr=$(test/p2p/ip.sh $i):46657
  15. # current state
  16. HASH1=`curl -s $addr/status | jq .result[1].latest_app_hash`
  17. # - send a tx
  18. TX=aadeadbeefbeefbeef0$i
  19. echo "Broadcast Tx $TX"
  20. curl -s $addr/broadcast_tx_commit?tx=0x$TX
  21. echo ""
  22. # we need to wait another block to get the new app_hash
  23. h1=`curl -s $addr/status | jq .result[1].latest_block_height`
  24. h2=$h1
  25. while [ "$h2" == "$h1" ]; do
  26. sleep 1
  27. h2=`curl -s $addr/status | jq .result[1].latest_block_height`
  28. done
  29. # check that hash was updated
  30. HASH2=`curl -s $addr/status | jq .result[1].latest_app_hash`
  31. if [[ "$HASH1" == "$HASH2" ]]; then
  32. echo "Expected state hash to update from $HASH1. Got $HASH2"
  33. exit 1
  34. fi
  35. # check we get the same new hash on all other nodes
  36. for j in `seq 1 $N`; do
  37. if [[ "$i" != "$j" ]]; then
  38. addrJ=$(test/p2p/ip.sh $j):46657
  39. HASH3=`curl -s $addrJ/status | jq .result[1].latest_app_hash`
  40. if [[ "$HASH2" != "$HASH3" ]]; then
  41. echo "App hash for node $j doesn't match. Got $HASH3, expected $HASH2"
  42. exit 1
  43. fi
  44. fi
  45. done
  46. echo "All nodes are up to date"
  47. done
  48. echo ""
  49. echo "PASS"
  50. echo ""