Skip to content

Commit 2e4edc6

Browse files
committed
Add some test logging to wallet_bumpfee.py
1 parent ccb2c9e commit 2e4edc6

File tree

1 file changed

+56
-44
lines changed

1 file changed

+56
-44
lines changed

test/functional/wallet_bumpfee.py

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,29 @@ def run_test(self):
7171
test_simple_bumpfee_succeeds(self, "default", rbf_node, peer_node, dest_address)
7272
test_simple_bumpfee_succeeds(self, "fee_rate", rbf_node, peer_node, dest_address)
7373
test_feerate_args(self, rbf_node, peer_node, dest_address)
74-
test_segwit_bumpfee_succeeds(rbf_node, dest_address)
75-
test_nonrbf_bumpfee_fails(peer_node, dest_address)
76-
test_notmine_bumpfee_fails(rbf_node, peer_node, dest_address)
77-
test_bumpfee_with_descendant_fails(rbf_node, rbf_node_address, dest_address)
78-
test_small_output_fails(rbf_node, dest_address)
79-
test_dust_to_fee(rbf_node, dest_address)
80-
test_settxfee(rbf_node, dest_address)
74+
test_segwit_bumpfee_succeeds(self, rbf_node, dest_address)
75+
test_nonrbf_bumpfee_fails(self, peer_node, dest_address)
76+
test_notmine_bumpfee_fails(self, rbf_node, peer_node, dest_address)
77+
test_bumpfee_with_descendant_fails(self, rbf_node, rbf_node_address, dest_address)
78+
test_small_output_fails(self, rbf_node, dest_address)
79+
test_dust_to_fee(self, rbf_node, dest_address)
80+
test_settxfee(self, rbf_node, dest_address)
8181
test_watchonly_psbt(self, peer_node, rbf_node, dest_address)
82-
test_rebumping(rbf_node, dest_address)
83-
test_rebumping_not_replaceable(rbf_node, dest_address)
84-
test_unconfirmed_not_spendable(rbf_node, rbf_node_address)
85-
test_bumpfee_metadata(rbf_node, dest_address)
86-
test_locked_wallet_fails(rbf_node, dest_address)
87-
test_change_script_match(rbf_node, dest_address)
82+
test_rebumping(self, rbf_node, dest_address)
83+
test_rebumping_not_replaceable(self, rbf_node, dest_address)
84+
test_unconfirmed_not_spendable(self, rbf_node, rbf_node_address)
85+
test_bumpfee_metadata(self, rbf_node, dest_address)
86+
test_locked_wallet_fails(self, rbf_node, dest_address)
87+
test_change_script_match(self, rbf_node, dest_address)
8888
test_maxtxfee_fails(self, rbf_node, dest_address)
8989
# These tests wipe out a number of utxos that are expected in other tests
90-
test_small_output_with_feerate_succeeds(rbf_node, dest_address)
91-
test_no_more_inputs_fails(rbf_node, dest_address)
90+
test_small_output_with_feerate_succeeds(self, rbf_node, dest_address)
91+
test_no_more_inputs_fails(self, rbf_node, dest_address)
9292
self.log.info("Success")
9393

9494

9595
def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
96+
self.log.info('Test simple bumpfee')
9697
rbfid = spend_one_input(rbf_node, dest_address)
9798
rbftx = rbf_node.gettransaction(rbfid)
9899
self.sync_mempools((rbf_node, peer_node))
@@ -119,6 +120,7 @@ def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
119120
assert_equal(bumpedwtx["replaces_txid"], rbfid)
120121

121122
def test_feerate_args(self, rbf_node, peer_node, dest_address):
123+
self.log.info('Test feerate args')
122124
rbfid = spend_one_input(rbf_node, dest_address)
123125
self.sync_mempools((rbf_node, peer_node))
124126
assert rbfid in rbf_node.getrawmempool() and rbfid in peer_node.getrawmempool()
@@ -135,7 +137,8 @@ def test_feerate_args(self, rbf_node, peer_node, dest_address):
135137
assert_raises_rpc_error(-4, "is too high (cannot be higher than", rbf_node.bumpfee, rbfid, {"fee_rate":1})
136138

137139

