diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2013-12-20 17:12:39 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2013-12-20 17:12:39 +0100 |
commit | 5fe19d640e50373ddaa810e5bfff9764d9ac549e (patch) | |
tree | 72a53ad596e73a0113d2008eeacc1571fb4547f5 /qa/rpc-tests/wallet.sh | |
parent | 365350140a19459b3c763245339e062d1ae0d733 (diff) | |
download | bitcoin-5fe19d640e50373ddaa810e5bfff9764d9ac549e.tar.xz |
qt: make wallet test consistent
Add a function `WaitBlocks` to wait for blocks to propagate to all three
nodes, and use this instead of waiting a fixed time of one second.
Fixes #3445.
Diffstat (limited to 'qa/rpc-tests/wallet.sh')
-rwxr-xr-x | qa/rpc-tests/wallet.sh | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/qa/rpc-tests/wallet.sh b/qa/rpc-tests/wallet.sh index dd511782d0..118809a265 100755 --- a/qa/rpc-tests/wallet.sh +++ b/qa/rpc-tests/wallet.sh @@ -37,12 +37,27 @@ B3PID=$! trap "kill -9 $B1PID $B2PID $B3PID; rm -rf $D" EXIT +# Wait until all three nodes are at the same block number +function WaitBlocks { + while : + do + sleep 1 + BLOCKS1=$( GetBlocks $B1ARGS ) + BLOCKS2=$( GetBlocks $B2ARGS ) + BLOCKS3=$( GetBlocks $B3ARGS ) + if (( $BLOCKS1 == $BLOCKS2 && $BLOCKS2 == $BLOCKS3 )) + then + break + fi + done +} + # 1 block, 50 XBT each == 50 XBT $CLI $B1ARGS setgenerate true 1 -sleep 1 # sleep is necessary to let block broadcast +WaitBlocks # 101 blocks, 1 mature == 50 XBT $CLI $B2ARGS setgenerate true 101 -sleep 1 +WaitBlocks CheckBalance $B1ARGS 50 CheckBalance $B2ARGS 50 @@ -56,11 +71,11 @@ Send $B1ARGS $B3ARGS 10 # Have B1 mine a new block, and mature it # to recover transaction fees $CLI $B1ARGS setgenerate true 1 -sleep 1 +WaitBlocks # Have B2 mine 100 blocks so B1's block is mature: $CLI $B2ARGS setgenerate true 100 -sleep 1 +WaitBlocks # B1 should end up with 100 XBT in block rewards plus fees, # minus the 21 XBT sent to B3: @@ -77,7 +92,7 @@ RAWTXID2=$(SendRawTxn $B2ARGS $RAW2) # Have B2 mine a block to confirm transactions: $CLI $B2ARGS setgenerate true 1 -sleep 1 # allow time for block to be relayed +WaitBlocks # Check balances after confirmation CheckBalance $B1ARGS 0 |