Skip to content

Commit 20d5f9b

Browse files
committed
QA: feature_rbf: Test full RBF mode
1 parent 45baf0e commit 20d5f9b

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

test/functional/feature_rbf.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def add_options(self, parser):
2525
self.add_wallet_options(parser)
2626

2727
def set_test_params(self):
28-
self.num_nodes = 3
28+
self.num_nodes = 4
2929
# both nodes disable full-rbf to test BIP125 signaling
3030
self.extra_args = [
3131
[
@@ -44,6 +44,12 @@ def set_test_params(self):
4444
"-mempoolreplacement=0",
4545
],
4646
]
47+
self.extra_args.append(
48+
[
49+
*self.extra_args[0],
50+
"-mempoolreplacement=fee,-optin",
51+
],
52+
)
4753
self.supports_cli = False
4854

4955
def run_test(self):
@@ -74,7 +80,10 @@ def run_test(self):
7480
self.test_too_many_replacements_with_default_mempool_params()
7581

7682
self.log.info("Running test opt-in...")
77-
self.test_opt_in()
83+
self.test_opt_in(fullrbf=False)
84+
self.nodes[0], self.nodes[-1] = self.nodes[-1], self.nodes[0]
85+
self.test_opt_in(fullrbf=True)
86+
self.nodes[0], self.nodes[-1] = self.nodes[-1], self.nodes[0]
7887

7988
self.log.info("Running test RPC...")
8089
self.test_rpc()
@@ -486,7 +495,7 @@ def test_too_many_replacements_with_default_mempool_params(self):
486495
self.generate(normal_node, 1)
487496
self.wallet.rescan_utxos()
488497

489-
def test_opt_in(self):
498+
def test_opt_in(self, fullrbf):
490499
"""Replacing should only work if orig tx opted in"""
491500
tx0_outpoint = self.make_utxo(self.nodes[0], int(1.1 * COIN))
492501

@@ -502,14 +511,19 @@ def test_opt_in(self):
502511
assert_equal(self.nodes[0].getmempoolentry(tx1a_utxo["txid"])['bip125-replaceable'], False)
503512

504513
# Shouldn't be able to double-spend
505-
tx1b_hex = self.wallet.create_self_transfer(
514+
tx1b_st = self.wallet.create_self_transfer(
506515
utxo_to_spend=tx0_outpoint,
507516
sequence=0,
508517
fee=Decimal("0.2"),
509-
)["hex"]
518+
)
519+
tx1b_hex = tx1b_st["hex"]
510520

511-
# This will raise an exception
512-
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
521+
if fullrbf:
522+
self.nodes[0].sendrawtransaction(tx1b_hex, 0)
523+
tx1a_utxo = tx1b_st["new_utxo"]
524+
else:
525+
# This will raise an exception
526+
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
513527

514528
tx1_outpoint = self.make_utxo(self.nodes[0], int(1.1 * COIN))
515529

@@ -522,14 +536,19 @@ def test_opt_in(self):
522536
)["new_utxo"]
523537

524538
# Still shouldn't be able to double-spend
525-
tx2b_hex = self.wallet.create_self_transfer(
539+
tx2b_st = self.wallet.create_self_transfer(
526540
utxo_to_spend=tx1_outpoint,
527541
sequence=0,
528542
fee=Decimal("0.2"),
529-
)["hex"]
543+
)
544+
tx2b_hex = tx2b_st["hex"]
530545

531-
# This will raise an exception
532-
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx2b_hex, 0)
546+
if fullrbf:
547+
self.nodes[0].sendrawtransaction(tx2b_hex, 0)
548+
tx2a_utxo = tx2b_st["new_utxo"]
549+
else:
550+
# This will raise an exception
551+
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx2b_hex, 0)
533552

534553
# Now create a new transaction that spends from tx1a and tx2a
535554
# opt-in on one of the inputs
@@ -561,6 +580,8 @@ def test_opt_in(self):
561580
fee=Decimal("0.4"),
562581
)
563582

583+
self.generate(self.nodes[0], 1) # clean mempool
584+
564585
def test_prioritised_transactions(self):
565586
# Ensure that fee deltas used via prioritisetransaction are
566587
# correctly used by replacement logic

0 commit comments

Comments
 (0)