github.com/evdatsion/aphelion-dpos-bft@v0.32.1/test/p2p/fast_sync/check_peer.sh (about)

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