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

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