@@ -26,7 +26,7 @@ def skip_test_if_missing_module(self):
26
26
self .skip_if_no_wallet ()
27
27
28
28
def run_test (self ):
29
- # Simple send, 0 to 1:
29
+ self . log . info ( "Test simple send from node0 to node1" )
30
30
txid = self .nodes [0 ].sendtoaddress (self .nodes [1 ].getnewaddress (), 0.1 )
31
31
self .sync_all ()
32
32
assert_array_result (self .nodes [0 ].listtransactions (),
@@ -35,7 +35,7 @@ def run_test(self):
35
35
assert_array_result (self .nodes [1 ].listtransactions (),
36
36
{"txid" : txid },
37
37
{"category" : "receive" , "amount" : Decimal ("0.1" ), "confirmations" : 0 })
38
- # mine a block, confirmations should change:
38
+ self . log . info ( "Test confirmations change after mining a block" )
39
39
blockhash = self .nodes [0 ].generate (1 )[0 ]
40
40
blockheight = self .nodes [0 ].getblockheader (blockhash )['height' ]
41
41
self .sync_all ()
@@ -46,7 +46,7 @@ def run_test(self):
46
46
{"txid" : txid },
47
47
{"category" : "receive" , "amount" : Decimal ("0.1" ), "confirmations" : 1 , "blockhash" : blockhash , "blockheight" : blockheight })
48
48
49
- # send-to-self:
49
+ self . log . info ( "Test send-to-self on node0" )
50
50
txid = self .nodes [0 ].sendtoaddress (self .nodes [0 ].getnewaddress (), 0.2 )
51
51
assert_array_result (self .nodes [0 ].listtransactions (),
52
52
{"txid" : txid , "category" : "send" },
@@ -55,7 +55,7 @@ def run_test(self):
55
55
{"txid" : txid , "category" : "receive" },
56
56
{"amount" : Decimal ("0.2" )})
57
57
58
- # sendmany from node1: twice to self, twice to node2:
58
+ self . log . info ( "Test sendmany from node1: twice to self, twice to node0" )
59
59
send_to = {self .nodes [0 ].getnewaddress (): 0.11 ,
60
60
self .nodes [1 ].getnewaddress (): 0.22 ,
61
61
self .nodes [0 ].getnewaddress (): 0.33 ,
@@ -89,6 +89,7 @@ def run_test(self):
89
89
90
90
if not self .options .descriptors :
91
91
# include_watchonly is a legacy wallet feature, so don't test it for descriptor wallets
92
+ self .log .info ("Test 'include_watchonly' feature (legacy wallet)" )
92
93
pubkey = self .nodes [1 ].getaddressinfo (self .nodes [1 ].getnewaddress ())['pubkey' ]
93
94
multisig = self .nodes [1 ].createmultisig (1 , [pubkey ])
94
95
self .nodes [0 ].importaddress (multisig ["redeemScript" ], "watchonly" , False , True )
@@ -104,33 +105,35 @@ def run_test(self):
104
105
105
106
self .run_rbf_opt_in_test ()
106
107
107
- # Check that the opt-in-rbf flag works properly, for sent and received
108
- # transactions.
108
+
109
109
def run_rbf_opt_in_test (self ):
110
- # Check whether a transaction signals opt-in RBF itself
110
+ """Test the opt-in-rbf flag for sent and received transactions."""
111
+
111
112
def is_opt_in (node , txid ):
113
+ """Check whether a transaction signals opt-in RBF itself."""
112
114
rawtx = node .getrawtransaction (txid , 1 )
113
115
for x in rawtx ["vin" ]:
114
116
if x ["sequence" ] < 0xfffffffe :
115
117
return True
116
118
return False
117
119
118
- # Find an unconfirmed output matching a certain txid
119
120
def get_unconfirmed_utxo_entry (node , txid_to_match ):
121
+ """Find an unconfirmed output matching a certain txid."""
120
122
utxo = node .listunspent (0 , 0 )
121
123
for i in utxo :
122
124
if i ["txid" ] == txid_to_match :
123
125
return i
124
126
return None
125
127
126
- # 1. Chain a few transactions that don't opt-in.
128
+ self .log .info ("Test txs w/o opt-in RBF (bip125-replaceable=no)" )
129
+ # Chain a few transactions that don't opt in.
127
130
txid_1 = self .nodes [0 ].sendtoaddress (self .nodes [1 ].getnewaddress (), 1 )
128
131
assert not is_opt_in (self .nodes [0 ], txid_1 )
129
132
assert_array_result (self .nodes [0 ].listtransactions (), {"txid" : txid_1 }, {"bip125-replaceable" : "no" })
130
133
self .sync_mempools ()
131
134
assert_array_result (self .nodes [1 ].listtransactions (), {"txid" : txid_1 }, {"bip125-replaceable" : "no" })
132
135
133
- # Tx2 will build off txid_1 , still not opting in to RBF.
136
+ # Tx2 will build off tx1 , still not opting in to RBF.
134
137
utxo_to_use = get_unconfirmed_utxo_entry (self .nodes [0 ], txid_1 )
135
138
assert_equal (utxo_to_use ["safe" ], True )
136
139
utxo_to_use = get_unconfirmed_utxo_entry (self .nodes [1 ], txid_1 )
@@ -149,6 +152,7 @@ def get_unconfirmed_utxo_entry(node, txid_to_match):
149
152
self .sync_mempools ()
150
153
assert_array_result (self .nodes [0 ].listtransactions (), {"txid" : txid_2 }, {"bip125-replaceable" : "no" })
151
154
155
+ self .log .info ("Test txs with opt-in RBF (bip125-replaceable=yes)" )
152
156
# Tx3 will opt-in to RBF
153
157
utxo_to_use = get_unconfirmed_utxo_entry (self .nodes [0 ], txid_2 )
154
158
inputs = [{"txid" : txid_2 , "vout" : utxo_to_use ["vout" ]}]
@@ -179,6 +183,7 @@ def get_unconfirmed_utxo_entry(node, txid_to_match):
179
183
self .sync_mempools ()
180
184
assert_array_result (self .nodes [0 ].listtransactions (), {"txid" : txid_4 }, {"bip125-replaceable" : "yes" })
181
185
186
+ self .log .info ("Test tx with unknown RBF state (bip125-replaceable=unknown)" )
182
187
# Replace tx3, and check that tx4 becomes unknown
183
188
tx3_b = tx3_modified
184
189
tx3_b .vout [0 ].nValue -= int (Decimal ("0.004" ) * COIN ) # bump the fee
@@ -191,15 +196,15 @@ def get_unconfirmed_utxo_entry(node, txid_to_match):
191
196
self .sync_mempools ()
192
197
assert_array_result (self .nodes [1 ].listtransactions (), {"txid" : txid_4 }, {"bip125-replaceable" : "unknown" })
193
198
194
- # Check gettransaction as well:
199
+ self . log . info ( "Test bip125-replaceable status with gettransaction RPC" )
195
200
for n in self .nodes [0 :2 ]:
196
201
assert_equal (n .gettransaction (txid_1 )["bip125-replaceable" ], "no" )
197
202
assert_equal (n .gettransaction (txid_2 )["bip125-replaceable" ], "no" )
198
203
assert_equal (n .gettransaction (txid_3 )["bip125-replaceable" ], "yes" )
199
204
assert_equal (n .gettransaction (txid_3b )["bip125-replaceable" ], "yes" )
200
205
assert_equal (n .gettransaction (txid_4 )["bip125-replaceable" ], "unknown" )
201
206
202
- # After mining a transaction, it's no longer BIP125 -replaceable
207
+ self . log . info ( "Test mined transactions are no longer bip125 -replaceable" )
203
208
self .nodes [0 ].generate (1 )
204
209
assert txid_3b not in self .nodes [0 ].getrawmempool ()
205
210
assert_equal (self .nodes [0 ].gettransaction (txid_3b )["bip125-replaceable" ], "no" )
0 commit comments