mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
test: Replace MiniWallet scan_blocks with rescan_utxos
This commit is contained in:
parent
226731ac11
commit
fa7e3f1fc1
5 changed files with 7 additions and 14 deletions
|
@ -46,7 +46,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
|||
# the pre-mined test framework chain contains coinbase outputs to the
|
||||
# MiniWallet's default address ADDRESS_BCRT1_P2WSH_OP_TRUE in blocks
|
||||
# 76-100 (see method BitcoinTestFramework._initialize_chain())
|
||||
self.wallet.scan_blocks(start=76, num=2)
|
||||
self.wallet.rescan_utxos()
|
||||
|
||||
self.log.info("Running test simple doublespend...")
|
||||
self.test_simple_doublespend()
|
||||
|
|
|
@ -31,7 +31,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
|
|||
self.log.info("Add 4 coinbase utxos to the miniwallet")
|
||||
# Block 76 contains the first spendable coinbase txs.
|
||||
first_block = 76
|
||||
wallet.scan_blocks(start=first_block, num=4)
|
||||
wallet.rescan_utxos()
|
||||
|
||||
# Three scenarios for re-orging coinbase spends in the memory pool:
|
||||
# 1. Direct coinbase spend : spend_1
|
||||
|
|
|
@ -28,14 +28,14 @@ class MempoolSpendCoinbaseTest(BitcoinTestFramework):
|
|||
chain_height = 198
|
||||
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(chain_height + 1))
|
||||
assert_equal(chain_height, self.nodes[0].getblockcount())
|
||||
wallet.rescan_utxos()
|
||||
|
||||
# Coinbase at height chain_height-100+1 ok in mempool, should
|
||||
# get mined. Coinbase at height chain_height-100+2 is
|
||||
# too immature to spend.
|
||||
wallet.scan_blocks(start=chain_height - 100 + 1, num=1)
|
||||
utxo_mature = wallet.get_utxo()
|
||||
wallet.scan_blocks(start=chain_height - 100 + 2, num=1)
|
||||
utxo_immature = wallet.get_utxo()
|
||||
coinbase_txid = lambda h: self.nodes[0].getblock(self.nodes[0].getblockhash(h))['tx'][0]
|
||||
utxo_mature = wallet.get_utxo(txid=coinbase_txid(chain_height - 100 + 1))
|
||||
utxo_immature = wallet.get_utxo(txid=coinbase_txid(chain_height - 100 + 2))
|
||||
|
||||
spend_mature_id = wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo_mature)["txid"]
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
node = self.nodes[0]
|
||||
|
||||
miniwallet = MiniWallet(node)
|
||||
miniwallet.scan_blocks(num=5)
|
||||
miniwallet.rescan_utxos()
|
||||
|
||||
fee_per_byte = Decimal('0.00000010')
|
||||
fee_per_kb = 1000 * fee_per_byte
|
||||
|
|
|
@ -87,13 +87,6 @@ class MiniWallet:
|
|||
for utxo in res['unspents']:
|
||||
self._utxos.append({'txid': utxo['txid'], 'vout': utxo['vout'], 'value': utxo['amount']})
|
||||
|
||||
def scan_blocks(self, *, start=1, num):
|
||||
"""Scan the blocks for self._address outputs and add them to self._utxos"""
|
||||
for i in range(start, start + num):
|
||||
block = self._test_node.getblock(blockhash=self._test_node.getblockhash(i), verbosity=2)
|
||||
for tx in block['tx']:
|
||||
self.scan_tx(tx)
|
||||
|
||||
def scan_tx(self, tx):
|
||||
"""Scan the tx for self._scriptPubKey outputs and add them to self._utxos"""
|
||||
for out in tx['vout']:
|
||||
|
|
Loading…
Reference in a new issue