Skip to content

Commit fa7e3f1

Browse files
author
MarcoFalke
committed
test: Replace MiniWallet scan_blocks with rescan_utxos
1 parent 226731a commit fa7e3f1

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

test/functional/feature_rbf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run_test(self):
4646
# the pre-mined test framework chain contains coinbase outputs to the
4747
# MiniWallet's default address ADDRESS_BCRT1_P2WSH_OP_TRUE in blocks
4848
# 76-100 (see method BitcoinTestFramework._initialize_chain())
49-
self.wallet.scan_blocks(start=76, num=2)
49+
self.wallet.rescan_utxos()
5050

5151
self.log.info("Running test simple doublespend...")
5252
self.test_simple_doublespend()

test/functional/mempool_reorg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def run_test(self):
3131
self.log.info("Add 4 coinbase utxos to the miniwallet")
3232
# Block 76 contains the first spendable coinbase txs.
3333
first_block = 76
34-
wallet.scan_blocks(start=first_block, num=4)
34+
wallet.rescan_utxos()
3535

3636
# Three scenarios for re-orging coinbase spends in the memory pool:
3737
# 1. Direct coinbase spend : spend_1

test/functional/mempool_spend_coinbase.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ def run_test(self):
2828
chain_height = 198
2929
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(chain_height + 1))
3030
assert_equal(chain_height, self.nodes[0].getblockcount())
31+
wallet.rescan_utxos()
3132

3233
# Coinbase at height chain_height-100+1 ok in mempool, should
3334
# get mined. Coinbase at height chain_height-100+2 is
3435
# too immature to spend.
35-
wallet.scan_blocks(start=chain_height - 100 + 1, num=1)
36-
utxo_mature = wallet.get_utxo()
37-
wallet.scan_blocks(start=chain_height - 100 + 2, num=1)
38-
utxo_immature = wallet.get_utxo()
36+
coinbase_txid = lambda h: self.nodes[0].getblock(self.nodes[0].getblockhash(h))['tx'][0]
37+
utxo_mature = wallet.get_utxo(txid=coinbase_txid(chain_height - 100 + 1))
38+
utxo_immature = wallet.get_utxo(txid=coinbase_txid(chain_height - 100 + 2))
3939

4040
spend_mature_id = wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo_mature)["txid"]
4141

test/functional/rpc_blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def _test_getblock(self):
406406
node = self.nodes[0]
407407

408408
miniwallet = MiniWallet(node)
409-
miniwallet.scan_blocks(num=5)
409+
miniwallet.rescan_utxos()
410410

411411
fee_per_byte = Decimal('0.00000010')
412412
fee_per_kb = 1000 * fee_per_byte

test/functional/test_framework/wallet.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@ def rescan_utxos(self):
8787
for utxo in res['unspents']:
8888
self._utxos.append({'txid': utxo['txid'], 'vout': utxo['vout'], 'value': utxo['amount']})
8989

90-
def scan_blocks(self, *, start=1, num):
91-
"""Scan the blocks for self._address outputs and add them to self._utxos"""
92-
for i in range(start, start + num):
93-
block = self._test_node.getblock(blockhash=self._test_node.getblockhash(i), verbosity=2)
94-
for tx in block['tx']:
95-
self.scan_tx(tx)
96-
9790
def scan_tx(self, tx):
9891
"""Scan the tx for self._scriptPubKey outputs and add them to self._utxos"""
9992
for out in tx['vout']:

0 commit comments

Comments
 (0)