Skip to content

Commit

Permalink
tests: Use manual bumps instead of bumpfee for resendwallettransactions
Browse files Browse the repository at this point in the history
Bumpfee will try to increase the entire package to the target feerate,
which causes repeated bumpfees to quickly shoot up in fees, causing
intermittent failures when the fee is too large. We don't care about
this property, just that the child is continuously replaced until we
observe it's position in mapWallet is before its parent. Instead of
using bumpfee, we can create raw transactions which have only pay the
additional incremental relay fee, thus avoiding this problem.
  • Loading branch information
achow101 committed Sep 26, 2023
1 parent c9f2882 commit 42056e6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/functional/wallet_resendwallettransactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""Test that the wallet resends transactions periodically."""
import time

from decimal import Decimal

from test_framework.blocktools import (
create_block,
create_coinbase,
Expand All @@ -15,6 +17,7 @@
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
get_fee,
)

class ResendWalletTransactionsTest(BitcoinTestFramework):
Expand Down Expand Up @@ -86,18 +89,28 @@ def run_test(self):
# ordering of mapWallet is, if the child is not before the parent, we will create a new
# child (via bumpfee) and remove the old child (via removeprunedfunds) until we get the
# ordering of child before parent.
child_txid = node.send(outputs=[{addr: 0.5}], inputs=[{"txid":txid, "vout":0}])["txid"]
child_inputs = [{"txid": txid, "vout": 0}]
child_txid = node.sendall(recipients=[addr], inputs=child_inputs)["txid"]
# Get the child tx's info for manual bumping
child_tx_info = node.gettransaction(txid=child_txid, verbose=True)
child_output_value = child_tx_info["decoded"]["vout"][0]["value"]
additional_child_fee = get_fee(child_tx_info["decoded"]["vsize"], Decimal(0.00001100))
while True:
txids = node.listreceivedbyaddress(minconf=0, address_filter=addr)[0]["txids"]
if txids == [child_txid, txid]:
break
bumped = node.bumpfee(child_txid)
# Manually bump the tx
# The inputs and the output address stay the same, just changing the amount for the new fee
child_output_value -= additional_child_fee
bumped_raw = node.createrawtransaction(inputs=child_inputs, outputs=[{addr: child_output_value}])
bumped = node.signrawtransactionwithwallet(bumped_raw)
bumped_txid = node.sendrawtransaction(bumped["hex"])
# The scheduler queue creates a copy of the added tx after
# send/bumpfee and re-adds it to the wallet (undoing the next
# removeprunedfunds). So empty the scheduler queue:
node.syncwithvalidationinterfacequeue()
node.removeprunedfunds(child_txid)
child_txid = bumped["txid"]
child_txid = bumped_txid
entry_time = node.getmempoolentry(child_txid)["time"]

block_time = entry_time + 6 * 60
Expand Down

0 comments on commit 42056e6

Please sign in to comment.