138-
def test_segwit_bumpfee_succeeds(rbf_node, dest_address):
140+
def test_segwit_bumpfee_succeeds(self, rbf_node, dest_address):
141+
self.log.info('Test that segwit-sourcing bumpfee works')
139142
# Create a transaction with segwit output, then create an RBF transaction
140143
# which spends it, and make sure bumpfee can be called on it.
141144

@@ -165,14 +168,14 @@ def test_segwit_bumpfee_succeeds(rbf_node, dest_address):
165168
assert rbfid not in rbf_node.getrawmempool()
166169

167170

168-
def test_nonrbf_bumpfee_fails(peer_node, dest_address):
169-
# cannot replace a non RBF transaction (from node which did not enable RBF)
171+
def test_nonrbf_bumpfee_fails(self, peer_node, dest_address):
172+
self.log.info('Test that we cannot replace a non RBF transaction')
170173
not_rbfid = peer_node.sendtoaddress(dest_address, Decimal("0.00090000"))
171174
assert_raises_rpc_error(-4, "not BIP 125 replaceable", peer_node.bumpfee, not_rbfid)
172175

173176

174-
def test_notmine_bumpfee_fails(rbf_node, peer_node, dest_address):
175-
# cannot bump fee unless the tx has only inputs that we own.
177+
def test_notmine_bumpfee_fails(self, rbf_node, peer_node, dest_address):
178+
self.log.info('Test that it cannot bump fee if non-owned inputs are included')
176179
# here, the rbftx has a peer_node coin and then adds a rbf_node input
177180
# Note that this test depends upon the RPC code checking input ownership prior to change outputs
178181
# (since it can't use fundrawtransaction, it lacks a proper change output)
@@ -192,32 +195,34 @@ def test_notmine_bumpfee_fails(rbf_node, peer_node, dest_address):
192195
rbf_node.bumpfee, rbfid)
193196

194197

195-
def test_bumpfee_with_descendant_fails(rbf_node, rbf_node_address, dest_address):
196-
# cannot bump fee if the transaction has a descendant
198+
def test_bumpfee_with_descendant_fails(self, rbf_node, rbf_node_address, dest_address):
199+
self.log.info('Test that fee cannot be bumped when it has descendant')
197200
# parent is send-to-self, so we don't have to check which output is change when creating the child tx
198201
parent_id = spend_one_input(rbf_node, rbf_node_address)
199202
tx = rbf_node.createrawtransaction([{"txid": parent_id, "vout": 0}], {dest_address: 0.00020000})
200203
tx = rbf_node.signrawtransactionwithwallet(tx)
201204
rbf_node.sendrawtransaction(tx["hex"])
202205
assert_raises_rpc_error(-8, "Transaction has descendants in the wallet", rbf_node.bumpfee, parent_id)
203206

204-
def test_small_output_fails(rbf_node, dest_address):
207+
def test_small_output_fails(self, rbf_node, dest_address):
208+
self.log.info('Test totalFee bump with small output fails')
205209
# cannot bump fee with a too-small output
206210
rbfid = spend_one_input(rbf_node, dest_address)
207211
rbf_node.bumpfee(rbfid, {"totalFee": 50000})
208212

209213
rbfid = spend_one_input(rbf_node, dest_address)
210214
assert_raises_rpc_error(-4, "Change output is too small", rbf_node.bumpfee, rbfid, {"totalFee": 50001})
211215

212-
def test_small_output_with_feerate_succeeds(rbf_node, dest_address):
216+
def test_small_output_with_feerate_succeeds(self, rbf_node, dest_address):
217+
self.log.info('Testing small output with feerate bump succeeds')
213218

214219
# Make sure additional inputs exist
215220
rbf_node.generatetoaddress(101, rbf_node.getnewaddress())
216221
rbfid = spend_one_input(rbf_node, dest_address)
217222
input_list = rbf_node.getrawtransaction(rbfid, 1)["vin"]
218223
assert_equal(len(input_list), 1)
219224
original_txin = input_list[0]
220-
# Keep bumping until we out-spend change output
225+
self.log.info('Keep bumping until transaction fee out-spends change output amount')
221226
tx_fee = 0
222227
while tx_fee < Decimal("0.0005"):
223228
input_list = rbf_node.getrawtransaction(rbfid, 1)["vin"]
@@ -244,8 +249,8 @@ def test_small_output_with_feerate_succeeds(rbf_node, dest_address):
244249
rbf_node.generatetoaddress(1, rbf_node.getnewaddress())
245250
assert_equal(rbf_node.gettransaction(rbfid)["confirmations"], 1)
246251

