Skip to content

Commit e3f5727

Browse files
committed
Merge pull request #5612
84d9199 [QA] fix zapwallettxes test (Jonas Schnelli)
2 parents 2eda47b + 84d9199 commit e3f5727

File tree

3 files changed

+84
-166
lines changed

3 files changed

+84
-166
lines changed

qa/pull-tester/rpc-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ testScripts=(
2626
'mempool_spendcoinbase.py'
2727
'mempool_coinbase_spends.py'
2828
'httpbasics.py'
29+
'zapwallettxes.py'
2930
# 'forknotify.py'
3031
);
3132
if [ "x${ENABLE_BITCOIND}${ENABLE_UTILS}${ENABLE_WALLET}" = "x111" ]; then
3233
for (( i = 0; i < ${#testScripts[@]}; i++ ))
3334
do
3435
if [ -z "$1" ] || [ "$1" == "${testScripts[$i]}" ] || [ "$1.py" == "${testScripts[$i]}" ]
3536
then
36-
echo -e "running testscript \033[1m${testScripts[$i]}...\033[0m"
37+
echo -e "Running testscript \033[1m${testScripts[$i]}...\033[0m"
3738
${BUILDDIR}/qa/rpc-tests/${testScripts[$i]} --srcdir "${BUILDDIR}/src"
3839
fi
3940
done

qa/rpc-tests/zapwallettxes.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env python2
2+
# Copyright (c) 2014 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+
from test_framework import BitcoinTestFramework
7+
from util import *
8+
9+
10+
class ZapWalletTXesTest (BitcoinTestFramework):
11+
12+
def setup_chain(self):
13+
print("Initializing test directory "+self.options.tmpdir)
14+
initialize_chain_clean(self.options.tmpdir, 3)
15+
16+
def setup_network(self, split=False):
17+
self.nodes = start_nodes(3, self.options.tmpdir)
18+
connect_nodes_bi(self.nodes,0,1)
19+
connect_nodes_bi(self.nodes,1,2)
20+
connect_nodes_bi(self.nodes,0,2)
21+
self.is_network_split=False
22+
self.sync_all()
23+
24+
def run_test (self):
25+
print "Mining blocks..."
26+
self.nodes[0].setgenerate(True, 1)
27+
self.sync_all()
28+
self.nodes[1].setgenerate(True, 101)
29+
self.sync_all()
30+
31+
assert_equal(self.nodes[0].getbalance(), 50)
32+
33+
txid0 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
34+
txid1 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
35+
self.sync_all()
36+
self.nodes[0].setgenerate(True, 1)
37+
self.sync_all()
38+
39+
txid2 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
40+
txid3 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
41+
42+
tx0 = self.nodes[0].gettransaction(txid0)
43+
assert_equal(tx0['txid'], txid0) #tx0 must be available (confirmed)
44+
45+
tx1 = self.nodes[0].gettransaction(txid1)
46+
assert_equal(tx1['txid'], txid1) #tx1 must be available (confirmed)
47+
48+
tx2 = self.nodes[0].gettransaction(txid2)
49+
assert_equal(tx2['txid'], txid2) #tx2 must be available (unconfirmed)
50+
51+
tx3 = self.nodes[0].gettransaction(txid3)
52+
assert_equal(tx3['txid'], txid3) #tx3 must be available (unconfirmed)
53+
54+
#restart bitcoind
55+
self.nodes[0].stop()
56+
bitcoind_processes[0].wait()
57+
self.nodes[0] = start_node(0,self.options.tmpdir)
58+
59+
tx3 = self.nodes[0].gettransaction(txid3)
60+
assert_equal(tx3['txid'], txid3) #tx must be available (unconfirmed)
61+
62+
self.nodes[0].stop()
63+
bitcoind_processes[0].wait()
64+
65+
#restart bitcoind with zapwallettxes
66+
self.nodes[0] = start_node(0,self.options.tmpdir, ["-zapwallettxes=1"])
67+
68+
aException = False
69+
try:
70+
tx3 = self.nodes[0].gettransaction(txid3)
71+
except JSONRPCException,e:
72+
print e
73+
aException = True
74+
75+
assert_equal(aException, True) #there must be a expection because the unconfirmed wallettx0 must be gone by now
76+
77+
tx0 = self.nodes[0].gettransaction(txid0)
78+
assert_equal(tx0['txid'], txid0) #tx0 (confirmed) must still be available because it was confirmed
79+
80+
81+
if __name__ == '__main__':
82+
ZapWalletTXesTest ().main ()

qa/rpc-tests/zapwallettxes.sh

Lines changed: 0 additions & 165 deletions
This file was deleted.

0 commit comments

Comments
 (0)