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.

43 lines
1.0 KiB

  1. #! /bin/bash
  2. set -eu
  3. set -o pipefail
  4. ID=$1
  5. ###########################################
  6. #
  7. # Wait for peer to catchup to other peers
  8. #
  9. ###########################################
  10. addr=$(test/p2p/ip.sh $ID):46657
  11. peerID=$(( $(($ID % 4)) + 1 )) # 1->2 ... 3->4 ... 4->1
  12. peer_addr=$(test/p2p/ip.sh $peerID):46657
  13. # get another peer's height
  14. h1=`curl -s $peer_addr/status | jq .result.latest_block_height`
  15. # get another peer's state
  16. root1=`curl -s $peer_addr/status | jq .result.latest_app_hash`
  17. echo "Other peer is on height $h1 with state $root1"
  18. echo "Waiting for peer $ID to catch up"
  19. # wait for it to sync to past its previous height
  20. set +e
  21. set +o pipefail
  22. h2="0"
  23. while [[ "$h2" -lt "$(($h1+3))" ]]; do
  24. sleep 1
  25. h2=`curl -s $addr/status | jq .result.latest_block_height`
  26. echo "... $h2"
  27. done
  28. # check the app hash
  29. root2=`curl -s $addr/status | jq .result.latest_app_hash`
  30. if [[ "$root1" != "$root2" ]]; then
  31. echo "App hash after fast sync does not match. Got $root2; expected $root1"
  32. exit 1
  33. fi
  34. echo "... fast sync successful"