@ -1,28 +0,0 @@ | |||
name: Net | |||
# Net creates a 4 node test network with docker-compose | |||
# This workflow is run on every pull request, if a *{.go, .mod, .sum} file has been modified, and push to master and release/** branches | |||
on: | |||
pull_request: | |||
paths: | |||
- "**.go" | |||
- "**.mod" | |||
- "**.sum" | |||
push: | |||
branches: | |||
- master | |||
- release/** | |||
jobs: | |||
net-short: | |||
runs-on: ubuntu-latest | |||
timeout-minutes: 5 | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- name: 10 Blocks | |||
run: | | |||
set -x | |||
docker run --rm -v "$PWD":/go/src/github.com/tendermint/tendermint -w /go/src/github.com/tendermint/tendermint golang make build-linux | |||
make localnet-start & | |||
./scripts/localnet-blocks-test.sh 40 5 10 localhost | |||
# Decide if we want to run longer lived testnets |
@ -1,41 +0,0 @@ | |||
#!/bin/bash | |||
ITERATIONS=$1 | |||
SLEEP=$2 | |||
NUMBLOCKS=$3 | |||
NODEADDR=$4 | |||
if [ -z "$1" ]; then | |||
echo "Need to input number of iterations to run..." | |||
exit 1 | |||
fi | |||
if [ -z "$2" ]; then | |||
echo "Need to input number of seconds to sleep between iterations" | |||
exit 1 | |||
fi | |||
if [ -z "$3" ]; then | |||
echo "Need to input block height to declare completion..." | |||
exit 1 | |||
fi | |||
if [ -z "$4" ]; then | |||
echo "Need to input node address to poll..." | |||
exit 1 | |||
fi | |||
I=0 | |||
while [ ${I} -lt "$ITERATIONS" ]; do | |||
var=$(curl -s "$NODEADDR:26657/status" | jq -r ".result.sync_info.latest_block_height") | |||
echo "Number of Blocks: ${var}" | |||
if [ ! -z "${var}" ] && [ "${var}" -gt "${NUMBLOCKS}" ]; then | |||
echo "Number of blocks reached, exiting success..." | |||
exit 0 | |||
fi | |||
I=$((I+1)) | |||
sleep "$SLEEP" | |||
done | |||
echo "Timeout reached, exiting failure..." | |||
exit 1 |
@ -1,66 +0,0 @@ | |||
# Tendermint P2P Tests | |||
These scripts facilitate setting up and testing a local testnet using docker containers. | |||
Setup your own local testnet as follows. | |||
For consistency, we assume all commands are run from the Tendermint repository root. | |||
First, build the docker image: | |||
```sh | |||
docker build -t tendermint_tester -f ./test/docker/Dockerfile . | |||
``` | |||
Now create the docker network: | |||
```sh | |||
docker network create --driver bridge --subnet 172.57.0.0/16 my_testnet | |||
``` | |||
This gives us a new network with IP addresses in the rage `172.57.0.0 - 172.57.255.255`. | |||
Peers on the network can have any IP address in this range. | |||
For our four node network, let's pick `172.57.0.101 - 172.57.0.104`. | |||
Since we use Tendermint's default listening port of 26656, our list of seed nodes will look like: | |||
```sh | |||
172.57.0.101:26656,172.57.0.102:26656,172.57.0.103:26656,172.57.0.104:26656 | |||
``` | |||
Now we can start up the peers. We already have config files setup in `test/p2p/data/`. | |||
Let's use a for-loop to start our peers: | |||
```sh | |||
for i in $(seq 1 4); do | |||
docker run -d \ | |||
--net=my_testnet\ | |||
--ip="172.57.0.$((100 + $i))" \ | |||
--name local_testnet_$i \ | |||
--entrypoint tendermint \ | |||
-e TMHOME=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$((i-1)) \ | |||
tendermint_tester node --p2p.persistent_peers 172.57.0.101:26656,172.57.0.102:26656,172.57.0.103:26656,172.57.0.104:26656 --proxy_app=kvstore | |||
done | |||
``` | |||
If you now run `docker ps`, you'll see your containers! | |||
We can confirm they are making blocks by checking the `/status` message using `curl` and `jq` to pretty print the output json: | |||
```sh | |||
curl 172.57.0.101:26657/status | jq . | |||
``` | |||
## IPv6 tests | |||
IPv6 tests require a Docker daemon with IPv6 enabled, by setting the following in `daemon.json`: | |||
```json | |||
{ | |||
"ipv6": true, | |||
"fixed-cidr-v6": "2001:db8:1::/64" | |||
} | |||
``` | |||
In Docker for Mac, this is done via Preferences → Docker Engine. | |||
Once set, run IPv6 tests via `make test_p2p_ipv6`. |
@ -1,28 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
IPV=$1 | |||
ID=$2 | |||
PORT=${3:-} | |||
DOCKER_IMAGE=${4:-} | |||
if [[ "$IPV" == 6 ]]; then | |||
ADDRESS="fd80:b10c::" | |||
else | |||
ADDRESS="172.57.0." | |||
fi | |||
ADDRESS="$ADDRESS$((100+$ID))" | |||
if [[ -n "$PORT" ]]; then | |||
if [[ "$IPV" == 6 ]]; then | |||
ADDRESS="[$ADDRESS]" | |||
fi | |||
ADDRESS="$ADDRESS:$PORT" | |||
fi | |||
if [[ -n "$DOCKER_IMAGE" ]]; then | |||
NODEID="$(docker run --rm -e TMHOME=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$((ID-1)) $DOCKER_IMAGE tendermint show_node_id)" | |||
ADDRESS="$NODEID@$ADDRESS" | |||
fi | |||
echo $ADDRESS |
@ -1,76 +0,0 @@ | |||
#! /bin/bash | |||
set -u | |||
IPV=$1 | |||
N=$2 | |||
################################################################### | |||
# assumes peers are already synced up | |||
# test sending txs | |||
# for each peer: | |||
# send a tx, wait for commit | |||
# assert app hash on every peer reflects the post tx state | |||
################################################################### | |||
echo "" | |||
# run the test on each of them | |||
for i in $(seq 1 "$N"); do | |||
addr=$(test/p2p/address.sh $IPV $i 26657) | |||
# current state | |||
HASH1=$(curl -s "$addr/status" | jq .result.sync_info.latest_app_hash) | |||
# - send a tx | |||
TX=aadeadbeefbeefbeef0$i | |||
echo "Broadcast Tx $TX" | |||
curl -s "$addr/broadcast_tx_commit?tx=0x$TX" | |||
echo "" | |||
# we need to wait another block to get the new app_hash | |||
h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | jq fromjson) | |||
h2=$h1 | |||
while [ "$h2" == "$h1" ]; do | |||
sleep 1 | |||
h2=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | jq fromjson) | |||
done | |||
# wait for all other peers to get to this height | |||
minHeight=$h2 | |||
for j in $(seq 1 "$N"); do | |||
if [[ "$i" != "$j" ]]; then | |||
addrJ=$(test/p2p/address.sh $IPV $j 26657) | |||
h=$(curl -s "$addrJ/status" | jq .result.sync_info.latest_block_height | jq fromjson) | |||
while [ "$h" -lt "$minHeight" ]; do | |||
sleep 1 | |||
h=$(curl -s "$addrJ/status" | jq .result.sync_info.latest_block_height | jq fromjson) | |||
done | |||
fi | |||
done | |||
# check that hash was updated | |||
HASH2=$(curl -s "$addr/status" | jq .result.sync_info.latest_app_hash) | |||
if [[ "$HASH1" == "$HASH2" ]]; then | |||
echo "Expected state hash to update from $HASH1. Got $HASH2" | |||
exit 1 | |||
fi | |||
# check we get the same new hash on all other nodes | |||
for j in $(seq 1 "$N"); do | |||
if [[ "$i" != "$j" ]]; then | |||
addrJ=$(test/p2p/address.sh $IPV $j 26657) | |||
HASH3=$(curl -s "$addrJ/status" | jq .result.sync_info.latest_app_hash) | |||
if [[ "$HASH2" != "$HASH3" ]]; then | |||
echo "App hash for node $j doesn't match. Got $HASH3, expected $HASH2" | |||
exit 1 | |||
fi | |||
fi | |||
done | |||
echo "All nodes are up to date" | |||
done | |||
echo "" | |||
echo "PASS" | |||
echo "" |
@ -1,76 +0,0 @@ | |||
#! /bin/bash | |||
set -u | |||
IPV=$1 | |||
N=$2 | |||
################################################################### | |||
# wait for all peers to come online | |||
# for each peer: | |||
# wait to have N-1 peers | |||
# wait to be at height > 1 | |||
################################################################### | |||
# wait 60s per step per peer | |||
MAX_SLEEP=60 | |||
# wait for everyone to come online | |||
echo "Waiting for nodes to come online" | |||
for i in `seq 1 $N`; do | |||
addr=$(test/p2p/address.sh $IPV $i 26657) | |||
curl -s $addr/status > /dev/null | |||
ERR=$? | |||
COUNT=0 | |||
while [ "$ERR" != 0 ]; do | |||
sleep 1 | |||
curl -s $addr/status > /dev/null | |||
ERR=$? | |||
COUNT=$((COUNT+1)) | |||
if [ "$COUNT" -gt "$MAX_SLEEP" ]; then | |||
echo "Waited too long for node $i to come online" | |||
exit 1 | |||
fi | |||
done | |||
echo "... node $i is up" | |||
done | |||
echo "" | |||
# wait for each of them to sync up | |||
for i in `seq 1 $N`; do | |||
addr=$(test/p2p/address.sh $IPV $i 26657) | |||
N_1=$(($N - 1)) | |||
# - assert everyone has N-1 other peers | |||
N_PEERS=`curl -s $addr/net_info | jq '.result.peers | length'` | |||
COUNT=0 | |||
while [ "$N_PEERS" != $N_1 ]; do | |||
echo "Waiting for node $i to connect to all peers ..." | |||
sleep 1 | |||
N_PEERS=`curl -s $addr/net_info | jq '.result.peers | length'` | |||
COUNT=$((COUNT+1)) | |||
if [ "$COUNT" -gt "$MAX_SLEEP" ]; then | |||
echo "Waited too long for node $i to connect to all peers" | |||
exit 1 | |||
fi | |||
done | |||
# - assert block height is greater than 1 | |||
BLOCK_HEIGHT=`curl -s $addr/status | jq .result.sync_info.latest_block_height | jq fromjson` | |||
COUNT=0 | |||
echo "$$BLOCK_HEIGHT IS $BLOCK_HEIGHT" | |||
while [ "$BLOCK_HEIGHT" -le 1 ]; do | |||
echo "Waiting for node $i to commit a block ..." | |||
sleep 1 | |||
BLOCK_HEIGHT=`curl -s $addr/status | jq .result.sync_info.latest_block_height | jq fromjson` | |||
COUNT=$((COUNT+1)) | |||
if [ "$COUNT" -gt "$MAX_SLEEP" ]; then | |||
echo "Waited too long for node $i to commit a block" | |||
exit 1 | |||
fi | |||
done | |||
echo "Node $i is connected to all peers and at block $BLOCK_HEIGHT" | |||
done | |||
echo "" | |||
echo "PASS" | |||
echo "" |
@ -1,55 +0,0 @@ | |||
#! /bin/bash | |||
set -eux | |||
# Take IP version as parameter | |||
IPV="${1:-4}" | |||
# Get the directory of where this script is. | |||
SOURCE="${BASH_SOURCE[0]}" | |||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done | |||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | |||
# Enable IPv6 support in Docker daemon | |||
if [[ "$IPV" == "6" ]]; then | |||
echo | |||
echo "* [$(date +"%T")] enabling IPv6 stack in Docker daemon" | |||
cat <<'EOF' | sudo tee /etc/docker/daemon.json | |||
{ | |||
"ipv6": true, | |||
"fixed-cidr-v6": "2001:db8:1::/64" | |||
} | |||
EOF | |||
sudo service docker restart | |||
fi | |||
LOGS_DIR="$DIR/logs" | |||
echo | |||
echo "* [$(date +"%T")] cleaning up $LOGS_DIR" | |||
rm -rf "$LOGS_DIR" | |||
mkdir -p "$LOGS_DIR" | |||
set +e | |||
echo | |||
echo "* [$(date +"%T")] removing run_test container" | |||
docker rm -vf run_test | |||
set -e | |||
echo | |||
echo "* [$(date +"%T")] starting rsyslog container" | |||
docker rm -f rsyslog || true | |||
docker run -d -v "$LOGS_DIR:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog | |||
set +u | |||
if [[ "$SKIP_BUILD" == "" ]]; then | |||
echo | |||
echo "* [$(date +"%T")] building docker image" | |||
bash "$DIR/../docker/build.sh" | |||
fi | |||
echo | |||
echo "* [$(date +"%T")] running IPv$IPV p2p tests on a local docker network" | |||
bash "$DIR/../p2p/test.sh" tester $IPV | |||
echo | |||
echo "* [$(date +"%T")] copying log files out of docker container into $LOGS_DIR" | |||
docker cp rsyslog:/var/log $LOGS_DIR |
@ -1,26 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
ID=$4 | |||
CMD=$5 | |||
NAME=test_container_$ID | |||
if [[ "$IPV" == 6 ]]; then | |||
IP_SWITCH="--ip6" | |||
else | |||
IP_SWITCH="--ip" | |||
fi | |||
echo "starting test client container with CMD=$CMD" | |||
# run the test container on the local network | |||
docker run -t --rm \ | |||
-v "$PWD/test/p2p/:/go/src/github.com/tendermint/tendermint/test/p2p" \ | |||
--net="$NETWORK_NAME" \ | |||
$IP_SWITCH=$(test/p2p/address.sh $IPV -1) \ | |||
--name "$NAME" \ | |||
--entrypoint bash \ | |||
"$DOCKER_IMAGE" $CMD |
@ -1,64 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
set -o pipefail | |||
IPV=$1 | |||
ID=$2 | |||
ASSERT_CASE=$3 | |||
ASSERT_NODE_UP=1 | |||
ASSERT_NODE_DOWN=0 | |||
MAX_TRY=10 | |||
########################################### | |||
# | |||
# Wait for peer to catchup to other peers | |||
# | |||
########################################### | |||
addr=$(test/p2p/address.sh $IPV $ID 26657) | |||
peerID=$(( $(($ID % 4)) + 1 )) # 1->2 ... 3->4 ... 4->1 | |||
peer_addr=$(test/p2p/address.sh $IPV $peerID 26657) | |||
# get another peer's height | |||
h1=`curl -s $peer_addr/status | jq .result.sync_info.latest_block_height | jq fromjson` | |||
# get another peer's state | |||
root1=`curl -s $peer_addr/status | jq .result.sync_info.latest_app_hash` | |||
echo "Other peer is on height $h1 with state $root1" | |||
echo "Waiting for peer $ID to catch up" | |||
# wait for it to sync to past its previous height | |||
set +e | |||
set +o pipefail | |||
h2="0" | |||
COUNT=0 | |||
while [[ "$h2" -lt "$(($h1+1))" ]]; do | |||
sleep 1 | |||
h2=`curl -s $addr/status --connect-timeout 1 | jq .result.sync_info.latest_block_height | jq fromjson` | |||
COUNT=$((COUNT+1)) | |||
echo "... $h2, try $COUNT" | |||
if [ "$COUNT" -ge "$MAX_TRY" ]; then | |||
if [ $ASSERT_CASE -eq $ASSERT_NODE_DOWN ]; then | |||
echo "double sign risk reduction operates normally as expected" | |||
fi | |||
if [ $ASSERT_CASE -eq $ASSERT_NODE_UP ]; then | |||
echo "double sign risk reduction fail" | |||
exit 1 | |||
fi | |||
break | |||
fi | |||
done | |||
if [ $ASSERT_CASE -eq $ASSERT_NODE_UP ]; then | |||
# check the app hash | |||
root2=`curl -s $addr/status | jq .result.sync_info.latest_app_hash` | |||
if [[ "$root1" != "$root2" ]]; then | |||
echo "App hash after restart does not match. Got $root2; expected $root1" | |||
exit 1 | |||
fi | |||
echo "... double sign risk reduction test passed" | |||
fi |
@ -1,13 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
N=$4 | |||
PROXY_APP=$5 | |||
# run it on each of them | |||
for i in `seq 1 $N`; do | |||
bash test/p2p/dsrr/test_peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $i $N $PROXY_APP | |||
done |
@ -1,65 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
set -o pipefail | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
ID=$4 | |||
N=$5 | |||
PROXY_APP=$6 | |||
ASSERT_NODE_UP=1 | |||
ASSERT_NODE_DOWN=0 | |||
###########################s#################################### | |||
# this runs on each peer: | |||
# kill peer | |||
# bring it back online with double_sign_check_height 10 | |||
# wait node is not run by double sign risk reduction | |||
# | |||
# kill peer | |||
# bring it back online with double_sign_check_height 1 | |||
# pass double sign risk reduction, wait for it to sync and check the app hash | |||
# | |||
# kill peer | |||
# bring it back online with double_sign_check_height 0 | |||
# wait for it to sync and check the app hash | |||
############################################################### | |||
echo "Testing double sign risk reduction on node $ID" | |||
# kill peer | |||
set +e | |||
docker rm -vf local_testnet_$ID | |||
set -e | |||
PERSISTENT_PEERS="$(test/p2p/address.sh $IPV 1 26656 $DOCKER_IMAGE)" | |||
for j in `seq 2 $N`; do | |||
PERSISTENT_PEERS="$PERSISTENT_PEERS,$(test/p2p/address.sh $IPV $j 26656 $DOCKER_IMAGE)" | |||
done | |||
# bring it back online with double_sign_check_height 10 | |||
# wait node is not run by double sign risk reduction | |||
DSCH=10 | |||
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe --consensus.double_sign_check_height $DSCH" | |||
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV fs_$ID "test/p2p/dsrr/check_peer.sh $IPV $ID $ASSERT_NODE_DOWN" | |||
docker stop local_testnet_$ID | |||
docker rm local_testnet_$ID | |||
# bring it back online with double_sign_check_height 1 | |||
# pass double sign risk reduction, wait for it to sync and check the app hash | |||
DSCH=1 | |||
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe --consensus.double_sign_check_height $DSCH" | |||
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV fs_$ID "test/p2p/dsrr/check_peer.sh $IPV $ID $ASSERT_NODE_UP" | |||
docker stop local_testnet_$ID | |||
docker rm local_testnet_$ID | |||
DSCH=0 | |||
# bring it back online with double_sign_check_height 0 | |||
# double sign risk reduction is not activated, wait for it to sync and check the app hash | |||
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe --consensus.double_sign_check_height $DSCH" | |||
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV fs_$ID "test/p2p/dsrr/check_peer.sh $IPV $ID $ASSERT_NODE_UP" | |||
echo "" | |||
echo "PASS" | |||
echo "" |
@ -1,44 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
set -o pipefail | |||
IPV=$1 | |||
ID=$2 | |||
########################################### | |||
# | |||
# Wait for peer to catchup to other peers | |||
# | |||
########################################### | |||
addr=$(test/p2p/address.sh $IPV $ID 26657) | |||
peerID=$(( $(($ID % 4)) + 1 )) # 1->2 ... 3->4 ... 4->1 | |||
peer_addr=$(test/p2p/address.sh $IPV $peerID 26657) | |||
# get another peer's height | |||
h1=`curl -s $peer_addr/status | jq .result.sync_info.latest_block_height | jq fromjson` | |||
# get another peer's state | |||
root1=`curl -s $peer_addr/status | jq .result.sync_info.latest_app_hash` | |||
echo "Other peer is on height $h1 with state $root1" | |||
echo "Waiting for peer $ID to catch up" | |||
# wait for it to sync to past its previous height | |||
set +e | |||
set +o pipefail | |||
h2="0" | |||
while [[ "$h2" -lt "$(($h1+3))" ]]; do | |||
sleep 1 | |||
h2=`curl -s $addr/status | jq .result.sync_info.latest_block_height | jq fromjson` | |||
echo "... $h2" | |||
done | |||
# check the app hash | |||
root2=`curl -s $addr/status | jq .result.sync_info.latest_app_hash` | |||
if [[ "$root1" != "$root2" ]]; then | |||
echo "App hash after fast sync does not match. Got $root2; expected $root1" | |||
exit 1 | |||
fi | |||
echo "... fast sync successful" |
@ -1,15 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
N=$4 | |||
PROXY_APP=$5 | |||
# run it on each of them | |||
for i in `seq 1 $N`; do | |||
bash test/p2p/fast_sync/test_peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $i $N $PROXY_APP | |||
done | |||
@ -1,39 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
ID=$4 | |||
N=$5 | |||
PROXY_APP=$6 | |||
############################################################### | |||
# this runs on each peer: | |||
# kill peer | |||
# bring it back online via fast sync | |||
# wait for it to sync and check the app hash | |||
############################################################### | |||
echo "Testing fastsync on node $ID" | |||
# kill peer | |||
set +e # circle sigh :( | |||
docker rm -vf local_testnet_$ID | |||
set -e | |||
# restart peer - should have an empty blockchain | |||
PERSISTENT_PEERS="$(test/p2p/address.sh $IPV 1 26656 $DOCKER_IMAGE)" | |||
for j in `seq 2 $N`; do | |||
PERSISTENT_PEERS="$PERSISTENT_PEERS,$(test/p2p/address.sh $IPV $j 26656 $DOCKER_IMAGE)" | |||
done | |||
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe" | |||
# wait for peer to sync and check the app hash | |||
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV fs_$ID "test/p2p/fast_sync/check_peer.sh $IPV $ID" | |||
echo "" | |||
echo "PASS" | |||
echo "" | |||
@ -1,50 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
IPV=$1 | |||
NUM_OF_PEERS=$2 | |||
# how many attempts for each peer to catch up by height | |||
MAX_ATTEMPTS_TO_CATCH_UP=120 | |||
echo "Waiting for nodes to come online" | |||
set +e | |||
for i in $(seq 1 "$NUM_OF_PEERS"); do | |||
addr=$(test/p2p/address.sh $IPV $i 26657) | |||
curl -s "$addr/status" > /dev/null | |||
ERR=$? | |||
while [ "$ERR" != 0 ]; do | |||
sleep 1 | |||
curl -s "$addr/status" > /dev/null | |||
ERR=$? | |||
done | |||
echo "... node $i is up" | |||
done | |||
set -e | |||
# get the first peer's height | |||
addr=$(test/p2p/address.sh $IPV 1 26657) | |||
h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") | |||
echo "1st peer is on height $h1" | |||
echo "Waiting until other peers reporting a height higher than the 1st one" | |||
for i in $(seq 2 "$NUM_OF_PEERS"); do | |||
attempt=1 | |||
hi=0 | |||
while [[ $hi -le $h1 ]] ; do | |||
addr=$(test/p2p/address.sh $IPV $i 26657) | |||
hi=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") | |||
echo "... peer $i is on height $hi" | |||
((attempt++)) | |||
if [ "$attempt" -ge $MAX_ATTEMPTS_TO_CATCH_UP ] ; then | |||
echo "$attempt unsuccessful attempts were made to catch up" | |||
curl -s "$addr/dump_consensus_state" | jq .result | |||
exit 1 | |||
fi | |||
sleep 1 | |||
done | |||
done |
@ -1,31 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
NUM_OF_PEERS=$4 | |||
NUM_OF_CRASHES=$5 | |||
############################################################### | |||
# NUM_OF_CRASHES times: | |||
# restart all peers | |||
# wait for them to sync and check that they are making progress | |||
############################################################### | |||
for i in $(seq 1 "$NUM_OF_CRASHES"); do | |||
echo "" | |||
echo "Restarting all peers! Take $i ..." | |||
# restart all peers | |||
for j in $(seq 1 "$NUM_OF_PEERS"); do | |||
docker stop "local_testnet_$j" | |||
docker start "local_testnet_$j" | |||
done | |||
bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" kill_all_$i "test/p2p/kill_all/check_peers.sh $IPV $NUM_OF_PEERS" | |||
done | |||
echo "" | |||
echo "PASS" | |||
echo "" |
@ -1,27 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
N=$4 | |||
APP_PROXY=$5 | |||
set +u | |||
PERSISTENT_PEERS=$6 | |||
if [[ "$PERSISTENT_PEERS" != "" ]]; then | |||
echo "PersistentPeers: $PERSISTENT_PEERS" | |||
PERSISTENT_PEERS="--p2p.persistent_peers $PERSISTENT_PEERS" | |||
fi | |||
set -u | |||
# create docker network | |||
if [[ $IPV == 6 ]]; then | |||
docker network create --driver bridge --ipv6 --subnet fd80:b10c::/48 "$NETWORK_NAME" | |||
else | |||
docker network create --driver bridge --subnet 172.57.0.0/16 "$NETWORK_NAME" | |||
fi | |||
for i in $(seq 1 "$N"); do | |||
bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" $IPV "$i" "$APP_PROXY" "$PERSISTENT_PEERS --p2p.pex --rpc.unsafe" | |||
done |
@ -1,12 +0,0 @@ | |||
#! /bin/bash | |||
set -u | |||
NETWORK_NAME=$1 | |||
N=$2 | |||
for i in $(seq 1 "$N"); do | |||
docker stop "local_testnet_$i" | |||
docker rm -vf "local_testnet_$i" | |||
done | |||
docker network rm "$NETWORK_NAME" |
@ -1,53 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
ID=$4 | |||
APP_PROXY=$5 | |||
set +u | |||
NODE_FLAGS=$6 | |||
set -u | |||
if [[ "$IPV" == 6 ]]; then | |||
IP_SWITCH="--ip6" | |||
else | |||
IP_SWITCH="--ip" | |||
fi | |||
echo "starting tendermint peer ID=$ID" | |||
# start tendermint container on the network | |||
# NOTE: $NODE_FLAGS should be unescaped (no quotes). otherwise it will be | |||
# treated as one flag. | |||
# test/p2p/data/mach$((ID-1)) data is generated in test/docker/Dockerfile using | |||
# the tendermint testnet command. | |||
if [[ "$ID" == "x" ]]; then # Set "x" to "1" to print to console. | |||
docker run \ | |||
--net="$NETWORK_NAME" \ | |||
$IP_SWITCH=$(test/p2p/address.sh $IPV $ID) \ | |||
--name "local_testnet_$ID" \ | |||
--entrypoint tendermint \ | |||
-e TMHOME="/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$((ID-1))" \ | |||
-e GOMAXPROCS=1 \ | |||
--log-driver=syslog \ | |||
--log-opt syslog-address=udp://127.0.0.1:5514 \ | |||
--log-opt syslog-facility=daemon \ | |||
--log-opt tag="{{.Name}}" \ | |||
"$DOCKER_IMAGE" node $NODE_FLAGS --log_level=debug --proxy_app="$APP_PROXY" & | |||
else | |||
docker run -d \ | |||
--net="$NETWORK_NAME" \ | |||
$IP_SWITCH=$(test/p2p/address.sh $IPV $ID) \ | |||
--name "local_testnet_$ID" \ | |||
--entrypoint tendermint \ | |||
-e TMHOME="/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$((ID-1))" \ | |||
-e GOMAXPROCS=1 \ | |||
--log-driver=syslog \ | |||
--log-opt syslog-address=udp://127.0.0.1:5514 \ | |||
--log-opt syslog-facility=daemon \ | |||
--log-opt tag="{{.Name}}" \ | |||
"$DOCKER_IMAGE" node $NODE_FLAGS --log_level=debug --proxy_app="$APP_PROXY" | |||
fi |
@ -1,12 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
IPV=$1 | |||
N=$2 | |||
DOCKER_IMAGE=$3 | |||
persistent_peers="$(test/p2p/address.sh $IPV 1 26656 $DOCKER_IMAGE)" | |||
for i in $(seq 2 $N); do | |||
persistent_peers="$persistent_peers,$(test/p2p/address.sh $IPV $i 26656 $DOCKER_IMAGE)" | |||
done | |||
echo "$persistent_peers" |
@ -1,18 +0,0 @@ | |||
#! /bin/bash | |||
set -u | |||
IPV=$1 | |||
ID=$2 | |||
N=$3 | |||
addr=$(test/p2p/address.sh $IPV "$ID" 26657) | |||
echo "2. wait until peer $ID connects to other nodes using pex reactor" | |||
peers_count="0" | |||
while [[ "$peers_count" -lt "$((N-1))" ]]; do | |||
sleep 1 | |||
peers_count=$(curl -s "$addr/net_info" | jq ".result.peers | length") | |||
echo "... peers count = $peers_count, expected = $((N-1))" | |||
done | |||
echo "... successful" |
@ -1,22 +0,0 @@ | |||
#! /bin/bash | |||
set -u | |||
IPV=$1 | |||
N=$2 | |||
PEERS=$3 | |||
echo "Waiting for nodes to come online" | |||
for i in $(seq 1 "$N"); do | |||
addr=$(test/p2p/address.sh $IPV $i 26657) | |||
curl -s "$addr/status" > /dev/null | |||
ERR=$? | |||
while [ "$ERR" != 0 ]; do | |||
sleep 1 | |||
curl -s "$addr/status" > /dev/null | |||
ERR=$? | |||
done | |||
echo "... node $i is up" | |||
done | |||
ADDR=$(test/p2p/address.sh $IPV 1 26657) | |||
curl "$ADDR/dial_peers?persistent=true&peers=\\[$PEERS\\]" |
@ -1,14 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
N=$4 | |||
PROXY_APP=$5 | |||
echo "Test reconnecting from the address book" | |||
bash test/p2p/pex/test_addrbook.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" | |||
echo "Test connecting via /dial_peers" | |||
bash test/p2p/pex/test_dial_peers.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" |
@ -1,67 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
N=$4 | |||
PROXY_APP=$5 | |||
ID=1 | |||
echo "----------------------------------------------------------------------" | |||
echo "Testing pex creates the addrbook and uses it if persistent_peers are not provided" | |||
echo "(assuming peers are started with pex enabled)" | |||
CLIENT_NAME="pex_addrbook_$ID" | |||
echo "1. restart peer $ID" | |||
docker stop "local_testnet_$ID" | |||
echo "stopped local_testnet_$ID" | |||
# preserve addrbook.json | |||
docker cp "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json" "/tmp/addrbook.json" | |||
set +e #CIRCLE | |||
docker rm -vf "local_testnet_$ID" | |||
set -e | |||
# NOTE that we do not provide persistent_peers | |||
bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" $IPV "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" | |||
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" "$IPV" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $IPV $ID $N" | |||
# Now we know that the node is up. | |||
docker cp "/tmp/addrbook.json" "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json" | |||
echo "with the following addrbook:" | |||
cat /tmp/addrbook.json | |||
# exec doesn't work on circle | |||
# docker exec "local_testnet_$ID" cat "/go/src/github.com/tendermint/tendermint/test/p2p/data/mach0/config/addrbook.json" | |||
echo "" | |||
echo "----------------------------------------------------------------------" | |||
echo "Testing other peers connect to us if we have neither persistent_peers nor the addrbook" | |||
echo "(assuming peers are started with pex enabled)" | |||
CLIENT_NAME="pex_no_addrbook_$ID" | |||
echo "1. restart peer $ID" | |||
docker stop "local_testnet_$ID" | |||
echo "stopped local_testnet_$ID" | |||
set +e #CIRCLE | |||
docker rm -vf "local_testnet_$ID" | |||
set -e | |||
# NOTE that we do not provide persistent_peers | |||
bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" $IPV "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" | |||
echo "started local_testnet_$ID" | |||
# if the client runs forever, it means other peers have removed us from their books (which should not happen) | |||
bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $IPV $ID $N" | |||
# Now we know that the node is up. | |||
echo "" | |||
echo "PASS" | |||
echo "" |
@ -1,38 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=$2 | |||
IPV=$3 | |||
N=$4 | |||
PROXY_APP=$5 | |||
ID=1 | |||
echo "----------------------------------------------------------------------" | |||
echo "Testing full network connection using one /dial_peers call" | |||
echo "(assuming peers are started with pex enabled)" | |||
# stop the existing testnet and remove local network | |||
set +e | |||
bash test/p2p/local_testnet_stop.sh $NETWORK_NAME $N | |||
set -e | |||
# start the testnet on a local network | |||
# NOTE we re-use the same network for all tests | |||
bash test/p2p/local_testnet_start.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $N $PROXY_APP "" | |||
PERSISTENT_PEERS="\"$(test/p2p/address.sh $IPV 1 26656 $DOCKER_IMAGE)\"" | |||
for i in $(seq 2 $N); do | |||
PERSISTENT_PEERS="$PERSISTENT_PEERS,\"$(test/p2p/address.sh $IPV $i 26656 $DOCKER_IMAGE)\"" | |||
done | |||
echo "$PERSISTENT_PEERS" | |||
# dial peers from one node | |||
CLIENT_NAME="dial_peers" | |||
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $CLIENT_NAME "test/p2p/pex/dial_peers.sh $IPV $N $PERSISTENT_PEERS" | |||
# test basic connectivity and consensus | |||
# start client container and check the num peers and height for all nodes | |||
CLIENT_NAME="dial_peers_basic" | |||
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $CLIENT_NAME "test/p2p/basic/test.sh $IPV $N" |
@ -1,45 +0,0 @@ | |||
#! /bin/bash | |||
set -eu | |||
DOCKER_IMAGE=$1 | |||
NETWORK_NAME=local_testnet | |||
N=4 | |||
PROXY_APP=persistent_kvstore | |||
IPV=${2:-4} # Default to IPv4 | |||
if [[ "$IPV" != "4" && "$IPV" != "6" ]]; then | |||
echo "IP version must be 4 or 6" >&2 | |||
exit 1 | |||
fi | |||
# stop the existing testnet and remove local network | |||
set +e | |||
bash test/p2p/local_testnet_stop.sh "$NETWORK_NAME" "$N" | |||
set -e | |||
PERSISTENT_PEERS=$(bash test/p2p/persistent_peers.sh $IPV $N $DOCKER_IMAGE) | |||
# start the testnet on a local network | |||
# NOTE we re-use the same network for all tests | |||
bash test/p2p/local_testnet_start.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" "$PERSISTENT_PEERS" | |||
# test basic connectivity and consensus | |||
# start client container and check the num peers and height for all nodes | |||
bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" basic "test/p2p/basic/test.sh $IPV $N" | |||
# test atomic broadcast: | |||
# start client container and test sending a tx to each node | |||
bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" ab "test/p2p/atomic_broadcast/test.sh $IPV $N" | |||
# test fast sync (from current state of network): | |||
# for each node, kill it and readd via fast sync | |||
bash test/p2p/fast_sync/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" | |||
# test double sign risk reduction for each node | |||
bash test/p2p/dsrr/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" | |||
# test killing all peers 3 times | |||
bash test/p2p/kill_all/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" 3 | |||
# test pex | |||
bash test/p2p/pex/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" |
@ -1,124 +0,0 @@ | |||
#! /bin/bash | |||
export PATH="$GOBIN:$PATH" | |||
export TMHOME=$HOME/.tendermint_persist | |||
rm -rf "$TMHOME" | |||
tendermint init | |||
# use a unix socket so we can remove it | |||
RPC_ADDR="$(pwd)/rpc.sock" | |||
TM_CMD="tendermint node --log_level=debug --rpc.laddr=unix://$RPC_ADDR" # &> tendermint_${name}.log" | |||
DUMMY_CMD="abci-cli kvstore --persist $TMHOME/kvstore" # &> kvstore_${name}.log" | |||
function start_procs(){ | |||
name=$1 | |||
indexToFail=$2 | |||
echo "Starting persistent kvstore and tendermint" | |||
if [[ "$CIRCLECI" == true ]]; then | |||
$DUMMY_CMD & | |||
else | |||
$DUMMY_CMD &> "kvstore_${name}.log" & | |||
fi | |||
PID_DUMMY=$! | |||
# before starting tendermint, remove the rpc socket | |||
rm -f $RPC_ADDR | |||
if [[ "$indexToFail" == "" ]]; then | |||
# run in background, dont fail | |||
if [[ "$CIRCLECI" == true ]]; then | |||
$TM_CMD & | |||
else | |||
$TM_CMD &> "tendermint_${name}.log" & | |||
fi | |||
PID_TENDERMINT=$! | |||
else | |||
# run in foreground, fail | |||
if [[ "$CIRCLECI" == true ]]; then | |||
FAIL_TEST_INDEX=$indexToFail $TM_CMD | |||
else | |||
FAIL_TEST_INDEX=$indexToFail $TM_CMD &> "tendermint_${name}.log" | |||
fi | |||
PID_TENDERMINT=$! | |||
fi | |||
} | |||
function kill_procs(){ | |||
kill -9 "$PID_DUMMY" "$PID_TENDERMINT" | |||
wait "$PID_DUMMY" | |||
wait "$PID_TENDERMINT" | |||
} | |||
# wait for port to be available | |||
function wait_for_port() { | |||
port=$1 | |||
# this will succeed while port is bound | |||
nc -z 127.0.0.1 $port | |||
ERR=$? | |||
i=0 | |||
while [ "$ERR" == 0 ]; do | |||
echo "... port $port is still bound. waiting ..." | |||
sleep 1 | |||
nc -z 127.0.0.1 $port | |||
ERR=$? | |||
i=$((i + 1)) | |||
if [[ $i == 10 ]]; then | |||
echo "Timed out waiting for port to be released" | |||
exit 1 | |||
fi | |||
done | |||
echo "... port $port is free!" | |||
} | |||
failsStart=0 | |||
fails=$(grep -r "fail.Fail" --include \*.go . | wc -l) | |||
failsEnd=$((fails-1)) | |||
for failIndex in $(seq $failsStart $failsEnd); do | |||
echo "" | |||
echo "* Test FailIndex $failIndex" | |||
# test failure at failIndex | |||
bash $(dirname $0)/txs.sh "localhost:26657" & | |||
start_procs 1 "$failIndex" | |||
# tendermint should already have exited when it hits the fail index | |||
# but kill -9 for good measure | |||
kill_procs | |||
start_procs 2 | |||
# wait for node to handshake and make a new block | |||
# NOTE: --unix-socket is only available in curl v7.40+ | |||
curl -s --unix-socket "$RPC_ADDR" http://localhost/status > /dev/null | |||
ERR=$? | |||
i=0 | |||
while [ "$ERR" != 0 ]; do | |||
sleep 1 | |||
curl -s --unix-socket "$RPC_ADDR" http://localhost/status > /dev/null | |||
ERR=$? | |||
i=$((i + 1)) | |||
if [[ $i == 20 ]]; then | |||
echo "Timed out waiting for tendermint to start" | |||
exit 1 | |||
fi | |||
done | |||
# wait for a new block | |||
h1=$(curl -s --unix-socket "$RPC_ADDR" http://localhost/status | jq .result.sync_info.latest_block_height) | |||
h2=$h1 | |||
while [ "$h2" == "$h1" ]; do | |||
sleep 1 | |||
h2=$(curl -s --unix-socket "$RPC_ADDR" http://localhost/status | jq .result.sync_info.latest_block_height) | |||
done | |||
kill_procs | |||
echo "* Passed Test for FailIndex $failIndex" | |||
echo "" | |||
done | |||
echo "Passed Test: Persistence" |
@ -1,70 +0,0 @@ | |||
#! /bin/bash | |||
export TMHOME=$HOME/.tendermint_persist | |||
rm -rf $TMHOME | |||
tendermint init | |||
function start_procs(){ | |||
name=$1 | |||
echo "Starting persistent kvstore and tendermint" | |||
abci-cli kvstore --persist $TMHOME/kvstore &> "kvstore_${name}.log" & | |||
PID_DUMMY=$! | |||
tendermint node &> tendermint_${name}.log & | |||
PID_TENDERMINT=$! | |||
sleep 5 | |||
} | |||
function kill_procs(){ | |||
kill -9 $PID_DUMMY $PID_TENDERMINT | |||
} | |||
function send_txs(){ | |||
# send a bunch of txs over a few blocks | |||
echo "Sending txs" | |||
for i in `seq 1 5`; do | |||
for j in `seq 1 100`; do | |||
tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'` | |||
curl -s 127.0.0.1:26657/broadcast_tx_async?tx=0x$tx &> /dev/null | |||
done | |||
sleep 1 | |||
done | |||
} | |||
start_procs 1 | |||
send_txs | |||
kill_procs | |||
start_procs 2 | |||
# wait for node to handshake and make a new block | |||
addr="localhost:26657" | |||
curl -s $addr/status > /dev/null | |||
ERR=$? | |||
i=0 | |||
while [ "$ERR" != 0 ]; do | |||
sleep 1 | |||
curl -s $addr/status > /dev/null | |||
ERR=$? | |||
i=$(($i + 1)) | |||
if [[ $i == 10 ]]; then | |||
echo "Timed out waiting for tendermint to start" | |||
exit 1 | |||
fi | |||
done | |||
# wait for a new block | |||
h1=`curl -s $addr/status | jq .result.sync_info.latest_block_height` | |||
h2=$h1 | |||
while [ "$h2" == "$h1" ]; do | |||
sleep 1 | |||
h2=`curl -s $addr/status | jq .result.sync_info.latest_block_height` | |||
done | |||
kill_procs | |||
sleep 2 | |||
echo "Passed Test: Persistence" |
@ -1,23 +0,0 @@ | |||
#! /bin/bash | |||
set -u | |||
# wait till node is up, send txs | |||
ADDR=$1 #="127.0.0.1:26657" | |||
curl -s $ADDR/status > /dev/null | |||
ERR=$? | |||
while [ "$ERR" != 0 ]; do | |||
sleep 1 | |||
curl -s $ADDR/status > /dev/null | |||
ERR=$? | |||
done | |||
# send a bunch of txs over a few blocks | |||
echo "Node is up, sending txs" | |||
for i in $(seq 1 5); do | |||
for _ in $(seq 1 100); do | |||
tx=$(head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"') | |||
curl -s "$ADDR/broadcast_tx_async?tx=0x$tx" &> /dev/null | |||
done | |||
echo "sent 100" | |||
sleep 1 | |||
done |