From 6abf8ef78f1474fdeb7a6a6ce084bf994cc055f2 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 5 Jan 2015 17:10:42 +0100 Subject: Merge --- eth/test/README.md | 27 ++++++++++++++++++++++++ eth/test/bootstrap.sh | 9 ++++++++ eth/test/chains/00.chain | Bin 0 -> 9726 bytes eth/test/chains/01.chain | Bin 0 -> 13881 bytes eth/test/chains/02.chain | Bin 0 -> 14989 bytes eth/test/chains/03.chain | Bin 0 -> 18590 bytes eth/test/chains/04.chain | Bin 0 -> 20529 bytes eth/test/mine.sh | 20 ++++++++++++++++++ eth/test/run.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++ eth/test/tests/00.chain | 1 + eth/test/tests/00.sh | 13 ++++++++++++ eth/test/tests/01.chain | 1 + eth/test/tests/01.sh | 18 ++++++++++++++++ eth/test/tests/02.chain | 1 + eth/test/tests/02.sh | 19 +++++++++++++++++ eth/test/tests/03.chain | 1 + eth/test/tests/03.sh | 14 +++++++++++++ eth/test/tests/04.sh | 17 +++++++++++++++ eth/test/tests/05.sh | 20 ++++++++++++++++++ eth/test/tests/common.js | 9 ++++++++ eth/test/tests/common.sh | 20 ++++++++++++++++++ 21 files changed, 243 insertions(+) create mode 100644 eth/test/README.md create mode 100644 eth/test/bootstrap.sh create mode 100755 eth/test/chains/00.chain create mode 100755 eth/test/chains/01.chain create mode 100755 eth/test/chains/02.chain create mode 100755 eth/test/chains/03.chain create mode 100755 eth/test/chains/04.chain create mode 100644 eth/test/mine.sh create mode 100644 eth/test/run.sh create mode 120000 eth/test/tests/00.chain create mode 100644 eth/test/tests/00.sh create mode 120000 eth/test/tests/01.chain create mode 100644 eth/test/tests/01.sh create mode 120000 eth/test/tests/02.chain create mode 100644 eth/test/tests/02.sh create mode 120000 eth/test/tests/03.chain create mode 100644 eth/test/tests/03.sh create mode 100644 eth/test/tests/04.sh create mode 100644 eth/test/tests/05.sh create mode 100644 eth/test/tests/common.js create mode 100644 eth/test/tests/common.sh (limited to 'eth/test') diff --git a/eth/test/README.md b/eth/test/README.md new file mode 100644 index 000000000..65728efa5 --- /dev/null +++ b/eth/test/README.md @@ -0,0 +1,27 @@ += Integration tests for eth protocol and blockpool + +This is a simple suite of tests to fire up a local test node with peers to test blockchain synchronisation and download. +The scripts call ethereum (assumed to be compiled in go-ethereum root). + +To run a test: + + . run.sh 00 02 + +Without arguments, all tests are run. + +Peers are launched with preloaded imported chains. In order to prevent them from synchronizing with each other they are set with `-dial=false` and `-maxpeer 1` options. They log into `/tmp/eth.test/nodes/XX` where XX is the last two digits of their port. + +Chains to import can be bootstrapped by letting nodes mine for some time. This is done with + + . bootstrap.sh + +Only the relative timing and forks matter so they should work if the bootstrap script is rerun. +The reference blockchain of tests are soft links to these import chains and check at the end of a test run. + +Connecting to peers and exporting blockchain is scripted with JS files executed by the JSRE, see `tests/XX.sh`. + +Each test is set with a timeout. This may vary on different computers so adjust sensibly. +If you kill a test before it completes, do not forget to kill all the background processes, since they will impact the result. Use: + + killall ethereum + diff --git a/eth/test/bootstrap.sh b/eth/test/bootstrap.sh new file mode 100644 index 000000000..3da038be8 --- /dev/null +++ b/eth/test/bootstrap.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# bootstrap chains - used to regenerate tests/chains/*.chain + +mkdir -p chains +bash ./mine.sh 00 10 +bash ./mine.sh 01 5 00 +bash ./mine.sh 02 10 00 +bash ./mine.sh 03 5 02 +bash ./mine.sh 04 10 02 \ No newline at end of file diff --git a/eth/test/chains/00.chain b/eth/test/chains/00.chain new file mode 100755 index 000000000..ad3c05b24 Binary files /dev/null and b/eth/test/chains/00.chain differ diff --git a/eth/test/chains/01.chain b/eth/test/chains/01.chain new file mode 100755 index 000000000..56c9aef65 Binary files /dev/null and b/eth/test/chains/01.chain differ diff --git a/eth/test/chains/02.chain b/eth/test/chains/02.chain new file mode 100755 index 000000000..440c92d65 Binary files /dev/null and b/eth/test/chains/02.chain differ diff --git a/eth/test/chains/03.chain b/eth/test/chains/03.chain new file mode 100755 index 000000000..1cc7570ab Binary files /dev/null and b/eth/test/chains/03.chain differ diff --git a/eth/test/chains/04.chain b/eth/test/chains/04.chain new file mode 100755 index 000000000..d4e5b1aa8 Binary files /dev/null and b/eth/test/chains/04.chain differ diff --git a/eth/test/mine.sh b/eth/test/mine.sh new file mode 100644 index 000000000..0d95db1e4 --- /dev/null +++ b/eth/test/mine.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# bash ./mine.sh node_id timeout(sec) [basechain] +ETH=../../ethereum +MINE="$ETH -datadir tmp/nodes/$1 -seed=false -port '' -shh=false -id test$1" +rm -rf tmp/nodes/$1 +echo "Creating chain $1..." +if [[ "" != "$3" ]]; then + CHAIN="chains/$3.chain" + CHAINARG="-chain $CHAIN" + $MINE -mine $CHAINARG -loglevel 3 | grep 'importing' +fi +$MINE -mine -loglevel 0 & +PID=$! +sleep $2 +kill $PID +$MINE -loglevel 3 <(echo "eth.export(\"chains/$1.chain\")") > /tmp/eth.test/mine.tmp & +PID=$! +sleep 1 +kill $PID +cat /tmp/eth.test/mine.tmp | grep 'exporting' diff --git a/eth/test/run.sh b/eth/test/run.sh new file mode 100644 index 000000000..5229af035 --- /dev/null +++ b/eth/test/run.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# bash run.sh (testid0 testid1 ...) +# runs tests tests/testid0.sh tests/testid1.sh ... +# without arguments, it runs all tests + +. tests/common.sh + +TESTS= + +if [ "$#" -eq 0 ]; then + for NAME in tests/??.sh; do + i=`basename $NAME .sh` + TESTS="$TESTS $i" + done +else + TESTS=$@ +fi + +ETH=../../ethereum +DIR="/tmp/eth.test/nodes" +TIMEOUT=10 + +mkdir -p $DIR/js + +echo "running tests $TESTS" +for NAME in $TESTS; do + PIDS= + CHAIN="tests/$NAME.chain" + JSFILE="$DIR/js/$NAME.js" + CHAIN_TEST="$DIR/$NAME/chain" + + echo "RUN: test $NAME" + cat tests/common.js > $JSFILE + . tests/$NAME.sh + sleep $TIMEOUT + echo "timeout after $TIMEOUT seconds: killing $PIDS" + kill $PIDS + if [ -r "$CHAIN" ]; then + if diff $CHAIN $CHAIN_TEST >/dev/null ; then + echo "chain ok: $CHAIN=$CHAIN_TEST" + else + echo "FAIL: chains differ: expected $CHAIN ; got $CHAIN_TEST" + continue + fi + fi + ERRORS=$DIR/errors + if [ -r "$ERRORS" ]; then + echo "FAIL: " + cat $ERRORS + else + echo PASS + fi +done \ No newline at end of file diff --git a/eth/test/tests/00.chain b/eth/test/tests/00.chain new file mode 120000 index 000000000..9655cb3df --- /dev/null +++ b/eth/test/tests/00.chain @@ -0,0 +1 @@ +../chains/01.chain \ No newline at end of file diff --git a/eth/test/tests/00.sh b/eth/test/tests/00.sh new file mode 100644 index 000000000..9c5077164 --- /dev/null +++ b/eth/test/tests/00.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +TIMEOUT=4 + +cat >> $JSFILE <> $JSFILE <> $JSFILE <> $JSFILE <> $JSFILE <> $JSFILE <