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.

74 lines
1.8 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):46657
  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):46657
  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`
  51. COUNT=0
  52. while [ "$BLOCK_HEIGHT" -le 1 ]; do
  53. echo "Waiting for node $i to commit a block ..."
  54. sleep 1
  55. BLOCK_HEIGHT=`curl -s $addr/status | jq .result.sync_info.latest_block_height`
  56. COUNT=$((COUNT+1))
  57. if [ "$COUNT" -gt "$MAX_SLEEP" ]; then
  58. echo "Waited too long for node $i to commit a block"
  59. exit 1
  60. fi
  61. done
  62. echo "Node $i is connected to all peers and at block $BLOCK_HEIGHT"
  63. done
  64. echo ""
  65. echo "PASS"
  66. echo ""