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
1.9 KiB

  1. #! /bin/bash
  2. set -u
  3. N=$1
  4. ###################################################################
  5. # wait for all peers to come online
  6. # for each peer:
  7. # wait to have N-1 peers
  8. # wait to be at height > 1
  9. ###################################################################
  10. # wait 60s per step per peer
  11. MAX_SLEEP=60
  12. # wait for everyone to come online
  13. echo "Waiting for nodes to come online"
  14. for i in `seq 1 $N`; do
  15. addr=$(test/p2p/ip.sh $i):26657
  16. curl -s $addr/status > /dev/null
  17. ERR=$?
  18. COUNT=0
  19. while [ "$ERR" != 0 ]; do
  20. sleep 1
  21. curl -s $addr/status > /dev/null
  22. ERR=$?
  23. COUNT=$((COUNT+1))
  24. if [ "$COUNT" -gt "$MAX_SLEEP" ]; then
  25. echo "Waited too long for node $i to come online"
  26. exit 1
  27. fi
  28. done
  29. echo "... node $i is up"
  30. done
  31. echo ""
  32. # wait for each of them to sync up
  33. for i in `seq 1 $N`; do
  34. addr=$(test/p2p/ip.sh $i):26657
  35. N_1=$(($N - 1))
  36. # - assert everyone has N-1 other peers
  37. N_PEERS=`curl -s $addr/net_info | jq '.result.peers | length'`
  38. COUNT=0
  39. while [ "$N_PEERS" != $N_1 ]; do
  40. echo "Waiting for node $i to connect to all peers ..."
  41. sleep 1
  42. N_PEERS=`curl -s $addr/net_info | jq '.result.peers | length'`
  43. COUNT=$((COUNT+1))
  44. if [ "$COUNT" -gt "$MAX_SLEEP" ]; then
  45. echo "Waited too long for node $i to connect to all peers"
  46. exit 1
  47. fi
  48. done
  49. # - assert block height is greater than 1
  50. BLOCK_HEIGHT=`curl -s $addr/status | jq .result.sync_info.latest_block_height | jq fromjson`
  51. COUNT=0
  52. echo "$$BLOCK_HEIGHT IS $BLOCK_HEIGHT"
  53. while [ "$BLOCK_HEIGHT" -le 1 ]; do
  54. echo "Waiting for node $i to commit a block ..."
  55. sleep 1
  56. BLOCK_HEIGHT=`curl -s $addr/status | jq .result.sync_info.latest_block_height | jq fromjson`
  57. COUNT=$((COUNT+1))
  58. if [ "$COUNT" -gt "$MAX_SLEEP" ]; then
  59. echo "Waited too long for node $i to commit a block"
  60. exit 1
  61. fi
  62. done
  63. echo "Node $i is connected to all peers and at block $BLOCK_HEIGHT"
  64. done
  65. echo ""
  66. echo "PASS"
  67. echo ""