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

     1  #! /bin/bash
     2  set -eu
     3  
     4  DOCKER_IMAGE=$1
     5  NETWORK_NAME=$2
     6  IPV=$3
     7  N=$4
     8  PROXY_APP=$5
     9  
    10  ID=1
    11  
    12  echo "----------------------------------------------------------------------"
    13  echo "Testing pex creates the addrbook and uses it if persistent_peers are not provided"
    14  echo "(assuming peers are started with pex enabled)"
    15  
    16  CLIENT_NAME="pex_addrbook_$ID"
    17  
    18  echo "1. restart peer $ID"
    19  docker stop "local_testnet_$ID"
    20  echo "stopped local_testnet_$ID"
    21  # preserve addrbook.json
    22  docker cp "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json" "/tmp/addrbook.json"
    23  set +e #CIRCLE
    24  docker rm -vf "local_testnet_$ID"
    25  set -e
    26  
    27  # NOTE that we do not provide persistent_peers
    28  bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" $IPV "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe"
    29  echo "started local_testnet_$ID"
    30  
    31  # if the client runs forever, it means addrbook wasn't saved or was empty
    32  bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $IPV $ID $N"
    33  
    34  # Now we know that the node is up.
    35  
    36  docker cp "/tmp/addrbook.json" "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json"
    37  echo "with the following addrbook:"
    38  cat /tmp/addrbook.json
    39  # exec doesn't work on circle
    40  # docker exec "local_testnet_$ID" cat "/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json"
    41  echo ""
    42  
    43  echo "----------------------------------------------------------------------"
    44  echo "Testing other peers connect to us if we have neither persistent_peers nor the addrbook"
    45  echo "(assuming peers are started with pex enabled)"
    46  
    47  CLIENT_NAME="pex_no_addrbook_$ID"
    48  
    49  echo "1. restart peer $ID"
    50  docker stop "local_testnet_$ID"
    51  echo "stopped local_testnet_$ID"
    52  set +e #CIRCLE
    53  docker rm -vf "local_testnet_$ID"
    54  set -e
    55  
    56  # NOTE that we do not provide persistent_peers
    57  bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" $IPV "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe"
    58  echo "started local_testnet_$ID"
    59  
    60  # if the client runs forever, it means other peers have removed us from their books (which should not happen)
    61  bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $IPV $ID $N"
    62  
    63  # Now we know that the node is up.
    64  
    65  echo ""
    66  echo "PASS"
    67  echo ""