github.com/pokt-network/tendermint@v0.32.11-0.20230426215212-59310158d3e9/test/p2p/atomic_broadcast/test.sh (about)

     1  #! /bin/bash
     2  set -u
     3  
     4  IPV=$1
     5  N=$2
     6  
     7  ###################################################################
     8  # assumes peers are already synced up
     9  # test sending txs
    10  # for each peer:
    11  #	send a tx, wait for commit
    12  #	assert app hash on every peer reflects the post tx state
    13  ###################################################################
    14  
    15  echo ""
    16  # run the test on each of them
    17  for i in $(seq 1 "$N"); do
    18      addr=$(test/p2p/address.sh $IPV $i 26657)
    19  
    20      # current state
    21      HASH1=$(curl -s "$addr/status" | jq .result.sync_info.latest_app_hash)
    22  
    23      # - send a tx
    24      TX=aadeadbeefbeefbeef0$i
    25      echo "Broadcast Tx $TX"
    26      curl -s "$addr/broadcast_tx_commit?tx=0x$TX"
    27      echo ""
    28  
    29      # we need to wait another block to get the new app_hash
    30      h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | jq fromjson)
    31      h2=$h1
    32      while [ "$h2" == "$h1" ]; do
    33          sleep 1
    34          h2=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | jq fromjson)
    35      done
    36  
    37      # wait for all other peers to get to this height
    38      minHeight=$h2
    39      for j in $(seq 1 "$N"); do
    40          if [[ "$i" != "$j" ]]; then
    41              addrJ=$(test/p2p/address.sh $IPV $j 26657)
    42  
    43              h=$(curl -s "$addrJ/status" | jq .result.sync_info.latest_block_height | jq fromjson)
    44              while [ "$h" -lt "$minHeight" ]; do
    45                  sleep 1
    46                  h=$(curl -s "$addrJ/status" | jq .result.sync_info.latest_block_height | jq fromjson)
    47              done
    48          fi
    49      done
    50  
    51      # check that hash was updated
    52      HASH2=$(curl -s "$addr/status" | jq .result.sync_info.latest_app_hash)
    53      if [[ "$HASH1" == "$HASH2" ]]; then
    54          echo "Expected state hash to update from $HASH1. Got $HASH2"
    55          exit 1
    56      fi
    57  
    58      # check we get the same new hash on all other nodes
    59      for j in $(seq 1 "$N"); do
    60          if [[ "$i" != "$j" ]]; then
    61              addrJ=$(test/p2p/address.sh $IPV $j 26657)
    62              HASH3=$(curl -s "$addrJ/status" | jq .result.sync_info.latest_app_hash)
    63  
    64              if [[ "$HASH2" != "$HASH3" ]]; then
    65                  echo "App hash for node $j doesn't match. Got $HASH3, expected $HASH2"
    66                  exit 1
    67              fi
    68          fi
    69      done
    70  
    71      echo "All nodes are up to date"
    72  done
    73  
    74  echo ""
    75  echo "PASS"
    76  echo ""