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