aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/wallet.sh
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2014-02-15 16:38:28 -0500
committerGavin Andresen <gavinandresen@gmail.com>2014-02-26 11:53:51 -0500
commit93a18a3650292afbb441a47d1fa1b94aeb0164e3 (patch)
tree36382e2077820d469fd1257ee35375a86206a878 /qa/rpc-tests/wallet.sh
parenta16ad1c0f465935d437bd9ae9875b28be49ec65b (diff)
Remove CWalletTx::vfSpent
Use the spent outpoint multimap to figure out which wallet transaction outputs are unspent, instead of a vfSpent array that is saved to disk.
Diffstat (limited to 'qa/rpc-tests/wallet.sh')
-rwxr-xr-xqa/rpc-tests/wallet.sh39
1 files changed, 20 insertions, 19 deletions
diff --git a/qa/rpc-tests/wallet.sh b/qa/rpc-tests/wallet.sh
index 8d5a6cdc78..2940566af9 100755
--- a/qa/rpc-tests/wallet.sh
+++ b/qa/rpc-tests/wallet.sh
@@ -8,6 +8,8 @@ if [ $# -lt 1 ]; then
exit 1
fi
+set -f
+
BITCOIND=${1}/bitcoind
CLI=${1}/bitcoin-cli
@@ -19,40 +21,40 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
D=$(mktemp -d test.XXXXX)
D1=${D}/node1
-CreateDataDir $D1 port=11000 rpcport=11001
+CreateDataDir "$D1" port=11000 rpcport=11001
B1ARGS="-datadir=$D1"
$BITCOIND $B1ARGS &
B1PID=$!
D2=${D}/node2
-CreateDataDir $D2 port=11010 rpcport=11011 connect=127.0.0.1:11000
+CreateDataDir "$D2" port=11010 rpcport=11011 connect=127.0.0.1:11000
B2ARGS="-datadir=$D2"
$BITCOIND $B2ARGS &
B2PID=$!
D3=${D}/node3
-CreateDataDir $D3 port=11020 rpcport=11021 connect=127.0.0.1:11000
+CreateDataDir "$D3" port=11020 rpcport=11021 connect=127.0.0.1:11000
B3ARGS="-datadir=$D3"
$BITCOIND $BITCOINDARGS $B3ARGS &
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 ))
+ declare -i BLOCKS1=$( GetBlocks $B1ARGS )
+ declare -i BLOCKS2=$( GetBlocks $B2ARGS )
+ declare -i BLOCKS3=$( GetBlocks $B3ARGS )
+ if (( BLOCKS1 == BLOCKS2 && BLOCKS2 == BLOCKS3 ))
then
break
fi
done
}
+echo "Generating test blockchain..."
+
# 1 block, 50 XBT each == 50 XBT
$CLI $B1ARGS setgenerate true 1
WaitBlocks
@@ -60,8 +62,8 @@ WaitBlocks
$CLI $B2ARGS setgenerate true 101
WaitBlocks
-CheckBalance $B1ARGS 50
-CheckBalance $B2ARGS 50
+CheckBalance "$B1ARGS" 50
+CheckBalance "$B2ARGS" 50
# Send 21 XBT from 1 to 3. Second
# transaction will be child of first, and
@@ -80,25 +82,25 @@ WaitBlocks
# B1 should end up with 100 XBT in block rewards plus fees,
# minus the 21 XBT sent to B3:
-CheckBalance $B1ARGS "100-21"
-CheckBalance $B3ARGS "21"
+CheckBalance "$B1ARGS" "100-21"
+CheckBalance "$B3ARGS" "21"
# B1 should have two unspent outputs; create a couple
# of raw transactions to send them to B3, submit them through
# B2, and make sure both B1 and B3 pick them up properly:
RAW1=$(CreateTxn1 $B1ARGS 1 $(Address $B3ARGS "from1" ) )
RAW2=$(CreateTxn1 $B1ARGS 2 $(Address $B3ARGS "from1" ) )
-RAWTXID1=$(SendRawTxn $B2ARGS $RAW1)
-RAWTXID2=$(SendRawTxn $B2ARGS $RAW2)
+RAWTXID1=$(SendRawTxn "$B2ARGS" $RAW1)
+RAWTXID2=$(SendRawTxn "$B2ARGS" $RAW2)
# Have B2 mine a block to confirm transactions:
$CLI $B2ARGS setgenerate true 1
WaitBlocks
# Check balances after confirmation
-CheckBalance $B1ARGS 0
-CheckBalance $B3ARGS 100
-CheckBalance $B3ARGS "100-21" "from1"
+CheckBalance "$B1ARGS" 0
+CheckBalance "$B3ARGS" 100
+CheckBalance "$B3ARGS" "100-21" "from1"
$CLI $B3ARGS stop > /dev/null 2>&1
wait $B3PID
@@ -108,6 +110,5 @@ $CLI $B1ARGS stop > /dev/null 2>&1
wait $B1PID
echo "Tests successful, cleaning up"
-trap "" EXIT
rm -rf $D
exit 0