Browse Source

tests: broadcast_tx with tmsp; p2p

pull/259/head
Ethan Buchman 8 years ago
parent
commit
8987d29bee
29 changed files with 536 additions and 15 deletions
  1. +1
    -0
      consensus/state.go
  2. +7
    -0
      scripts/glide/parse.sh
  3. +0
    -0
      scripts/glide/status.sh
  4. +1
    -6
      scripts/glide/update.sh
  5. +11
    -0
      scripts/install_tmsp_apps.sh
  6. +16
    -0
      test/Dockerfile
  7. +0
    -0
      test/broadcast_tx/clean.sh
  8. +0
    -0
      test/broadcast_tx/counter_test.sh
  9. +10
    -1
      test/broadcast_tx/dummy_test.sh
  10. +31
    -6
      test/broadcast_tx/test.sh
  11. +4
    -0
      test/p2p/clean.sh
  12. +9
    -0
      test/p2p/data/app/init.sh
  13. +53
    -0
      test/p2p/data/chain_config.json
  14. +20
    -0
      test/p2p/data/core/init.sh
  15. +7
    -0
      test/p2p/data/data/init.sh
  16. +39
    -0
      test/p2p/data/mach1/core/genesis.json
  17. +14
    -0
      test/p2p/data/mach1/core/priv_validator.json
  18. +39
    -0
      test/p2p/data/mach2/core/genesis.json
  19. +14
    -0
      test/p2p/data/mach2/core/priv_validator.json
  20. +39
    -0
      test/p2p/data/mach3/core/genesis.json
  21. +14
    -0
      test/p2p/data/mach3/core/priv_validator.json
  22. +39
    -0
      test/p2p/data/mach4/core/genesis.json
  23. +14
    -0
      test/p2p/data/mach4/core/priv_validator.json
  24. +28
    -0
      test/p2p/local_testnet.sh
  25. +79
    -0
      test/p2p/run_test.sh
  26. +10
    -0
      test/p2p/test.sh
  27. +16
    -0
      test/p2p/test_client.sh
  28. +10
    -2
      test/run_test.sh
  29. +11
    -0
      test/test.sh

+ 1
- 0
consensus/state.go View File

@ -1236,6 +1236,7 @@ func (cs *ConsensusState) finalizeCommit(height int) {
}
// txs committed, bad ones removed from mepool; fire events
// NOTE: the block.AppHash wont reflect these txs until the next block
eventCache.Flush()
// Save to blockStore.


+ 7
- 0
scripts/glide/parse.sh View File

@ -0,0 +1,7 @@
#! /bin/bash
set -euo pipefail
GLIDE=$1
LIB=$2
cat $GLIDE | grep -A1 $LIB | grep -v $LIB | awk '{print $2}'

scripts/glide/glide_status.sh → scripts/glide/status.sh View File


scripts/glide/glide_update.sh → scripts/glide/update.sh View File


+ 11
- 0
scripts/install_tmsp_apps.sh View File

@ -0,0 +1,11 @@
#! /bin/bash
go get github.com/tendermint/tmsp/...
COMMIT=`bash scripts/glide/parse.sh $(pwd)/glide.lock tmsp`
cd $GOPATH/src/github.com/tendermint/tmsp
git checkout $COMMIT
go install ./cmd/...

+ 16
- 0
test/Dockerfile View File

