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.

53 lines
1.3 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 for everyone to come online
  11. echo "Waiting for nodes to come online"
  12. for i in `seq 1 $N`; do
  13. addr=$(test/p2p/ip.sh $i):46657
  14. curl -s $addr/status > /dev/null
  15. ERR=$?
  16. while [ "$ERR" != 0 ]; do
  17. sleep 1
  18. curl -s $addr/status > /dev/null
  19. ERR=$?
  20. done
  21. echo "... node $i is up"
  22. done
  23. echo ""
  24. # wait for each of them to sync up
  25. for i in `seq 1 $N`; do
  26. addr=$(test/p2p/ip.sh $i):46657
  27. N_1=$(($N - 1))
  28. # - assert everyone has N-1 other peers
  29. N_PEERS=`curl -s $addr/net_info | jq '.result.peers | length'`
  30. while [ "$N_PEERS" != $N_1 ]; do
  31. echo "Waiting for node $i to connect to all peers ..."
  32. sleep 1
  33. N_PEERS=`curl -s $addr/net_info | jq '.result.peers | length'`
  34. done
  35. # - assert block height is greater than 1
  36. BLOCK_HEIGHT=`curl -s $addr/status | jq .result.latest_block_height`
  37. while [ "$BLOCK_HEIGHT" -le 1 ]; do
  38. echo "Waiting for node $i to commit a block ..."
  39. sleep 1
  40. BLOCK_HEIGHT=`curl -s $addr/status | jq .result.latest_block_height`
  41. done
  42. echo "Node $i is connected to all peers and at block $BLOCK_HEIGHT"
  43. done
  44. echo ""
  45. echo "PASS"
  46. echo ""