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.

75 lines
2.1 KiB

  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.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.latest_block_height)
  24. h2=$h1
  25. while [ "$h2" == "$h1" ]; do
  26. sleep 1
  27. h2=$(curl -s "$addr/status" | jq .result.latest_block_height)
  28. done
  29. # wait for all other peers to get to this height
  30. minHeight=$h2
  31. for j in $(seq 1 "$N"); do
  32. if [[ "$i" != "$j" ]]; then
  33. addrJ=$(test/p2p/ip.sh "$j"):46657
  34. h=$(curl -s "$addrJ/status" | jq .result.latest_block_height)
  35. while [ "$h" -lt "$minHeight" ]; do
  36. sleep 1
  37. h=$(curl -s "$addrJ/status" | jq .result.latest_block_height)
  38. done
  39. fi
  40. done
  41. # check that hash was updated
  42. HASH2=$(curl -s "$addr/status" | jq .result.latest_app_hash)
  43. if [[ "$HASH1" == "$HASH2" ]]; then
  44. echo "Expected state hash to update from $HASH1. Got $HASH2"
  45. exit 1
  46. fi
  47. # check we get the same new hash on all other nodes
  48. for j in $(seq 1 "$N"); do
  49. if [[ "$i" != "$j" ]]; then
  50. addrJ=$(test/p2p/ip.sh "$j"):46657
  51. HASH3=$(curl -s "$addrJ/status" | jq .result.latest_app_hash)
  52. if [[ "$HASH2" != "$HASH3" ]]; then
  53. echo "App hash for node $j doesn't match. Got $HASH3, expected $HASH2"
  54. exit 1
  55. fi
  56. fi
  57. done
  58. echo "All nodes are up to date"
  59. done
  60. echo ""
  61. echo "PASS"
  62. echo ""