@ -1,7 +1,23 @@
# Pull base image.
FROM golang:1.6
# Grab deps (jq, hexdump)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
jq bsdmainutils && \
rm -rf /var/lib/apt/lists/*
ENV TENDERMINT_ORG $GOPATH/src/github.com/tendermint/
RUN mkdir -p $TENDERMINT_ORG
COPY . $TENDERMINT_ORG/tendermint
WORKDIR $TENDERMINT_ORG/tendermint
RUN make get_vendor_deps
RUN go install ./cmd/tendermint
RUN bash scripts/install_tmsp_apps.sh
EXPOSE 46656
EXPOSE 46657

test/rpc/clean.sh → test/broadcast_tx/clean.sh View File


test/rpc/counter_test.sh → test/broadcast_tx/counter_test.sh View File


test/rpc/dummy_test.sh → test/broadcast_tx/dummy_test.sh View File


test/rpc/test.sh → test/broadcast_tx/test.sh View File


+ 4
- 0
test/p2p/clean.sh View File

@ -0,0 +1,4 @@
#! /bin/bash
docker rm -vf $(docker ps -aq)
docker network rm local_testnet

+ 9
- 0
test/p2p/data/app/init.sh View File

@ -0,0 +1,9 @@
#! /bin/bash
# This is a sample bash script for a TMSP application
cd app/
git clone https://github.com/tendermint/nomnomcoin.git
cd nomnomcoin
npm install .
node app.js --eyes="unix:///data/tendermint/data/data.sock"

+ 53
- 0
test/p2p/data/chain_config.json View File

@ -0,0 +1,53 @@
{
"id": "",
"val_set_id": "anon",
"validators": [
{
"validator": {
"id": "mach1",
"pub_key": [
1,
"BE8933DFF1600C026E34718F1785A4CDEAB90C35698B394E38B6947AE91DE116"
]
},
"p2p_addr": "",
"rpc_addr": ""
},
{
"validator": {
"id": "mach2",
"pub_key": [
1,
"6DC534465323126587D2A2A93B59D689B717073B1DE968A25A6EF13D595318AD"
]
},
"p2p_addr": "",
"rpc_addr": "",
"index": 1
},
{
"validator": {
"id": "mach3",
"pub_key": [
1,
"AE67AC697D135AA0B4601EA57EAAB3FEBF4BAA4F229C45A598C2985B12FCD1A1"
]
},
"p2p_addr": "",
"rpc_addr": "",
"index": 2
},
{
"validator": {
"id": "mach4",
"pub_key": [
1,
"9EBC8F58CED4B46DCD5AB8ABA591DD253CD7CB5037273FDA32BC0B6461C4EFD9"
]
},
"p2p_addr": "",
"rpc_addr": "",
"index": 3
}
]
}

+ 20
- 0
test/p2p/data/core/init.sh View File

@ -0,0 +1,20 @@
#! /bin/bash
# This is a sample bash script for tendermint core
# Edit this script before "mintnet start" to change
# the core blockchain engine.
TMREPO="github.com/tendermint/tendermint"
BRANCH="master"
go get -d $TMREPO/cmd/tendermint
### DEPENDENCIES (example)
# cd $GOPATH/src/github.com/tendermint/tmsp
# git fetch origin $BRANCH
# git checkout $BRANCH
### DEPENDENCIES END
cd $GOPATH/src/$TMREPO
git fetch origin $BRANCH
git checkout $BRANCH
make install
tendermint node --seeds="$TMSEEDS" --moniker="$TMNAME" --proxy_app="$PROXYAPP"

+ 7
- 0
test/p2p/data/data/init.sh View File

@ -0,0 +1,7 @@
#! /bin/bash
# This is a sample bash script for MerkleEyes.
# NOTE: mintnet expects data.sock to be created
go get github.com/tendermint/merkleeyes/cmd/merkleeyes
merkleeyes server --address="unix:///data/tendermint/data/data.sock"

+ 39
- 0
test/p2p/data/mach1/core/genesis.json View File

@ -0,0 +1,39 @@
{
"app_hash": "",
"chain_id": "chain-9ujDWI",
"genesis_time": "2016-06-24T20:01:19.322Z",
"validators": [
{
"amount": 1,
"name": "mach1",
"pub_key": [
1,
"BE8933DFF1600C026E34718F1785A4CDEAB90C35698B394E38B6947AE91DE116"
]
},
{
"amount": 1,
"name": "mach2",
"pub_key": [
1,
"6DC534465323126587D2A2A93B59D689B717073B1DE968A25A6EF13D595318AD"
]
},
{
"amount": 1,
"name": "mach3",
"pub_key": [
1,
"AE67AC697D135AA0B4601EA57EAAB3FEBF4BAA4F229C45A598C2985B12FCD1A1"
]
},
{
"amount": 1,
"name": "mach4",
"pub_key": [
1,
"9EBC8F58CED4B46DCD5AB8ABA591DD253CD7CB5037273FDA32BC0B6461C4EFD9"
]
}
]
}

+ 14
- 0
test/p2p/data/mach1/core/priv_validator.json View File

@ -0,0 +1,14 @@
{
"address": "0E6925C3EE4C599DFF1536A5071AF4A26DF33635",
"last_height": 0,
"last_round": 0,
"last_step": 0,
"priv_key": [
1,
"547AA07C7A8CE16C5CB2A40C6C26D15B0A32960410A9F1EA6E50B636F1AB389ABE8933DFF1600C026E34718F1785A4CDEAB90C35698B394E38B6947AE91DE116"
],
"pub_key": [
1,
"BE8933DFF1600C026E34718F1785A4CDEAB90C35698B394E38B6947AE91DE116"
]
}

+ 39
- 0
test/p2p/data/mach2/core/genesis.json View File

@ -0,0 +1,39 @@
{
"app_hash": "",
"chain_id": "chain-9ujDWI",
"genesis_time": "2016-06-24T20:01:19.322Z",
"validators": [
{
"amount": 1,
"name": "mach1",
"pub_key": [
1,
"BE8933DFF1600C026E34718F1785A4CDEAB90C35698B394E38B6947AE91DE116"
]
},
{
"amount": 1,
"name": "mach2",
"pub_key": [
1,
"6DC534465323126587D2A2A93B59D689B717073B1DE968A25A6EF13D595318AD"
]
},
{
"amount": 1,
"name": "mach3",
"pub_key": [
1,
"AE67AC697D135AA0B4601EA57EAAB3FEBF4BAA4F229C45A598C2985B12FCD1A1"
]
},
{
"amount": 1,
"name": "mach4",
"pub_key": [
1,
"9EBC8F58CED4B46DCD5AB8ABA591DD253CD7CB5037273FDA32BC0B6461C4EFD9"
]
}
]
}

+ 14
- 0
test/p2p/data/mach2/core/priv_validator.json View File

@ -0,0 +1,14 @@
{
"address": "99DBBD2AFC28FB5BAC5574AFAF0D9C806CED3B55",
"last_height": 0,
"last_round": 0,
"last_step": 0,
"priv_key": [
1,
"D047889E60502FC3129D0AB7F334B1838ED9ED1ECD99CBB96B71AD5ABF5A81436DC534465323126587D2A2A93B59D689B717073B1DE968A25A6EF13D595318AD"
],
"pub_key": [
1,
"6DC534465323126587D2A2A93B59D689B717073B1DE968A25A6EF13D595318AD"
]
}

+ 39
- 0
test/p2p/data/mach3/core/genesis.json View File

@ -0,0 +1,39 @@
{
"app_hash": "",
"chain_id": "chain-9ujDWI",
"genesis_time": "2016-06-24T20:01:19.322Z",
"validators": [
{
"amount": 1,
"name": "mach1",
"pub_key": [
1,
"BE8933DFF1600C026E34718F1785A4CDEAB90C35698B394E38B6947AE91DE116"
]
},
{
"amount": 1,
"name": "mach2",
"pub_key": [
1,
"6DC534465323126587D2A2A93B59D689B717073B1DE968A25A6EF13D595318AD"
]
},
{
"amount": 1,
"name": "mach3",
"pub_key": [
1,
"AE67AC697D135AA0B4601EA57EAAB3FEBF4BAA4F229C45A598C2985B12FCD1A1"
]
},
{
"amount": 1,
"name": "mach4",
"pub_key": [
1,
"9EBC8F58CED4B46DCD5AB8ABA591DD253CD7CB5037273FDA32BC0B6461C4EFD9"
]
}
]
}

+ 14
- 0
test/p2p/data/mach3/core/priv_validator.json View File

@ -0,0 +1,14 @@
{
"address": "4C5F061DAC28660853904A66705B12CA2B317572",
"last_height": 0,
"last_round": 0,
"last_step": 0,
"priv_key": [
1,
"C1A4E47F349FC5F556F4A9A27BA776B94424C312BAA6CF6EE44B867348D7C3F2AE67AC697D135AA0B4601EA57EAAB3FEBF4BAA4F229C45A598C2985B12FCD1A1"
],
"pub_key": [
1,
"AE67AC697D135AA0B4601EA57EAAB3FEBF4BAA4F229C45A598C2985B12FCD1A1"
]
}

+ 39
- 0
test/p2p/data/mach4/core/genesis.json View File

@ -0,0 +1,39 @@
{
"app_hash": "",
"chain_id": "chain-9ujDWI",
"genesis_time": "2016-06-24T20:01:19.322Z",
"validators": [
{
"amount": 1,
"name": "mach1",
"pub_key": [
1,
"BE8933DFF1600C026E34718F1785A4CDEAB90C35698B394E38B6947AE91DE116"
]
},
{
"amount": 1,
"name": "mach2",
"pub_key": [
1,
"6DC534465323126587D2A2A93B59D689B717073B1DE968A25A6EF13D595318AD"
]
},
{
"amount": 1,
"name": "mach3",
"pub_key": [
1,
"AE67AC697D135AA0B4601EA57EAAB3FEBF4BAA4F229C45A598C2985B12FCD1A1"
]
},
{
"amount": 1,
"name": "mach4",
"pub_key": [
1,
"9EBC8F58CED4B46DCD5AB8ABA591DD253CD7CB5037273FDA32BC0B6461C4EFD9"
]
}
]
}

+ 14
- 0
test/p2p/data/mach4/core/priv_validator.json View File

@ -0,0 +1,14 @@
{
"address": "86F6DA4B34F16D743D2D992B5ACB12F5E724CC2D",
"last_height": 0,
"last_round": 0,
"last_step": 0,
"priv_key": [
1,
"C4CC3ED28F020C2DBDA98BCDBF08C3CED370470E74F25E938D5D295E8E3D2B0C9EBC8F58CED4B46DCD5AB8ABA591DD253CD7CB5037273FDA32BC0B6461C4EFD9"
],
"pub_key": [
1,
"9EBC8F58CED4B46DCD5AB8ABA591DD253CD7CB5037273FDA32BC0B6461C4EFD9"
]
}

+ 28
- 0
test/p2p/local_testnet.sh View File

@ -0,0 +1,28 @@
#! /bin/bash
set -eu
DOCKER_IMAGE=$1
NETWORK_NAME=$2
cd $GOPATH/src/github.com/tendermint/tendermint
# create docker network
docker network create --driver bridge --subnet 172.57.0.0/16 $NETWORK_NAME
N=4
seeds="172.57.0.101:46656"
for i in `seq 2 $N`; do
seeds="$seeds,172.57.0.$((100+$i)):46656"
done
echo "Seeds: $seeds"
for i in `seq 1 $N`; do
# start tendermint container
docker run -d \
--net=$NETWORK_NAME \
--ip=172.57.0.$((100+$i)) \
--name local_testnet_$i \
--entrypoint tendermint \
-e TMROOT=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$i/core \
$DOCKER_IMAGE node --seeds $seeds --proxy_app=dummy
done

+ 79
- 0
test/p2p/run_test.sh View File

@ -0,0 +1,79 @@
#! /bin/bash
# wait for everyone to come online
echo "Waiting for nodes to come online"
for i in `seq 1 4`; do
addr="172.57.0.$((100+$i)):46657"
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
echo ""
# run the test on each of them
for i in `seq 1 4`; do
addr="172.57.0.$((100+$i)):46657"
# - assert everyone has 3 other peers
N_PEERS=`curl -s $addr/net_info | jq '.result[1].peers | length'`
while [ "$N_PEERS" != 3 ]; do
echo "Waiting for node $i to connect to all peers ..."
sleep 1
N_PEERS=`curl -s $addr/net_info | jq '.result[1].peers | length'`
done
# - assert block height is greater than 1
BLOCK_HEIGHT=`curl -s $addr/status | jq .result[1].latest_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[1].latest_block_height`
done
echo "Node $i is connected to all peers and at block $BLOCK_HEIGHT"
# current state
HASH1=`curl -s $addr/status | jq .result[1].latest_app_hash`
# - send a tx
TX=\"aadeadbeefbeefbeef0$i\"
echo "Broadcast Tx $TX"
curl -s $addr/broadcast_tx_commit?tx=$TX
echo ""
# we need to wait another block to get the new app_hash
h1=`curl -s $addr/status | jq .result[1].latest_block_height`
h2=$h1
while [ "$h2" == "$h1" ]; do
sleep 1
h2=`curl -s $addr/status | jq .result[1].latest_block_height`
done
# check that hash was updated
HASH2=`curl -s $addr/status | jq .result[1].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 4`; do
if [[ "$i" != "$j" ]]; then
HASH3=`curl -s 172.57.0.$((100+$j)):46657/status | jq .result[1].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"

+ 10
- 0
test/p2p/test.sh View File

@ -0,0 +1,10 @@
#! /bin/bash
DOCKER_IMAGE=$1
NETWORK_NAME=local_testnet
# start the testnet on a local network
bash test/p2p/local_testnet.sh $DOCKER_IMAGE $NETWORK_NAME
# run the test
bash test/p2p/test_client.sh $DOCKER_IMAGE $NETWORK_NAME test/p2p/run_test.sh

+ 16
- 0
test/p2p/test_client.sh View File

@ -0,0 +1,16 @@
#! /bin/bash
set -eu
DOCKER_IMAGE=$1
NETWORK_NAME=$2
CMD=$3
# run the test container on the local network
docker run -t \
--rm \
-v $GOPATH/src/github.com/tendermint/tendermint/test/p2p/:/go/src/github.com/tendermint/tendermint/test/p2p \
--net=$NETWORK_NAME \
--ip=172.57.0.99 \
--name test_container \
--entrypoint bash \
$DOCKER_IMAGE $CMD

+ 10
- 2
test/run_test.sh View File

@ -1,14 +1,22 @@
#! /bin/bash
set -e
echo `pwd`
BRANCH=`git rev-parse --abbrev-ref HEAD`
echo "Current branch: $BRANCH"
make get_vendor_deps
# go test --race github.com/tendermint/tendermint/...
make test_race
# run the broadcast_tx tests
bash test/broadcast_tx/test.sh
if [[ "$BRANCH" == "master" || "$BRANCH" == "staging" ]]; then
echo ""
echo "* branch $BRANCH; testing libs"
# checkout every github.com/tendermint dir and run its tests
bash test/test_libs.sh
# TODO: mintnet/netmon
fi

+ 11
- 0
test/test.sh View File

@ -8,5 +8,16 @@
# If we pushed to STAGING or MASTER,
# it will also run the tests for all dependencies
echo ""
echo "* building docker file"
docker build -t tester -f ./test/Dockerfile .
echo ""
echo "* running go tests and broadcast tests"
docker run -t tester bash test/run_test.sh
# test basic network connectivity
# by starting a local testnet and checking peers connect and make blocks
echo ""
echo "* running basic peer tests"
bash test/p2p/test.sh tester

Loading…
Cancel
Save