247-
def test_dust_to_fee(rbf_node, dest_address):
248-
# check that if output is reduced to dust, it will be converted to fee
252+
def test_dust_to_fee(self, rbf_node, dest_address):
253+
self.log.info('Test that bumped output that is dust is dropped to fee')
249254
# the bumped tx sets fee=49,900, but it converts to 50,000
250255
rbfid = spend_one_input(rbf_node, dest_address)
251256
fulltx = rbf_node.getrawtransaction(rbfid, 1)
@@ -257,7 +262,8 @@ def test_dust_to_fee(rbf_node, dest_address):
257262
assert_equal(len(full_bumped_tx["vout"]), 1) # change output is eliminated
258263

259264

260-
def test_settxfee(rbf_node, dest_address):
265+
def test_settxfee(self, rbf_node, dest_address):
266+
self.log.info('Test settxfee')
261267
assert_raises_rpc_error(-8, "txfee cannot be less than min relay tx fee", rbf_node.settxfee, Decimal('0.000005'))
262268
assert_raises_rpc_error(-8, "txfee cannot be less than wallet min fee", rbf_node.settxfee, Decimal('0.000015'))
263269
# check that bumpfee reacts correctly to the use of settxfee (paytxfee)
@@ -272,17 +278,19 @@ def test_settxfee(rbf_node, dest_address):
272278
rbf_node.settxfee(Decimal("0.00000000")) # unset paytxfee
273279

274280

275-
def test_maxtxfee_fails(test, rbf_node, dest_address):
281+
def test_maxtxfee_fails(self, rbf_node, dest_address):
282+
self.log.info('Test that bumpfee fails when it hits -matxfee')
276283
# size of bumped transaction (p2wpkh, 1 input, 2 outputs): 141 vbytes
277284
# expected bumping feerate of 20 sats/vbyte => 141*20 sats = 0.00002820 btc
278-
test.restart_node(1, ['-maxtxfee=0.000025'] + test.extra_args[1])
285+
self.restart_node(1, ['-maxtxfee=0.000025'] + self.extra_args[1])
279286
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
280287
rbfid = spend_one_input(rbf_node, dest_address)
281288
assert_raises_rpc_error(-4, "Unable to create transaction: Fee exceeds maximum configured by -maxtxfee", rbf_node.bumpfee, rbfid)
282-
test.restart_node(1, test.extra_args[1])
289+
self.restart_node(1, self.extra_args[1])
283290
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
284291

285-
def test_watchonly_psbt(test, peer_node, rbf_node, dest_address):
292+
def test_watchonly_psbt(self, peer_node, rbf_node, dest_address):
293+
self.log.info('Test that PSBT is returned for bumpfee in watchonly wallets')
286294
priv_rec_desc = "wpkh([00000001/84'/1'/0']tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/0/*)#rweraev0"
287295
pub_rec_desc = rbf_node.getdescriptorinfo(priv_rec_desc)["descriptor"]
288296
priv_change_desc = "wpkh([00000001/84'/1'/0']tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/*)#j6uzqvuh"
@@ -334,7 +342,7 @@ def test_watchonly_psbt(test, peer_node, rbf_node, dest_address):
334342
funding_address2 = watcher.getnewaddress(address_type='bech32')
335343
peer_node.sendmany("", {funding_address1: 0.001, funding_address2: 0.001})
336344
peer_node.generate(1)
337-
test.sync_all()
345+
self.sync_all()
338346

339347
# Create single-input PSBT for transaction to be bumped
340348
psbt = watcher.walletcreatefundedpsbt([], {dest_address:0.0005}, 0, {"feeRate": 0.00001}, True)['psbt']
@@ -363,24 +371,24 @@ def test_watchonly_psbt(test, peer_node, rbf_node, dest_address):
363371
rbf_node.unloadwallet("watcher")
364372
rbf_node.unloadwallet("signer")
365373

