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.

44 lines
1.1 KiB

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