github.com/pokt-network/tendermint@v0.32.11-0.20230426215212-59310158d3e9/test/p2p/kill_all/check_peers.sh (about) 1 #! /bin/bash 2 set -eu 3 4 IPV=$1 5 NUM_OF_PEERS=$2 6 7 # how many attempts for each peer to catch up by height 8 MAX_ATTEMPTS_TO_CATCH_UP=120 9 10 echo "Waiting for nodes to come online" 11 set +e 12 for i in $(seq 1 "$NUM_OF_PEERS"); do 13 addr=$(test/p2p/address.sh $IPV $i 26657) 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 set -e 24 25 # get the first peer's height 26 addr=$(test/p2p/address.sh $IPV 1 26657) 27 h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") 28 echo "1st peer is on height $h1" 29 30 echo "Waiting until other peers reporting a height higher than the 1st one" 31 for i in $(seq 2 "$NUM_OF_PEERS"); do 32 attempt=1 33 hi=0 34 35 while [[ $hi -le $h1 ]] ; do 36 addr=$(test/p2p/address.sh $IPV $i 26657) 37 hi=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") 38 39 echo "... peer $i is on height $hi" 40 41 ((attempt++)) 42 if [ "$attempt" -ge $MAX_ATTEMPTS_TO_CATCH_UP ] ; then 43 echo "$attempt unsuccessful attempts were made to catch up" 44 curl -s "$addr/dump_consensus_state" | jq .result 45 exit 1 46 fi 47 48 sleep 1 49 done 50 done