Skip to content

Commit faa137e

Browse files
author
MarcoFalke
committed
test: Speed up rpc_blockchain.py by removing miniwallet.generate()
1 parent fa1fe80 commit faa137e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

test/functional/rpc_blockchain.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ def _test_getblock(self):
384384
node = self.nodes[0]
385385

386386
miniwallet = MiniWallet(node)
387-
miniwallet.generate(5)
388-
node.generate(100)
387+
miniwallet.scan_blocks(num=5)
389388

390389
fee_per_byte = Decimal('0.00000010')
391390
fee_per_kb = 1000 * fee_per_byte

test/functional/test_framework/wallet.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ def __init__(self, test_node):
3232
self._address = ADDRESS_BCRT1_P2WSH_OP_TRUE
3333
self._scriptPubKey = hex_str_to_bytes(self._test_node.validateaddress(self._address)['scriptPubKey'])
3434

35+
def scan_blocks(self, *, start=1, num):
36+
"""Scan the blocks for self._address outputs and add them to self._utxos"""
37+
for i in range(start, start + num):
38+
block = self._test_node.getblock(blockhash=self._test_node.getblockhash(i), verbosity=2)
39+
for tx in block['tx']:
40+
for out in tx['vout']:
41+
if out['scriptPubKey']['hex'] == self._scriptPubKey.hex():
42+
self._utxos.append({'txid': tx['txid'], 'vout': out['n'], 'value': out['value']})
43+
3544
def generate(self, num_blocks):
3645
"""Generate blocks with coinbase outputs to the internal address, and append the outputs to the internal list"""
3746
blocks = self._test_node.generatetoaddress(num_blocks, self._address)

0 commit comments

Comments
 (0)