mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
integration tests
- regenerate chains consistently - separate peer (nodial, maxpeer 1, loglevel 0) and test_node - improve scripts, clean up code - include js file, define sleep function - add 02
This commit is contained in:
parent
251f37e589
commit
38edc428eb
11 changed files with 43 additions and 52 deletions
|
|
@ -2,8 +2,8 @@
|
|||
# bootstrap chains - used to regenerate tests/chains/*.chain
|
||||
|
||||
mkdir -p chains
|
||||
bash ./mine.sh 00 15
|
||||
bash ./mine.sh 00 10
|
||||
bash ./mine.sh 01 5 00
|
||||
bash ./mine.sh 02 5 00
|
||||
bash ./mine.sh 03 5 01
|
||||
bash ./mine.sh 04 5 01
|
||||
bash ./mine.sh 02 10 00
|
||||
bash ./mine.sh 03 5 02
|
||||
bash ./mine.sh 04 10 02
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,20 +1,20 @@
|
|||
#!/bin/bash
|
||||
# bash ./mine.sh node_id timeout(sec) [basechain]
|
||||
ETH="../ethereum -datadir tmp/nodes/$1 -seed=false -port '' -id test$1"
|
||||
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"
|
||||
echo "import chain '$CHAIN'"
|
||||
$ETH -mine $CHAINARG
|
||||
$MINE -mine $CHAINARG -loglevel 3 | grep 'importing'
|
||||
fi
|
||||
$ETH -mine &
|
||||
$MINE -mine -loglevel 0 &
|
||||
PID=$!
|
||||
sleep $2
|
||||
echo "killing $PID"
|
||||
kill $PID
|
||||
$ETH <(echo "eth.export(\"chains/$1.chain\")") &
|
||||
$MINE -loglevel 3 <(echo "eth.export(\"chains/$1.chain\")") > /tmp/eth.test/mine.tmp &
|
||||
PID=$!
|
||||
sleep 1
|
||||
echo "killing $PID"
|
||||
kill $PID
|
||||
cat /tmp/eth.test/mine.tmp | grep 'exporting'
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@
|
|||
# runs tests tests/testid0.sh tests/testid1.sh ...
|
||||
# without arguments, it runs all tests
|
||||
|
||||
. tests/common.sh
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
for file in tests/*.sh; do
|
||||
i=`basename $file .sh`
|
||||
TESTS="$TESTS $i"
|
||||
TESTS="$TESTS $NAME"
|
||||
done
|
||||
else
|
||||
TESTS=$@
|
||||
|
|
@ -16,19 +18,18 @@ 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
|
||||
for NAME in $TESTS; do
|
||||
PIDS=
|
||||
CHAIN="tests/$i.chain"
|
||||
JSFILE="$DIR/$i/js"
|
||||
CHAIN_TEST="$DIR/$i/chain"
|
||||
CHAIN="tests/$NAME.chain"
|
||||
JSFILE="$DIR/js/$NAME.js"
|
||||
CHAIN_TEST="$DIR/$NAME/chain"
|
||||
|
||||
# OUT="$DIR/out"
|
||||
echo "RUN: test $i"
|
||||
. tests/$i.sh
|
||||
echo "RUN: test $NAME"
|
||||
cat tests/common.js > $JSFILE
|
||||
. tests/$NAME.sh
|
||||
sleep $TIMEOUT
|
||||
echo "timeout after $TIMEOUT seconds: killing $PIDS"
|
||||
kill $PIDS
|
||||
|
|
@ -48,5 +49,3 @@ for i in $TESTS; do
|
|||
echo PASS
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,13 @@
|
|||
#!/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){}
|
||||
cat >> $JSFILE <<EOF
|
||||
eth.addPeer("localhost:30311");
|
||||
sleep(1000)
|
||||
eth.export("$CHAIN_TEST");
|
||||
EOF
|
||||
|
||||
peer 10 01 -loglevel 5
|
||||
sleep 1
|
||||
peer $ID "" -loglevel 5 $JSFILE
|
||||
peer 11 01
|
||||
test_node $NAME "" -loglevel 5 $JSFILE
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,18 @@
|
|||
#!/bin/bash
|
||||
. `dirname $BASH_SOURCE`/common.sh
|
||||
|
||||
TIMEOUT=20
|
||||
ID=01
|
||||
JSFILE="$DIR/js/$ID.js"
|
||||
TIMEOUT=5
|
||||
|
||||
echo $JSFILE
|
||||
cat > $JSFILE <<EOF
|
||||
cat >> $JSFILE <<EOF
|
||||
eth.addPeer("localhost:30311");
|
||||
var now = new Date().getTime();
|
||||
while(new Date().getTime() < now + 1000){}
|
||||
eth.addPeer("localhost:30310");
|
||||
var now = new Date().getTime();
|
||||
while(new Date().getTime() < now + 4000){}
|
||||
log("added peer localhost:30311");
|
||||
sleep(1000);
|
||||
log("added peer localhost:30312");
|
||||
eth.addPeer("localhost:30312");
|
||||
sleep(3000);
|
||||
eth.export("$CHAIN_TEST");
|
||||
EOF
|
||||
|
||||
peer 10 01 -loglevel 5
|
||||
peer 11 02 -loglevel 5
|
||||
sleep 1
|
||||
peer $ID "" -loglevel 5 $JSFILE
|
||||
peer 11 01
|
||||
peer 12 02
|
||||
test_node $NAME "" -loglevel 5 $JSFILE
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# launched by run.sh
|
||||
function peer {
|
||||
function test_node {
|
||||
rm -rf $DIR/$1
|
||||
ARGS="-datadir $DIR/$1 -debug debug -seed=false -shh=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
|
||||
$ETH $ARGS -loglevel 3 -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"
|
||||
}
|
||||
|
||||
function peer {
|
||||
test_node $@ -loglevel 0 -maxpeer 1 -dial=false
|
||||
}
|
||||
Loading…
Reference in a new issue