Skip to content

Commit ee589d4

Browse files
committed
Add regression test for m_limit mutation
1 parent 275579d commit ee589d4

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

test/functional/mempool_limit.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,56 @@ def fill_mempool(self):
7878
assert_equal(node.getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000'))
7979
assert_greater_than(node.getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))
8080

81+
def test_rbf_carveout_disallowed(self):
82+
node = self.nodes[0]
83+
84+
self.log.info("Check that individually-evaluated transactions in a package don't increase package limits for other subpackage parts")
85+
86+
# We set chain limits to 2 ancestors, 1 descendant, then try to get a parents-and-child chain of 2 in mempool
87+
#
88+
# A: Solo transaction to be RBF'd (to bump descendant limit for package later)
89+
# B: First transaction in package, RBFs A by itself under individual evaluation, which would give it +1 descendant limit
90+
# C: Second transaction in package, spends B. If the +1 descendant limit persisted, would make it into mempool
91+
92+
self.restart_node(0, extra_args=self.extra_args[0] + ["-limitancestorcount=2", "-limitdescendantcount=1"])
93+
94+
# Generate a confirmed utxo we will double-spend
95+
rbf_utxo = self.wallet.send_self_transfer(
96+
from_node=node,
97+
confirmed_only=True
98+
)["new_utxo"]
99+
self.generate(node, 1)
100+
101+
# tx_A needs to be RBF'd, set minfee at set size
102+
A_weight = 1000
103+
mempoolmin_feerate = node.getmempoolinfo()["mempoolminfee"]
104+
tx_A = self.wallet.send_self_transfer(
105+
from_node=node,
106+
fee=(mempoolmin_feerate / 1000) * (A_weight // 4) + Decimal('0.000001'),
107+
target_weight=A_weight,
108+
utxo_to_spend=rbf_utxo,
109+
confirmed_only=True
110+
)
111+
112+
# RBF's tx_A, is not yet submitted
113+
tx_B = self.wallet.create_self_transfer(
114+
fee=tx_A["fee"] * 4,
115+
target_weight=A_weight,
116+
utxo_to_spend=rbf_utxo,
117+
confirmed_only=True
118+
)
119+
120+
# Spends tx_B's output, too big for cpfp carveout (because that would also increase the descendant limit by 1)
121+
non_cpfp_carveout_weight = 40001 # EXTRA_DESCENDANT_TX_SIZE_LIMIT + 1
122+
tx_C = self.wallet.create_self_transfer(
123+
target_weight=non_cpfp_carveout_weight,
124+
fee = (mempoolmin_feerate / 1000) * (non_cpfp_carveout_weight // 4) + Decimal('0.000001'),
125+
utxo_to_spend=tx_B["new_utxo"],
126+
confirmed_only=True
127+
)
128+
129+
assert_raises_rpc_error(-26, "too-long-mempool-chain", node.submitpackage, [tx_B["hex"], tx_C["hex"]])
130+
81131
def test_mid_package_eviction(self):
82132
node = self.nodes[0]
83133
self.log.info("Check a package where each parent passes the current mempoolminfee but would cause eviction before package submission terminates")
@@ -324,6 +374,7 @@ def run_test(self):
324374

325375
self.test_mid_package_replacement()
326376
self.test_mid_package_eviction()
377+
self.test_rbf_carveout_disallowed()
327378

328379

329380
if __name__ == '__main__':

0 commit comments

Comments
 (0)