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.

79 lines
2.0 KiB

  1. #! /bin/bash
  2. # wait for everyone to come online
  3. echo "Waiting for nodes to come online"
  4. for i in `seq 1 4`; do
  5. addr="172.57.0.$((100+$i)):46657"
  6. curl -s $addr/status > /dev/null
  7. ERR=$?
  8. while [ "$ERR" != 0 ]; do
  9. sleep 1
  10. curl -s $addr/status > /dev/null
  11. ERR=$?
  12. done
  13. echo "... node $i is up"
  14. done
  15. echo ""
  16. # run the test on each of them
  17. for i in `seq 1 4`; do
  18. addr="172.57.0.$((100+$i)):46657"
  19. # - assert everyone has 3 other peers
  20. N_PEERS=`curl -s $addr/net_info | jq '.result[1].peers | length'`
  21. while [ "$N_PEERS" != 3 ]; do
  22. echo "Waiting for node $i to connect to all peers ..."
  23. sleep 1
  24. N_PEERS=`curl -s $addr/net_info | jq '.result[1].peers | length'`
  25. done
  26. # - assert block height is greater than 1
  27. BLOCK_HEIGHT=`curl -s $addr/status | jq .result[1].latest_block_height`
  28. while [ "$BLOCK_HEIGHT" -le 1 ]; do
  29. echo "Waiting for node $i to commit a block ..."
  30. sleep 1
  31. BLOCK_HEIGHT=`curl -s $addr/status | jq .result[1].latest_block_height`
  32. done
  33. echo "Node $i is connected to all peers and at block $BLOCK_HEIGHT"
  34. # current state
  35. HASH1=`curl -s $addr/status | jq .result[1].latest_app_hash`
  36. # - send a tx
  37. TX=\"aadeadbeefbeefbeef0$i\"
  38. echo "Broadcast Tx $TX"
  39. curl -s $addr/broadcast_tx_commit?tx=$TX
  40. echo ""
  41. # we need to wait another block to get the new app_hash
  42. h1=`curl -s $addr/status | jq .result[1].latest_block_height`
  43. h2=$h1
  44. while [ "$h2" == "$h1" ]; do
  45. sleep 1
  46. h2=`curl -s $addr/status | jq .result[1].latest_block_height`
  47. done
  48. # check that hash was updated
  49. HASH2=`curl -s $addr/status | jq .result[1].latest_app_hash`
  50. if [[ "$HASH1" == "$HASH2" ]]; then
  51. echo "Expected state hash to update from $HASH1. Got $HASH2"
  52. exit 1
  53. fi
  54. # check we get the same new hash on all other nodes
  55. for j in `seq 1 4`; do
  56. if [[ "$i" != "$j" ]]; then
  57. HASH3=`curl -s 172.57.0.$((100+$j)):46657/status | jq .result[1].latest_app_hash`
  58. if [[ "$HASH2" != "$HASH3" ]]; then
  59. echo "App hash for node $j doesn't match. Got $HASH3, expected $HASH2"
  60. exit 1
  61. fi
  62. fi
  63. done
  64. echo "All nodes are up to date"
  65. done
  66. echo ""
  67. echo "PASS"