This assumes that the transaction to be evicted, the one that spends conflict_utxo, has a fee rate less than 30. That is a bit obscure and fragile.
Consider getting the feerate of the transaction to be evicted and using a higher value than that (plus two more asserts - that the to-be-evicted transaction is in the mempool when the function starts and is absent at the end):
--- i/test/functional/wallet_resendwallettransactions.py
+++ w/test/functional/wallet_resendwallettransactions.py
@@ -9,5 +9,8 @@ from test_framework.blocktools import (
create_block,
)
-from test_framework.messages import DEFAULT_MEMPOOL_EXPIRY_HOURS
+from test_framework.messages import (
+ COIN,
+ DEFAULT_MEMPOOL_EXPIRY_HOURS,
+)
from test_framework.p2p import P2PTxInvStore
from test_framework.test_framework import BitcoinTestFramework
@@ -45,12 +48,20 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
def evict_mempool_transaction(self, conflict_utxo, node, wallet, indep_wallet):
# Evict a transaction spending conflict_utxo by creating a conflict with it that pays a higher feerate
+ evict_txid = node.gettxspendingprevout([{"txid": conflict_utxo["txid"], "vout": conflict_utxo["vout"]}])[0]["spendingtxid"]
+ assert evict_txid in node.getrawmempool()
+ evict_tx_mempool_entry = node.getmempoolentry(evict_txid)
+ evict_tx_feerate = evict_tx_mempool_entry["fees"]["base"] * COIN / evict_tx_mempool_entry["vsize"]
+
indep_utxo = indep_wallet.listunspent()[0]
- psbt = indep_wallet.send(outputs=[{indep_wallet.getnewaddress(): 0.00001}], psbt=True, fee_rate=30, inputs=[conflict_utxo, indep_utxo], solving_data={"descriptors":[conflict_utxo["desc"]]})["psbt"]
+ tx1_feerate = evict_tx_feerate * 2
+ psbt = indep_wallet.send(outputs=[{indep_wallet.getnewaddress(): 0.00001}], psbt=True, fee_rate=tx1_feerate, inputs=[conflict_utxo, indep_utxo], solving_data={"descriptors":[conflict_utxo["desc"]]})["psbt"]
psbt = wallet.walletprocesspsbt(psbt)["psbt"]
txid1 = node.sendrawtransaction(node.finalizepsbt(psbt)["hex"])
# Create a conflict with just indep_utxo to evict the previous transaction so that the original can be rebroadcast
- r = indep_wallet.send(outputs=[{indep_wallet.getnewaddress(): 0.00001}], fee_rate=60, inputs=[indep_utxo], add_to_wallet=False)
+ tx2_feerate = tx1_feerate * 2
+ r = indep_wallet.send(outputs=[{indep_wallet.getnewaddress(): 0.00001}], fee_rate=tx2_feerate, inputs=[indep_utxo], add_to_wallet=False)
txid2 = node.sendrawtransaction(r["hex"])
mempool = node.getrawmempool()
+ assert evict_txid not in node.getrawmempool()
assert txid1 not in mempool
assert txid2 in mempool