v29.4-roots.4 · Commit 35: [PATCH 35/37] rpc: report the configured RBF policy in getmempoolinfo
test/functional/mempool_rbf_policy.py
Before: /dev/null · After: test/functional/mempool_rbf_policy.py
File metadata
new file mode 100755 index 0000000000000000000000000000000000000000..55a1d04a6089cfe5760575164f3531e3f6eec3c1
Download original patch · Release notes
Diff rows 1–68 of 68. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
test/functional/mempool_rbf_policy.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# Copyright (c) 2026 The Bitcoin Roots developers
|
| 3 |
+
# Distributed under the MIT software license, see the accompanying
|
| 4 |
+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
| 5 |
+
"""Test that getmempoolinfo reports the configured replacement policy.
|
| 6 |
+
|
| 7 |
+
-mempoolreplacement and -mempoolfullrbf select whether conflicting
|
| 8 |
+
transactions are never replaced, replaced only when the original signals
|
| 9 |
+
BIP125 replaceability, or always replaced by fee. The "fullrbf" field must
|
| 10 |
+
match the policy the node enforces.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from decimal import Decimal
|
| 14 |
+
|
| 15 |
+
from test_framework.messages import (
|
| 16 |
+
MAX_BIP125_RBF_SEQUENCE,
|
| 17 |
+
SEQUENCE_FINAL,
|
| 18 |
+
)
|
| 19 |
+
from test_framework.test_framework import BitcoinTestFramework
|
| 20 |
+
from test_framework.util import (
|
| 21 |
+
assert_equal,
|
| 22 |
+
assert_raises_rpc_error,
|
| 23 |
+
)
|
| 24 |
+
from test_framework.wallet import MiniWallet
|
| 25 |
+
|
| 26 |
+
# (extra_args, fullrbf, non-signaling original replaceable, signaling original replaceable)
|
| 27 |
+
POLICIES = [
|
| 28 |
+
([], True, True, True),
|
| 29 |
+
(["-mempoolreplacement=fee,-optin"], True, True, True),
|
| 30 |
+
(["-mempoolreplacement=fee,optin"], False, False, True),
|
| 31 |
+
(["-mempoolfullrbf=0"], False, False, True),
|
| 32 |
+
(["-mempoolreplacement=0"], False, False, False),
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class MempoolRBFPolicyTest(BitcoinTestFramework):
|
| 37 |
+
def set_test_params(self):
|
| 38 |
+
self.num_nodes = 1
|
| 39 |
+
|
| 40 |
+
def run_test(self):
|
| 41 |
+
self.wallet = MiniWallet(self.nodes[0])
|
| 42 |
+
|
| 43 |
+
for extra_args, fullrbf, nonsignaling_replaceable, signaling_replaceable in POLICIES:
|
| 44 |
+
self.log.info(f"Check replacement policy with {extra_args or 'default options'}")
|
| 45 |
+
self.restart_node(0, extra_args=extra_args)
|
| 46 |
+
assert_equal(self.nodes[0].getmempoolinfo()["fullrbf"], fullrbf)
|
| 47 |
+
self.check_replacement(sequence=SEQUENCE_FINAL, replaceable=nonsignaling_replaceable)
|
| 48 |
+
self.check_replacement(sequence=MAX_BIP125_RBF_SEQUENCE, replaceable=signaling_replaceable)
|
| 49 |
+
self.generate(self.nodes[0], 1)
|
| 50 |
+
|
| 51 |
+
def check_replacement(self, *, sequence, replaceable):
|
| 52 |
+
node = self.nodes[0]
|
| 53 |
+
utxo = self.wallet.get_utxo()
|
| 54 |
+
original = self.wallet.create_self_transfer(utxo_to_spend=utxo, sequence=sequence)
|
| 55 |
+
replacement = self.wallet.create_self_transfer(utxo_to_spend=utxo, sequence=sequence, fee_rate=Decimal("0.01"))
|
| 56 |
+
node.sendrawtransaction(original["hex"])
|
| 57 |
+
if replaceable:
|
| 58 |
+
node.sendrawtransaction(replacement["hex"])
|
| 59 |
+
mempool = node.getrawmempool()
|
| 60 |
+
assert original["txid"] not in mempool
|
| 61 |
+
assert replacement["txid"] in mempool
|
| 62 |
+
else:
|
| 63 |
+
assert_raises_rpc_error(-26, "txn-mempool-conflict", node.sendrawtransaction, replacement["hex"])
|
| 64 |
+
assert original["txid"] in node.getrawmempool()
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
if __name__ == '__main__':
|
| 68 |
+
MempoolRBFPolicyTest(__file__).main()
|