Skip to content

Commit c1061ac

Browse files
committed
[functional test] prioritisation is not removed during replacement and expiry
1 parent 0e5874f commit c1061ac

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

test/functional/mempool_expiry.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def test_transaction_expiry(self, timeout):
4040
parent_utxo = self.wallet.get_utxo(txid=parent_txid)
4141
independent_utxo = self.wallet.get_utxo()
4242

43+
# Add prioritisation to this transaction to check that it persists after the expiry
44+
node.prioritisetransaction(parent_txid, 0, COIN)
45+
assert_equal(node.getprioritisedtransactions()[parent_txid], { "fee_delta" : COIN, "in_mempool" : True})
46+
4347
# Ensure the transactions we send to trigger the mempool check spend utxos that are independent of
4448
# the transactions being tested for expiration.
4549
trigger_utxo1 = self.wallet.get_utxo()
@@ -82,6 +86,9 @@ def test_transaction_expiry(self, timeout):
8286
assert_raises_rpc_error(-5, 'Transaction not in mempool',
8387
node.getmempoolentry, parent_txid)
8488

89+
# Prioritisation does not disappear when transaction expires
90+
assert_equal(node.getprioritisedtransactions()[parent_txid], { "fee_delta" : COIN, "in_mempool" : False})
91+
8592
# The child transaction should be removed from the mempool as well.
8693
self.log.info('Test child tx is evicted as well.')
8794
assert_raises_rpc_error(-5, 'Transaction not in mempool',

test/functional/mining_prioritisetransaction.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@ def set_test_params(self):
3030
]] * self.num_nodes
3131
self.supports_cli = False
3232

33+
def test_replacement(self):
34+
self.log.info("Test tx prioritisation stays after a tx is replaced")
35+
conflicting_input = self.wallet.get_utxo()
36+
tx_replacee = self.wallet.create_self_transfer(utxo_to_spend=conflicting_input, fee_rate=Decimal("0.0001"))
37+
tx_replacement = self.wallet.create_self_transfer(utxo_to_spend=conflicting_input, fee_rate=Decimal("0.005"))
38+
# Add 1 satoshi fee delta to replacee
39+
self.nodes[0].prioritisetransaction(tx_replacee["txid"], 0, 100)
40+
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : False}})
41+
self.nodes[0].sendrawtransaction(tx_replacee["hex"])
42+
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : True}})
43+
self.nodes[0].sendrawtransaction(tx_replacement["hex"])
44+
assert tx_replacee["txid"] not in self.nodes[0].getrawmempool()
45+
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : False}})
46+
47+
# PrioritiseTransaction is additive
48+
self.nodes[0].prioritisetransaction(tx_replacee["txid"], 0, COIN)
49+
self.nodes[0].sendrawtransaction(tx_replacee["hex"])
50+
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : COIN + 100, "in_mempool" : True}})
51+
self.generate(self.nodes[0], 1)
52+
assert_equal(self.nodes[0].getprioritisedtransactions(), {})
53+
3354
def test_diamond(self):
3455
self.log.info("Test diamond-shape package with priority")
3556
mock_time = int(time.time())
@@ -142,6 +163,7 @@ def run_test(self):
142163
# Test `prioritisetransaction` invalid `fee_delta`
143164
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].prioritisetransaction, txid=txid, fee_delta='foo')
144165

166+
self.test_replacement()
145167
self.test_diamond()
146168

147169
self.txouts = gen_return_txouts()

0 commit comments

Comments
 (0)