@@ -25,7 +25,7 @@ def add_options(self, parser):
25
25
self .add_wallet_options (parser )
26
26
27
27
def set_test_params (self ):
28
- self .num_nodes = 3
28
+ self .num_nodes = 4
29
29
# both nodes disable full-rbf to test BIP125 signaling
30
30
self .extra_args = [
31
31
[
@@ -44,6 +44,12 @@ def set_test_params(self):
44
44
"-mempoolreplacement=0" ,
45
45
],
46
46
]
47
+ self .extra_args .append (
48
+ [
49
+ * self .extra_args [0 ],
50
+ "-mempoolreplacement=fee,-optin" ,
51
+ ],
52
+ )
47
53
self .supports_cli = False
48
54
49
55
def run_test (self ):
@@ -74,7 +80,10 @@ def run_test(self):
74
80
self .test_too_many_replacements_with_default_mempool_params ()
75
81
76
82
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 ]
78
87
79
88
self .log .info ("Running test RPC..." )
80
89
self .test_rpc ()
@@ -486,7 +495,7 @@ def test_too_many_replacements_with_default_mempool_params(self):
486
495
self .generate (normal_node , 1 )
487
496
self .wallet .rescan_utxos ()
488
497
489
- def test_opt_in (self ):
498
+ def test_opt_in (self , fullrbf ):
490
499
"""Replacing should only work if orig tx opted in"""
491
500
tx0_outpoint = self .make_utxo (self .nodes [0 ], int (1.1 * COIN ))
492
501
@@ -502,14 +511,19 @@ def test_opt_in(self):
502
511
assert_equal (self .nodes [0 ].getmempoolentry (tx1a_utxo ["txid" ])['bip125-replaceable' ], False )
503
512
504
513
# Shouldn't be able to double-spend
505
- tx1b_hex = self .wallet .create_self_transfer (
514
+ tx1b_st = self .wallet .create_self_transfer (
506
515
utxo_to_spend = tx0_outpoint ,
507
516
sequence = 0 ,
508
517
fee = Decimal ("0.2" ),
509
- )["hex" ]
518
+ )
519
+ tx1b_hex = tx1b_st ["hex" ]
510
520
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 )
513
527
514
528
tx1_outpoint = self .make_utxo (self .nodes [0 ], int (1.1 * COIN ))
515
529
@@ -522,14 +536,19 @@ def test_opt_in(self):
522
536
)["new_utxo" ]
523
537
524
538
# Still shouldn't be able to double-spend
525
- tx2b_hex = self .wallet .create_self_transfer (
539
+ tx2b_st = self .wallet .create_self_transfer (
526
540
utxo_to_spend = tx1_outpoint ,
527
541
sequence = 0 ,
528
542
fee = Decimal ("0.2" ),
529
- )["hex" ]
543
+ )
544
+ tx2b_hex = tx2b_st ["hex" ]
530
545
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 )
533
552
534
553
# Now create a new transaction that spends from tx1a and tx2a
535
554
# opt-in on one of the inputs
@@ -561,6 +580,8 @@ def test_opt_in(self):
561
580
fee = Decimal ("0.4" ),
562
581
)
563
582
583
+ self .generate (self .nodes [0 ], 1 ) # clean mempool
584
+
564
585
def test_prioritised_transactions (self ):
565
586
# Ensure that fee deltas used via prioritisetransaction are
566
587
# correctly used by replacement logic
0 commit comments