366-
def test_rebumping(rbf_node, dest_address):
367-
# check that re-bumping the original tx fails, but bumping the bumper succeeds
374+
def test_rebumping(self, rbf_node, dest_address):
375+
self.log.info('Test that re-bumping the original tx fails, but bumping successor works')
368376
rbfid = spend_one_input(rbf_node, dest_address)
369377
bumped = rbf_node.bumpfee(rbfid, {"totalFee": 2000})
370378
assert_raises_rpc_error(-4, "already bumped", rbf_node.bumpfee, rbfid, {"totalFee": 3000})
371379
rbf_node.bumpfee(bumped["txid"], {"totalFee": 3000})
372380

373381

374-
def test_rebumping_not_replaceable(rbf_node, dest_address):
375-
# check that re-bumping a non-replaceable bump tx fails
382+
def test_rebumping_not_replaceable(self, rbf_node, dest_address):
383+
self.log.info('Test that re-bumping non-replaceable fails')
376384
rbfid = spend_one_input(rbf_node, dest_address)
377385
bumped = rbf_node.bumpfee(rbfid, {"totalFee": 10000, "replaceable": False})
378386
assert_raises_rpc_error(-4, "Transaction is not BIP 125 replaceable", rbf_node.bumpfee, bumped["txid"],
379387
{"totalFee": 20000})
380388

381389

382-
def test_unconfirmed_not_spendable(rbf_node, rbf_node_address):
383-
# check that unconfirmed outputs from bumped transactions are not spendable
390+
def test_unconfirmed_not_spendable(self, rbf_node, rbf_node_address):
391+
self.log.info('Test that unconfirmed outputs from bumped txns are not spendable')
384392
rbfid = spend_one_input(rbf_node, rbf_node_address)
385393
rbftx = rbf_node.gettransaction(rbfid)["hex"]
386394
assert rbfid in rbf_node.getrawmempool()
@@ -418,7 +426,8 @@ def test_unconfirmed_not_spendable(rbf_node, rbf_node_address):
418426
if t["txid"] == rbfid and t["address"] == rbf_node_address and t["spendable"]), 1)
419427

420428

421-
def test_bumpfee_metadata(rbf_node, dest_address):
429+
def test_bumpfee_metadata(self, rbf_node, dest_address):
430+
self.log.info('Test that bumped txn metadata persists to new txn record')
422431
assert(rbf_node.getbalance() < 49)
423432
rbf_node.generatetoaddress(101, rbf_node.getnewaddress())
424433
rbfid = rbf_node.sendtoaddress(dest_address, 49, "comment value", "to value")
@@ -428,15 +437,17 @@ def test_bumpfee_metadata(rbf_node, dest_address):
428437
assert_equal(bumped_wtx["to"], "to value")
429438

430439

431-
def test_locked_wallet_fails(rbf_node, dest_address):
440+
def test_locked_wallet_fails(self, rbf_node, dest_address):
441+
self.log.info('Test that locked wallet cannot bump txn')
432442
rbfid = spend_one_input(rbf_node, dest_address)
433443
rbf_node.walletlock()
434444
assert_raises_rpc_error(-13, "Please enter the wallet passphrase with walletpassphrase first.",
435445
rbf_node.bumpfee, rbfid)
436446
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
437447

438-
def test_change_script_match(rbf_node, dest_address):
439-
"""Test that the same change addresses is used for the replacement transaction when possible."""
448+
def test_change_script_match(self, rbf_node, dest_address):
449+
self.log.info('Test that the same change addresses is used for the replacement transaction when possible.')
450+
440451
def get_change_address(tx):
441452
tx_details = rbf_node.getrawtransaction(tx, 1)
442453
txout_addresses = [txout['scriptPubKey']['addresses'][0] for txout in tx_details["vout"]]
@@ -480,7 +491,8 @@ def submit_block_with_tx(node, tx):
480491
node.submitblock(block.serialize().hex())
481492
return block
482493

483-
def test_no_more_inputs_fails(rbf_node, dest_address):
494+
def test_no_more_inputs_fails(self, rbf_node, dest_address):
495+
self.log.info('Test that bumpfee fails when there are no available confirmed outputs')
484496
# feerate rbf requires confirmed outputs when change output doesn't exist or is insufficient
485497
rbf_node.generatetoaddress(1, dest_address)
486498
# spend all funds, no change output

0 commit comments

Comments
 (0)