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.

76 lines
2.2 KiB

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