13
13
available, but that the unconfirmed transaction has been zapped.
14
14
"""
15
15
from test_framework .test_framework import BitcoinTestFramework
16
- from test_framework .util import *
17
-
16
+ from test_framework .util import (assert_equal ,
17
+ assert_raises ,
18
+ bitcoind_processes ,
19
+ connect_nodes_bi ,
20
+ JSONRPCException ,
21
+ )
18
22
19
23
class ZapWalletTXesTest (BitcoinTestFramework ):
20
24
@@ -25,56 +29,56 @@ def __init__(self):
25
29
26
30
def setup_network (self ):
27
31
super ().setup_network ()
28
- connect_nodes_bi (self .nodes ,0 , 2 )
32
+ connect_nodes_bi (self .nodes , 0 , 2 )
29
33
30
- def run_test (self ):
34
+ def run_test (self ):
31
35
self .log .info ("Mining blocks..." )
32
36
self .nodes [0 ].generate (1 )
33
37
self .sync_all ()
34
38
self .nodes [1 ].generate (101 )
35
39
self .sync_all ()
36
-
40
+
37
41
assert_equal (self .nodes [0 ].getbalance (), 50 )
38
-
42
+
39
43
txid0 = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 11 )
40
44
txid1 = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 10 )
41
45
self .sync_all ()
42
46
self .nodes [0 ].generate (1 )
43
47
self .sync_all ()
44
-
48
+
45
49
txid2 = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 11 )
46
50
txid3 = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 10 )
47
-
51
+
48
52
tx0 = self .nodes [0 ].gettransaction (txid0 )
49
- assert_equal (tx0 ['txid' ], txid0 ) # tx0 must be available (confirmed)
50
-
53
+ assert_equal (tx0 ['txid' ], txid0 ) # tx0 must be available (confirmed)
54
+
51
55
tx1 = self .nodes [0 ].gettransaction (txid1 )
52
- assert_equal (tx1 ['txid' ], txid1 ) # tx1 must be available (confirmed)
53
-
56
+ assert_equal (tx1 ['txid' ], txid1 ) # tx1 must be available (confirmed)
57
+
54
58
tx2 = self .nodes [0 ].gettransaction (txid2 )
55
- assert_equal (tx2 ['txid' ], txid2 ) # tx2 must be available (unconfirmed)
56
-
59
+ assert_equal (tx2 ['txid' ], txid2 ) # tx2 must be available (unconfirmed)
60
+
57
61
tx3 = self .nodes [0 ].gettransaction (txid3 )
58
- assert_equal (tx3 ['txid' ], txid3 ) # tx3 must be available (unconfirmed)
59
-
62
+ assert_equal (tx3 ['txid' ], txid3 ) # tx3 must be available (unconfirmed)
63
+
60
64
#restart bitcoind
61
65
self .stop_node (0 )
62
66
self .nodes [0 ] = self .start_node (0 ,self .options .tmpdir )
63
67
64
68
tx3 = self .nodes [0 ].gettransaction (txid3 )
65
- assert_equal (tx3 ['txid' ], txid3 ) # tx must be available (unconfirmed)
66
-
69
+ assert_equal (tx3 ['txid' ], txid3 ) # tx must be available (unconfirmed)
70
+
67
71
self .stop_node (0 )
68
72
69
73
#restart bitcoind with zapwallettxes
70
74
self .nodes [0 ] = self .start_node (0 ,self .options .tmpdir , ["-zapwallettxes=1" ])
71
-
75
+
72
76
assert_raises (JSONRPCException , self .nodes [0 ].gettransaction , [txid3 ])
73
- #there must be an exception because the unconfirmed wallettx0 must be gone by now
77
+ # there must be an exception because the unconfirmed wallettx0 must be gone by now
74
78
75
79
tx0 = self .nodes [0 ].gettransaction (txid0 )
76
- assert_equal (tx0 ['txid' ], txid0 ) # tx0 (confirmed) must still be available because it was confirmed
80
+ assert_equal (tx0 ['txid' ], txid0 ) # tx0 (confirmed) must still be available because it was confirmed
77
81
78
82
79
83
if __name__ == '__main__' :
80
- ZapWalletTXesTest ().main ()
84
+ ZapWalletTXesTest ().main ()
0 commit comments