mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 09:43:55 +02:00
Merge #21200: test: Speed up rpc_blockchain.py by removing miniwallet.generate()
faa137eb9etest: Speed up rpc_blockchain.py by removing miniwallet.generate() (MarcoFalke)fa1fe80c75test: Change address type from P2PKH to P2WSH in rpc_blockchain (MarcoFalke)fa4d8f3169test: Cache 25 mature coins for ADDRESS_BCRT1_P2WSH_OP_TRUE (MarcoFalke)fad25153f5test: Remove unused bug workaround (MarcoFalke)faabce7d07test: Start only the number of nodes that are needed (MarcoFalke) Pull request description: Speed up various tests: * Remove unused nodes, which only consume time on start/stop * Remove unused "bug workarounds" * Remove the need for `miniwallet.generate()` by adding `miniwallet.scan_blocks()`. (On my system, with valgrind, generating 105 blocks takes 3.31 seconds. Rescanning 5 blocks takes 0.11 seconds.) ACKs for top commit: laanwj: Code review ACKfaa137eb9eTree-SHA512: ead1988d5aaa748ef9f8520af1e0bf812cf1d72e281ad22fbd172b7306d850053040526f8adbcec0b9a971c697a0ee7ee8962684644d65b791663eedd505a025
This commit is contained in:
@@ -23,6 +23,7 @@ import http.client
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from test_framework.address import ADDRESS_BCRT1_P2WSH_OP_TRUE
|
||||
from test_framework.blocktools import (
|
||||
create_block,
|
||||
create_coinbase,
|
||||
@@ -71,11 +72,10 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
|
||||
def mine_chain(self):
|
||||
self.log.info('Create some old blocks')
|
||||
address = self.nodes[0].get_deterministic_priv_key().address
|
||||
for t in range(TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK + 200 * 600, 600):
|
||||
# ten-minute steps from genesis block time
|
||||
self.nodes[0].setmocktime(t)
|
||||
self.nodes[0].generatetoaddress(1, address)
|
||||
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_P2WSH_OP_TRUE)
|
||||
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 200)
|
||||
|
||||
def _test_getblockchaininfo(self):
|
||||
@@ -227,7 +227,7 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
assert_equal(res['transactions'], 200)
|
||||
assert_equal(res['height'], 200)
|
||||
assert_equal(res['txouts'], 200)
|
||||
assert_equal(res['bogosize'], 15000),
|
||||
assert_equal(res['bogosize'], 16800),
|
||||
assert_equal(res['bestblock'], node.getblockhash(200))
|
||||
size = res['disk_size']
|
||||
assert size > 6400
|
||||
@@ -332,12 +332,12 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
|
||||
def _test_stopatheight(self):
|
||||
assert_equal(self.nodes[0].getblockcount(), 200)
|
||||
self.nodes[0].generatetoaddress(6, self.nodes[0].get_deterministic_priv_key().address)
|
||||
self.nodes[0].generatetoaddress(6, ADDRESS_BCRT1_P2WSH_OP_TRUE)
|
||||
assert_equal(self.nodes[0].getblockcount(), 206)
|
||||
self.log.debug('Node should not stop at this height')
|
||||
assert_raises(subprocess.TimeoutExpired, lambda: self.nodes[0].process.wait(timeout=3))
|
||||
try:
|
||||
self.nodes[0].generatetoaddress(1, self.nodes[0].get_deterministic_priv_key().address)
|
||||
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_P2WSH_OP_TRUE)
|
||||
except (ConnectionError, http.client.BadStatusLine):
|
||||
pass # The node already shut down before response
|
||||
self.log.debug('Node should stop at this height...')
|
||||
@@ -387,8 +387,7 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
node = self.nodes[0]
|
||||
|
||||
miniwallet = MiniWallet(node)
|
||||
miniwallet.generate(5)
|
||||
node.generate(100)
|
||||
miniwallet.scan_blocks(num=5)
|
||||
|
||||
fee_per_byte = Decimal('0.00000010')
|
||||
fee_per_kb = 1000 * fee_per_byte
|
||||
|
||||
Reference in New Issue
Block a user