Skip to content

Commit a3f6397

Browse files
committed
test: feature_rbf.py: make MiniWallet instance available for all sub-tests
also document on why we start scanning blocks at height 76
1 parent 84c8747 commit a3f6397

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

test/functional/feature_rbf.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ def skip_test_if_missing_module(self):
8484
self.skip_if_no_wallet()
8585

8686
def run_test(self):
87+
self.wallet = MiniWallet(self.nodes[0])
88+
# the pre-mined test framework chain contains coinbase outputs to the
89+
# MiniWallet's default address ADDRESS_BCRT1_P2WSH_OP_TRUE in blocks
90+
# 76-100 (see method BitcoinTestFramework._initialize_chain())
91+
self.wallet.scan_blocks(start=76, num=1)
92+
8793
self.log.info("Running test simple doublespend...")
8894
self.test_simple_doublespend()
8995

@@ -569,20 +575,18 @@ def test_rpc(self):
569575
assert_equal(json1["vin"][0]["sequence"], 4294967294)
570576

571577
def test_no_inherited_signaling(self):
572-
wallet = MiniWallet(self.nodes[0])
573-
wallet.scan_blocks(start=76, num=1)
574-
confirmed_utxo = wallet.get_utxo()
578+
confirmed_utxo = self.wallet.get_utxo()
575579

576580
# Create an explicitly opt-in parent transaction
577-
optin_parent_tx = wallet.send_self_transfer(
581+
optin_parent_tx = self.wallet.send_self_transfer(
578582
from_node=self.nodes[0],
579583
utxo_to_spend=confirmed_utxo,
580584
sequence=BIP125_SEQUENCE_NUMBER,
581585
fee_rate=Decimal('0.01'),
582586
)
583587
assert_equal(True, self.nodes[0].getmempoolentry(optin_parent_tx['txid'])['bip125-replaceable'])
584588

585-
replacement_parent_tx = wallet.create_self_transfer(
589+
replacement_parent_tx = self.wallet.create_self_transfer(
586590
from_node=self.nodes[0],
587591
utxo_to_spend=confirmed_utxo,
588592
sequence=BIP125_SEQUENCE_NUMBER,
@@ -596,8 +600,8 @@ def test_no_inherited_signaling(self):
596600
assert_equal(res['allowed'], True)
597601

598602
# Create an opt-out child tx spending the opt-in parent
599-
parent_utxo = wallet.get_utxo(txid=optin_parent_tx['txid'])
600-
optout_child_tx = wallet.send_self_transfer(
603+
parent_utxo = self.wallet.get_utxo(txid=optin_parent_tx['txid'])
604+
optout_child_tx = self.wallet.send_self_transfer(
601605
from_node=self.nodes[0],
602606
utxo_to_spend=parent_utxo,
603607
sequence=0xffffffff,
@@ -607,7 +611,7 @@ def test_no_inherited_signaling(self):
607611
# Reports true due to inheritance
608612
assert_equal(True, self.nodes[0].getmempoolentry(optout_child_tx['txid'])['bip125-replaceable'])
609613

610-
replacement_child_tx = wallet.create_self_transfer(
614+
replacement_child_tx = self.wallet.create_self_transfer(
611615
from_node=self.nodes[0],
612616
utxo_to_spend=parent_utxo,
613617
sequence=0xffffffff,
@@ -626,9 +630,7 @@ def test_no_inherited_signaling(self):
626630
assert_raises_rpc_error(-26, 'txn-mempool-conflict', self.nodes[0].sendrawtransaction, replacement_child_tx["hex"], 0)
627631

628632
def test_replacement_relay_fee(self):
629-
wallet = MiniWallet(self.nodes[0])
630-
wallet.scan_blocks(start=77, num=1)
631-
tx = wallet.send_self_transfer(from_node=self.nodes[0])['tx']
633+
tx = self.wallet.send_self_transfer(from_node=self.nodes[0])['tx']
632634

633635
# Higher fee, higher feerate, different txid, but the replacement does not provide a relay
634636
# fee conforming to node's `incrementalrelayfee` policy of 1000 sat per KB.

0 commit comments

Comments
 (0)