mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
automated integration tests for eth protocol and blockpool
This commit is contained in:
parent
b356a9fb64
commit
f91a39e43c
12 changed files with 141 additions and 0 deletions
9
eth/test/bootstrap.sh
Normal file
9
eth/test/bootstrap.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# bootstrap chains - used to regenerate tests/chains/*.chain
|
||||||
|
|
||||||
|
mkdir -p chains
|
||||||
|
bash ./mine.sh 00 15
|
||||||
|
bash ./mine.sh 01 5 00
|
||||||
|
bash ./mine.sh 02 5 00
|
||||||
|
bash ./mine.sh 03 5 01
|
||||||
|
bash ./mine.sh 04 5 01
|
||||||
BIN
eth/test/chains/00.chain
Executable file
BIN
eth/test/chains/00.chain
Executable file
Binary file not shown.
BIN
eth/test/chains/01.chain
Executable file
BIN
eth/test/chains/01.chain
Executable file
Binary file not shown.
BIN
eth/test/chains/02.chain
Executable file
BIN
eth/test/chains/02.chain
Executable file
Binary file not shown.
BIN
eth/test/chains/03.chain
Executable file
BIN
eth/test/chains/03.chain
Executable file
Binary file not shown.
BIN
eth/test/chains/04.chain
Executable file
BIN
eth/test/chains/04.chain
Executable file
Binary file not shown.
20
eth/test/mine.sh
Normal file
20
eth/test/mine.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# bash ./mine.sh node_id timeout(sec) [basechain]
|
||||||
|
ETH="../ethereum -datadir tmp/nodes/$1 -seed=false -port '' -id test$1"
|
||||||
|
rm -rf tmp/nodes/$1
|
||||||
|
if [[ "" != "$3" ]]; then
|
||||||
|
CHAIN="chains/$3.chain"
|
||||||
|
CHAINARG="-chain $CHAIN"
|
||||||
|
echo "import chain '$CHAIN'"
|
||||||
|
$ETH -mine $CHAINARG
|
||||||
|
fi
|
||||||
|
$ETH -mine &
|
||||||
|
PID=$!
|
||||||
|
sleep $2
|
||||||
|
echo "killing $PID"
|
||||||
|
kill $PID
|
||||||
|
$ETH <(echo "eth.export(\"chains/$1.chain\")") &
|
||||||
|
PID=$!
|
||||||
|
sleep 1
|
||||||
|
echo "killing $PID"
|
||||||
|
kill $PID
|
||||||
52
eth/test/run.sh
Normal file
52
eth/test/run.sh
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# bash run.sh (testid0 testid1 ...)
|
||||||
|
# runs tests tests/testid0.sh tests/testid1.sh ...
|
||||||
|
# without arguments, it runs all tests
|
||||||
|
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
for file in tests/*.sh; do
|
||||||
|
i=`basename $file .sh`
|
||||||
|
TESTS="$TESTS $i"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
TESTS=$@
|
||||||
|
fi
|
||||||
|
|
||||||
|
ETH=../../ethereum
|
||||||
|
DIR="/tmp/eth.test/nodes"
|
||||||
|
TIMEOUT=10
|
||||||
|
|
||||||
|
mkdir -p $DIR
|
||||||
|
mkdir -p $DIR/js
|
||||||
|
|
||||||
|
echo "running tests $TESTS"
|
||||||
|
for i in $TESTS; do
|
||||||
|
PIDS=
|
||||||
|
CHAIN="tests/$i.chain"
|
||||||
|
JSFILE="$DIR/$i/js"
|
||||||
|
CHAIN_TEST="$DIR/$i/chain"
|
||||||
|
|
||||||
|
# OUT="$DIR/out"
|
||||||
|
echo "RUN: test $i"
|
||||||
|
. tests/$i.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
|
||||||
|
|
||||||
|
|
||||||
1
eth/test/tests/00.chain
Symbolic link
1
eth/test/tests/00.chain
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../chains/01.chain
|
||||||
19
eth/test/tests/00.sh
Normal file
19
eth/test/tests/00.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
. `dirname $BASH_SOURCE`/common.sh
|
||||||
|
|
||||||
|
TIMEOUT=4
|
||||||
|
ID=00
|
||||||
|
JSFILE="$DIR/js/$ID.js"
|
||||||
|
|
||||||
|
echo $JSFILE
|
||||||
|
cat > $JSFILE <<EOF
|
||||||
|
eth.addPeer("localhost:30310");
|
||||||
|
var now = new Date().getTime();
|
||||||
|
while(new Date().getTime() < now + 2000){}
|
||||||
|
eth.export("$CHAIN_TEST");
|
||||||
|
EOF
|
||||||
|
|
||||||
|
peer 10 01 -loglevel 5
|
||||||
|
sleep 1
|
||||||
|
peer $ID "" -loglevel 5 $JSFILE
|
||||||
|
|
||||||
23
eth/test/tests/01.sh
Normal file
23
eth/test/tests/01.sh
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
. `dirname $BASH_SOURCE`/common.sh
|
||||||
|
|
||||||
|
TIMEOUT=10
|
||||||
|
ID=01
|
||||||
|
JSFILE="$DIR/js/$ID.js"
|
||||||
|
|
||||||
|
echo $JSFILE
|
||||||
|
cat > $JSFILE <<EOF
|
||||||
|
eth.addPeer("localhost:30311");
|
||||||
|
var now = new Date().getTime();
|
||||||
|
while(new Date().getTime() < now + 100){}
|
||||||
|
eth.addPeer("localhost:30310");
|
||||||
|
var now = new Date().getTime();
|
||||||
|
while(new Date().getTime() < now + 2000){}
|
||||||
|
eth.export("$CHAIN_TEST");
|
||||||
|
EOF
|
||||||
|
|
||||||
|
peer 10 01 -loglevel 5
|
||||||
|
peer 11 02 -loglevel 5
|
||||||
|
sleep 1
|
||||||
|
peer $ID "" -loglevel 5 $JSFILE
|
||||||
|
|
||||||
17
eth/test/tests/common.sh
Normal file
17
eth/test/tests/common.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# launched by run.sh
|
||||||
|
function peer {
|
||||||
|
rm -rf $DIR/$1
|
||||||
|
ARGS="-datadir $DIR/$1 -debug debug -seed=false -id test$1"
|
||||||
|
if [ "" != "$2" ]; then
|
||||||
|
chain="chains/$2.chain"
|
||||||
|
echo "import chain $chain"
|
||||||
|
$ETH $ARGS -loglevel 5 -chain $chain
|
||||||
|
# $ETH $ARGS -loglevel 5 -chain $chain | grep CLI |grep import
|
||||||
|
fi
|
||||||
|
echo "starting test node $1 with extra args ${@:3}"
|
||||||
|
$ETH $ARGS -port 303$1 ${@:3} &
|
||||||
|
PID=$!
|
||||||
|
PIDS="$PIDS $PID"
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue