Skip to content

Commit 587cbca

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23873: test: use MiniWallet for p2p_compactblocks.py
d2efb66 test: use MiniWallet for p2p_compactblocks.py (Sebastian Falbesoner) Pull request description: This PR enables one more of the non-wallet functional tests (p2p_compactblocks.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in #20078. The wallet RPCs calls (`getnewaddress`/`sendtoaddress`) can easily be substituted by generating/sending to the MiniWallet's internal address instead (`self.generate(self.wallet, ...)`/`self.wallet.send_self_transfer(...)`). ACKs for top commit: josibake: ACK bitcoin/bitcoin@d2efb66 brunoerg: tACK d2efb66 Tree-SHA512: 25340d95199ffd1fa734231c22b7710aad1ed4cda78c8c533c19cea90dc4eab65832f043d20e4fc5c0869692b1f300ad79af4e7fd3c4af8f2578ac9ccbbc9aeb
2 parents 1292334 + d2efb66 commit 587cbca

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

test/functional/p2p_compactblocks.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
assert_equal,
6666
softfork_active,
6767
)
68+
from test_framework.wallet import MiniWallet
69+
6870

6971
# TestP2PConn: A peer we use to send messages to bitcoind, and store responses.
7072
class TestP2PConn(P2PInterface):
@@ -150,9 +152,6 @@ def set_test_params(self):
150152
]]
151153
self.utxos = []
152154

153-
def skip_test_if_missing_module(self):
154-
self.skip_if_no_wallet()
155-
156155
def build_block_on_tip(self, node, segwit=False):
157156
block = create_block(tmpl=node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS))
158157
if segwit:
@@ -165,7 +164,7 @@ def make_utxos(self):
165164
block = self.build_block_on_tip(self.nodes[0])
166165
self.segwit_node.send_and_ping(msg_no_witness_block(block))
167166
assert int(self.nodes[0].getbestblockhash(), 16) == block.sha256
168-
self.generatetoaddress(self.nodes[0], COINBASE_MATURITY, self.nodes[0].getnewaddress(address_type="bech32"))
167+
self.generate(self.wallet, COINBASE_MATURITY)
169168

170169
total_value = block.vtx[0].vout[0].nValue
171170
out_value = total_value // 10
@@ -296,12 +295,10 @@ def test_compactblock_construction(self, test_node, use_witness_address=True):
296295
# Generate a bunch of transactions.
297296
self.generate(node, COINBASE_MATURITY + 1)
298297
num_transactions = 25
299-
address = node.getnewaddress()
300298

301299
segwit_tx_generated = False
302300
for _ in range(num_transactions):
303-
txid = node.sendtoaddress(address, 0.1)
304-
hex_tx = node.gettransaction(txid)["hex"]
301+
hex_tx = self.wallet.send_self_transfer(from_node=self.nodes[0])['hex']
305302
tx = tx_from_hex(hex_tx)
306303
if not tx.wit.is_null():
307304
segwit_tx_generated = True
@@ -843,8 +840,7 @@ def assert_highbandwidth_states(node, hb_to, hb_from):
843840
assert_highbandwidth_states(self.nodes[0], hb_to=True, hb_from=False)
844841

845842
def run_test(self):
846-
# Get the nodes out of IBD
847-
self.generate(self.nodes[0], 1)
843+
self.wallet = MiniWallet(self.nodes[0])
848844

849845
# Setup the p2p connections
850846
self.segwit_node = self.nodes[0].add_p2p_connection(TestP2PConn(cmpct_version=2))

0 commit comments

Comments
 (0)