Skip to content

Commit a006d7d

Browse files
theStackjonatack
andcommitted
test: add logging to wallet_listtransactions
Co-authored-by: Jon Atack <[email protected]>
1 parent 47915b1 commit a006d7d

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

test/functional/wallet_listtransactions.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def skip_test_if_missing_module(self):
2626
self.skip_if_no_wallet()
2727

2828
def run_test(self):
29-
# Simple send, 0 to 1:
29+
self.log.info("Test simple send from node0 to node1")
3030
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
3131
self.sync_all()
3232
assert_array_result(self.nodes[0].listtransactions(),
@@ -35,7 +35,7 @@ def run_test(self):
3535
assert_array_result(self.nodes[1].listtransactions(),
3636
{"txid": txid},
3737
{"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")
3939
blockhash = self.nodes[0].generate(1)[0]
4040
blockheight = self.nodes[0].getblockheader(blockhash)['height']
4141
self.sync_all()
@@ -46,7 +46,7 @@ def run_test(self):
4646
{"txid": txid},
4747
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 1, "blockhash": blockhash, "blockheight": blockheight})
4848

49-
# send-to-self:
49+
self.log.info("Test send-to-self on node0")
5050
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 0.2)
5151
assert_array_result(self.nodes[0].listtransactions(),
5252
{"txid": txid, "category": "send"},
@@ -55,7 +55,7 @@ def run_test(self):
5555
{"txid": txid, "category": "receive"},
5656
{"amount": Decimal("0.2")})
5757

58-
# sendmany from node1: twice to self, twice to node2:
58+
self.log.info("Test sendmany from node1: twice to self, twice to node0")
5959
send_to = {self.nodes[0].getnewaddress(): 0.11,
6060
self.nodes[1].getnewaddress(): 0.22,
6161
self.nodes[0].getnewaddress(): 0.33,
@@ -89,6 +89,7 @@ def run_test(self):
8989

9090
if not self.options.descriptors:
9191
# 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)")
9293
pubkey = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress())['pubkey']
9394
multisig = self.nodes[1].createmultisig(1, [pubkey])
9495
self.nodes[0].importaddress(multisig["redeemScript"], "watchonly", False, True)
@@ -104,33 +105,35 @@ def run_test(self):
104105

105106
self.run_rbf_opt_in_test()
106107

107-
# Check that the opt-in-rbf flag works properly, for sent and received
108-
# transactions.
108+
109109
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+
111112
def is_opt_in(node, txid):
113+
"""Check whether a transaction signals opt-in RBF itself."""
112114
rawtx = node.getrawtransaction(txid, 1)
113115
for x in rawtx["vin"]:
114116
if x["sequence"] < 0xfffffffe:
115117
return True
116118
return False
117119

118-
# Find an unconfirmed output matching a certain txid
119120
def get_unconfirmed_utxo_entry(node, txid_to_match):
121+
"""Find an unconfirmed output matching a certain txid."""
120122
utxo = node.listunspent(0, 0)
121123
for i in utxo:
122124
if i["txid"] == txid_to_match:
123125
return i
124126
return None
125127

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.
127130
txid_1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
128131
assert not is_opt_in(self.nodes[0], txid_1)
129132
assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_1}, {"bip125-replaceable": "no"})
130133
self.sync_mempools()
131134
assert_array_result(self.nodes[1].listtransactions(), {"txid": txid_1}, {"bip125-replaceable": "no"})
132135

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.
134137
utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[0], txid_1)
135138
assert_equal(utxo_to_use["safe"], True)
136139
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):
149152
self.sync_mempools()
150153
assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_2}, {"bip125-replaceable": "no"})
151154

155+
self.log.info("Test txs with opt-in RBF (bip125-replaceable=yes)")
152156
# Tx3 will opt-in to RBF
153157
utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[0], txid_2)
154158
inputs = [{"txid": txid_2, "vout": utxo_to_use["vout"]}]
@@ -179,6 +183,7 @@ def get_unconfirmed_utxo_entry(node, txid_to_match):
179183
self.sync_mempools()
180184
assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_4}, {"bip125-replaceable": "yes"})
181185

186+
self.log.info("Test tx with unknown RBF state (bip125-replaceable=unknown)")
182187
# Replace tx3, and check that tx4 becomes unknown
183188
tx3_b = tx3_modified
184189
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):
191196
self.sync_mempools()
192197
assert_array_result(self.nodes[1].listtransactions(), {"txid": txid_4}, {"bip125-replaceable": "unknown"})
193198

194-
# Check gettransaction as well:
199+
self.log.info("Test bip125-replaceable status with gettransaction RPC")
195200
for n in self.nodes[0:2]:
196201
assert_equal(n.gettransaction(txid_1)["bip125-replaceable"], "no")
197202
assert_equal(n.gettransaction(txid_2)["bip125-replaceable"], "no")
198203
assert_equal(n.gettransaction(txid_3)["bip125-replaceable"], "yes")
199204
assert_equal(n.gettransaction(txid_3b)["bip125-replaceable"], "yes")
200205
assert_equal(n.gettransaction(txid_4)["bip125-replaceable"], "unknown")
201206

202-
# After mining a transaction, it's no longer BIP125-replaceable
207+
self.log.info("Test mined transactions are no longer bip125-replaceable")
203208
self.nodes[0].generate(1)
204209
assert txid_3b not in self.nodes[0].getrawmempool()
205210
assert_equal(self.nodes[0].gettransaction(txid_3b)["bip125-replaceable"], "no")

0 commit comments

Comments
 (0)