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. ###############################################################
  5. # for each peer:
  6. # kill peer
  7. # bring it back online via fast sync
  8. # check app hash
  9. ###############################################################
  10. ID=$1
  11. addr=$(test/p2p/ip.sh $ID):46657
  12. peerID=$(( $(($ID % 4)) + 1 )) # 1->2 ... 3->4 ... 4->1
  13. peer_addr=$(test/p2p/ip.sh $peerID):46657
  14. # get another peer's height
  15. h1=`curl -s $peer_addr/status | jq .result[1].latest_block_height`
  16. # get another peer's state
  17. root1=`curl -s $peer_addr/status | jq .result[1].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[1].latest_block_height`
  27. echo "... $h2"
  28. done
  29. # check the app hash
  30. root2=`curl -s $addr/status | jq .result[1].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"