Check gpg version before setting --weak-digest
[bitcoinplatinum.git] / qa / rpc-tests / zapwallettxes.py
blob9597d05f3a5e37ad0f1a51e96d6e1b94b95f1f8f
1 #!/usr/bin/env python3
2 # Copyright (c) 2014-2016 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 """Test the zapwallettxes functionality.
7 - start three bitcoind nodes
8 - create four transactions on node 0 - two are confirmed and two are
9 unconfirmed.
10 - restart node 1 and verify that both the confirmed and the unconfirmed
11 transactions are still available.
12 - restart node 0 and verify that the confirmed transactions are still
13 available, but that the unconfirmed transaction has been zapped.
14 """
15 from test_framework.test_framework import BitcoinTestFramework
16 from test_framework.util import *
19 class ZapWalletTXesTest (BitcoinTestFramework):
21 def __init__(self):
22 super().__init__()
23 self.setup_clean_chain = True
24 self.num_nodes = 3
26 def setup_network(self, split=False):
27 self.nodes = start_nodes(self.num_nodes, self.options.tmpdir)
28 connect_nodes_bi(self.nodes,0,1)
29 connect_nodes_bi(self.nodes,1,2)
30 connect_nodes_bi(self.nodes,0,2)
31 self.is_network_split=False
32 self.sync_all()
34 def run_test (self):
35 print("Mining blocks...")
36 self.nodes[0].generate(1)
37 self.sync_all()
38 self.nodes[1].generate(101)
39 self.sync_all()
41 assert_equal(self.nodes[0].getbalance(), 50)
43 txid0 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
44 txid1 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
45 self.sync_all()
46 self.nodes[0].generate(1)
47 self.sync_all()
49 txid2 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
50 txid3 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
52 tx0 = self.nodes[0].gettransaction(txid0)
53 assert_equal(tx0['txid'], txid0) #tx0 must be available (confirmed)
55 tx1 = self.nodes[0].gettransaction(txid1)
56 assert_equal(tx1['txid'], txid1) #tx1 must be available (confirmed)
58 tx2 = self.nodes[0].gettransaction(txid2)
59 assert_equal(tx2['txid'], txid2) #tx2 must be available (unconfirmed)
61 tx3 = self.nodes[0].gettransaction(txid3)
62 assert_equal(tx3['txid'], txid3) #tx3 must be available (unconfirmed)
64 #restart bitcoind
65 self.nodes[0].stop()
66 bitcoind_processes[0].wait()
67 self.nodes[0] = start_node(0,self.options.tmpdir)
69 tx3 = self.nodes[0].gettransaction(txid3)
70 assert_equal(tx3['txid'], txid3) #tx must be available (unconfirmed)
72 self.nodes[0].stop()
73 bitcoind_processes[0].wait()
75 #restart bitcoind with zapwallettxes
76 self.nodes[0] = start_node(0,self.options.tmpdir, ["-zapwallettxes=1"])
78 assert_raises(JSONRPCException, self.nodes[0].gettransaction, [txid3])
79 #there must be a expection because the unconfirmed wallettx0 must be gone by now
81 tx0 = self.nodes[0].gettransaction(txid0)
82 assert_equal(tx0['txid'], txid0) #tx0 (confirmed) must still be available because it was confirmed
85 if __name__ == '__main__':
86 ZapWalletTXesTest ().main ()