2017-03-05 23:12:27 -05:00
|
|
|
#! /bin/bash
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
DOCKER_IMAGE=$1
|
|
|
|
NETWORK_NAME=$2
|
|
|
|
N=$3
|
|
|
|
PROXY_APP=$4
|
|
|
|
|
|
|
|
ID=1
|
|
|
|
|
|
|
|
echo "----------------------------------------------------------------------"
|
2018-01-09 16:18:05 -06:00
|
|
|
echo "Testing pex creates the addrbook and uses it if persistent_peers are not provided"
|
2017-03-05 23:12:27 -05:00
|
|
|
echo "(assuming peers are started with pex enabled)"
|
|
|
|
|
2017-03-06 01:04:55 -05:00
|
|
|
CLIENT_NAME="pex_addrbook_$ID"
|
|
|
|
|
2017-03-05 23:12:27 -05:00
|
|
|
echo "1. restart peer $ID"
|
|
|
|
docker stop "local_testnet_$ID"
|
2018-06-27 14:31:42 -07:00
|
|
|
echo "stopped local_testnet_$ID"
|
2017-03-05 23:12:27 -05:00
|
|
|
# preserve addrbook.json
|
2018-11-01 07:07:18 +01:00
|
|
|
docker cp "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json" "/tmp/addrbook.json"
|
2017-03-05 23:12:27 -05:00
|
|
|
set +e #CIRCLE
|
|
|
|
docker rm -vf "local_testnet_$ID"
|
|
|
|
set -e
|
|
|
|
|
2018-01-09 16:18:05 -06:00
|
|
|
# NOTE that we do not provide persistent_peers
|
2017-05-26 14:20:23 -04:00
|
|
|
bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe"
|
2018-06-27 14:31:42 -07:00
|
|
|
echo "started local_testnet_$ID"
|
|
|
|
|
|
|
|
# if the client runs forever, it means addrbook wasn't saved or was empty
|
|
|
|
bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N"
|
|
|
|
|
|
|
|
# Now we know that the node is up.
|
|
|
|
|
2018-11-01 07:07:18 +01:00
|
|
|
docker cp "/tmp/addrbook.json" "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json"
|
2017-03-05 23:12:27 -05:00
|
|
|
echo "with the following addrbook:"
|
2017-03-05 23:38:11 -05:00
|
|
|
cat /tmp/addrbook.json
|
|
|
|
# exec doesn't work on circle
|
2018-11-01 07:07:18 +01:00
|
|
|
# docker exec "local_testnet_$ID" cat "/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json"
|
2017-03-05 23:12:27 -05:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "----------------------------------------------------------------------"
|
2018-01-09 16:18:05 -06:00
|
|
|
echo "Testing other peers connect to us if we have neither persistent_peers nor the addrbook"
|
2017-03-05 23:12:27 -05:00
|
|
|
echo "(assuming peers are started with pex enabled)"
|
|
|
|
|
2017-03-06 01:04:55 -05:00
|
|
|
CLIENT_NAME="pex_no_addrbook_$ID"
|
|
|
|
|
2017-03-05 23:12:27 -05:00
|
|
|
echo "1. restart peer $ID"
|
|
|
|
docker stop "local_testnet_$ID"
|
2018-06-27 14:31:42 -07:00
|
|
|
echo "stopped local_testnet_$ID"
|
2017-03-05 23:12:27 -05:00
|
|
|
set +e #CIRCLE
|
|
|
|
docker rm -vf "local_testnet_$ID"
|
2018-01-23 22:21:17 -05:00
|
|
|
set -e
|
2017-03-05 23:12:27 -05:00
|
|
|
|
2018-01-09 16:18:05 -06:00
|
|
|
# NOTE that we do not provide persistent_peers
|
2017-05-26 14:20:23 -04:00
|
|
|
bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe"
|
2018-06-27 14:31:42 -07:00
|
|
|
echo "started local_testnet_$ID"
|
2017-03-05 23:12:27 -05:00
|
|
|
|
|
|
|
# if the client runs forever, it means other peers have removed us from their books (which should not happen)
|
2017-03-06 01:04:55 -05:00
|
|
|
bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N"
|
2017-03-05 23:12:27 -05:00
|
|
|
|
2018-06-27 14:31:42 -07:00
|
|
|
# Now we know that the node is up.
|
|
|
|
|
2017-03-05 23:12:27 -05:00
|
|
|
echo ""
|
|
|
|
echo "PASS"
|
|
|
|
echo ""
|