mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#22741: Add generate* calls to test framework
This commit is contained in:
parent
9938f4438d
commit
c17fd8bc59
@ -217,7 +217,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
|
||||
|
||||
# Start by creating a lot of utxos on node3
|
||||
initial_height = self.nodes[3].getblockcount()
|
||||
utxo_list = create_confirmed_utxos(self.nodes[3].getnetworkinfo()['relayfee'], self.nodes[3], 5000)
|
||||
utxo_list = create_confirmed_utxos(self, self.nodes[3].getnetworkinfo()['relayfee'], self.nodes[3], 5000)
|
||||
self.log.info("Prepped %d utxo entries", len(utxo_list))
|
||||
|
||||
# Sync these blocks with the other nodes
|
||||
@ -253,7 +253,8 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
|
||||
self.log.debug("Mining longer tip")
|
||||
block_hashes = []
|
||||
while current_height + 1 > self.nodes[3].getblockcount():
|
||||
block_hashes.extend(self.nodes[3].generatetoaddress(
|
||||
block_hashes.extend(self.generatetoaddress(
|
||||
self.nodes[3],
|
||||
nblocks=min(10, current_height + 1 - self.nodes[3].getblockcount()),
|
||||
# new address to avoid mining a block that has just been invalidated
|
||||
address=self.nodes[3].getnewaddress(),
|
||||
|
@ -193,7 +193,7 @@ class DashGovernanceTest (DashTestFramework):
|
||||
isolated = self.nodes[payee_idx]
|
||||
|
||||
self.log.info("Move 1 block inside the Superblock maturity window on the isolated node")
|
||||
isolated.generate(1)
|
||||
self.generate(isolated, 1)
|
||||
self.bump_mocktime(1)
|
||||
self.log.info("The isolated 'winner' should submit new trigger and vote for it")
|
||||
self.wait_until(lambda: len(isolated.gobject("list", "valid", "triggers")) == 1, timeout=5)
|
||||
|
@ -71,7 +71,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||
p2p_conns.append(self.nodes[0].add_p2p_connection(TestP2PConn()))
|
||||
|
||||
# Now mine a big block
|
||||
mine_large_block(self.nodes[0], self.utxo_cache)
|
||||
mine_large_block(self, self.nodes[0], self.utxo_cache)
|
||||
|
||||
# Store the hash; we'll request this later
|
||||
big_old_block = self.nodes[0].getbestblockhash()
|
||||
@ -82,7 +82,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||
self.nodes[0].setmocktime(current_mocktime - 2*60*60*24)
|
||||
|
||||
# Mine one more block, so that the prior block looks old
|
||||
mine_large_block(self.nodes[0], self.utxo_cache)
|
||||
mine_large_block(self, self.nodes[0], self.utxo_cache)
|
||||
|
||||
# We'll be requesting this new block too
|
||||
big_new_block = self.nodes[0].getbestblockhash()
|
||||
|
@ -78,8 +78,8 @@ class ZMQTestSetupBlock:
|
||||
raw transaction data.
|
||||
"""
|
||||
|
||||
def __init__(self, node):
|
||||
self.block_hash = node.generate(1)[0]
|
||||
def __init__(self, test_framework, node):
|
||||
self.block_hash = test_framework.generate(node, 1)[0]
|
||||
coinbase = node.getblock(self.block_hash, 2)['tx'][0]
|
||||
self.tx_hash = coinbase['txid']
|
||||
self.raw_tx = coinbase['hex']
|
||||
@ -149,7 +149,7 @@ class ZMQTest (BitcoinTestFramework):
|
||||
for sub in subscribers:
|
||||
sub.socket.set(zmq.RCVTIMEO, 1000)
|
||||
while True:
|
||||
test_block = ZMQTestSetupBlock(self.nodes[0])
|
||||
test_block = ZMQTestSetupBlock(self, self.nodes[0])
|
||||
recv_failed = False
|
||||
for sub in subscribers:
|
||||
try:
|
||||
|
@ -32,7 +32,7 @@ class MempoolLimitTest(BitcoinTestFramework):
|
||||
assert_equal(self.nodes[0].getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))
|
||||
|
||||
txids = []
|
||||
utxos = create_confirmed_utxos(relayfee, self.nodes[0], 491)
|
||||
utxos = create_confirmed_utxos(self, relayfee, self.nodes[0], 491)
|
||||
|
||||
self.log.info('Create a mempool tx that will be evicted')
|
||||
us0 = utxos.pop()
|
||||
|
@ -32,7 +32,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
|
||||
node = self.nodes[0]
|
||||
|
||||
min_relay_fee = node.getnetworkinfo()["relayfee"]
|
||||
utxos = create_confirmed_utxos(min_relay_fee, node, 10)
|
||||
utxos = create_confirmed_utxos(self, min_relay_fee, node, 10)
|
||||
|
||||
self.disconnect_nodes(0, 1)
|
||||
|
||||
|
@ -47,9 +47,9 @@ class GetBlockTemplateLPTest(BitcoinTestFramework):
|
||||
thr.join(5) # wait 5 seconds or until thread exits
|
||||
assert thr.is_alive()
|
||||
|
||||
miniwallets = [ MiniWallet(node) for node in self.nodes ]
|
||||
miniwallets = [MiniWallet(node) for node in self.nodes]
|
||||
self.log.info("Test that longpoll will terminate if another node generates a block")
|
||||
miniwallets[1].generate(1) # generate a block on another node
|
||||
self.generate(miniwallets[1], 1) # generate a block on another node
|
||||
# check that thread will exit now that new transaction entered mempool
|
||||
thr.join(5) # wait 5 seconds or until thread exits
|
||||
assert not thr.is_alive()
|
||||
@ -57,7 +57,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework):
|
||||
self.log.info("Test that longpoll will terminate if we generate a block ourselves")
|
||||
thr = LongpollThread(self.nodes[0])
|
||||
thr.start()
|
||||
miniwallets[0].generate(1) # generate a block on own node
|
||||
self.generate(miniwallets[0], 1) # generate a block on own node
|
||||
thr.join(5) # wait 5 seconds or until thread exits
|
||||
assert not thr.is_alive()
|
||||
|
||||
|
@ -42,7 +42,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
||||
self.relayfee = self.nodes[0].getnetworkinfo()['relayfee']
|
||||
|
||||
utxo_count = 90
|
||||
utxos = create_confirmed_utxos(self.relayfee, self.nodes[0], utxo_count)
|
||||
utxos = create_confirmed_utxos(self, self.relayfee, self.nodes[0], utxo_count)
|
||||
base_fee = self.relayfee*100 # our transactions are smaller than 100kb
|
||||
txids = []
|
||||
|
||||
|
@ -67,11 +67,11 @@ class InstantSendTest(DashTestFramework):
|
||||
dblspnd_txid = isolated.sendrawtransaction(dblspnd_tx['hex'])
|
||||
# generate block on isolated node with doublespend transaction
|
||||
self.bump_mocktime(599)
|
||||
wrong_early_block = isolated.generate(1)[0]
|
||||
wrong_early_block = self.generate(isolated, 1)[0]
|
||||
assert not "confirmation" in isolated.getrawtransaction(dblspnd_txid, 1)
|
||||
isolated.invalidateblock(wrong_early_block)
|
||||
self.bump_mocktime(1)
|
||||
wrong_block = isolated.generate(1)[0]
|
||||
wrong_block = self.generate(isolated, 1)[0]
|
||||
assert_equal(isolated.getrawtransaction(dblspnd_txid, 1)["confirmations"], 1)
|
||||
# connect isolated block to network
|
||||
self.reconnect_isolated_node(self.isolated_idx, 0)
|
||||
|
@ -73,7 +73,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
min_work_node = self.nodes[1].add_p2p_connection(P2PInterface())
|
||||
|
||||
# 1. Have nodes mine a block (leave IBD)
|
||||
[n.generatetoaddress(1, n.get_deterministic_priv_key().address) for n in self.nodes]
|
||||
[self.generatetoaddress(n, 1, n.get_deterministic_priv_key().address) for n in self.nodes]
|
||||
tips = [int("0x" + n.getbestblockhash(), 0) for n in self.nodes]
|
||||
|
||||
# 2. Send one block that builds on each tip.
|
||||
|
@ -455,7 +455,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
if not self.disable_mocktime:
|
||||
self.log.debug('Generate a block with current mocktime')
|
||||
self.bump_mocktime(156 * 200, update_schedulers=False)
|
||||
block_hash = self.nodes[0].generate(1)[0]
|
||||
block_hash = self.generate(self.nodes[0], 1)[0]
|
||||
block = self.nodes[0].getblock(blockhash=block_hash, verbosity=0)
|
||||
for n in self.nodes:
|
||||
n.submitblock(block)
|
||||
@ -766,6 +766,22 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
self.connect_nodes(1, 2)
|
||||
self.sync_all()
|
||||
|
||||
def generate(self, generator, *args, **kwargs):
|
||||
blocks = generator.generate(*args, **kwargs)
|
||||
return blocks
|
||||
|
||||
def generateblock(self, generator, *args, **kwargs):
|
||||
blocks = generator.generateblock(*args, **kwargs)
|
||||
return blocks
|
||||
|
||||
def generatetoaddress(self, generator, *args, **kwargs):
|
||||
blocks = generator.generatetoaddress(*args, **kwargs)
|
||||
return blocks
|
||||
|
||||
def generatetodescriptor(self, generator, *args, **kwargs):
|
||||
blocks = generator.generatetodescriptor(*args, **kwargs)
|
||||
return blocks
|
||||
|
||||
def sync_blocks(self, nodes=None, wait=1, timeout=60):
|
||||
"""
|
||||
Wait until everybody has the same tip.
|
||||
@ -932,7 +948,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
assert_equal(len(gen_addresses), 4)
|
||||
for i in range(8):
|
||||
self.bump_mocktime((25 if i != 7 else 24) * 156, update_schedulers=False)
|
||||
cache_node.generatetoaddress(
|
||||
self.generatetoaddress(
|
||||
cache_node,
|
||||
nblocks=25 if i != 7 else 24,
|
||||
address=gen_addresses[i % len(gen_addresses)],
|
||||
)
|
||||
@ -1161,22 +1178,22 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
# Hence the last block prior to the activation is (expected_activation_height - 2).
|
||||
while expected_activation_height - height - 2 > batch_size:
|
||||
self.bump_mocktime(batch_size)
|
||||
self.nodes[0].generate(batch_size)
|
||||
self.generate(self.nodes[0], batch_size)
|
||||
height += batch_size
|
||||
self.sync_blocks()
|
||||
blocks_left = expected_activation_height - height - 2
|
||||
assert blocks_left <= batch_size
|
||||
self.bump_mocktime(blocks_left)
|
||||
self.nodes[0].generate(blocks_left)
|
||||
self.generate(self.nodes[0], blocks_left)
|
||||
self.sync_blocks()
|
||||
assert not softfork_active(self.nodes[0], name)
|
||||
self.bump_mocktime(1)
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks()
|
||||
else:
|
||||
while not softfork_active(self.nodes[0], name):
|
||||
self.bump_mocktime(batch_size)
|
||||
self.nodes[0].generate(batch_size)
|
||||
self.generate(self.nodes[0], batch_size)
|
||||
self.sync_blocks()
|
||||
|
||||
assert softfork_active(self.nodes[0], name)
|
||||
@ -1265,7 +1282,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
outputs = {collateral_address: collateral_amount, funds_address: 1}
|
||||
collateral_txid = self.nodes[0].sendmany("", outputs)
|
||||
self.wait_for_instantlock(collateral_txid, self.nodes[0])
|
||||
tip = self.nodes[0].generate(1)[0]
|
||||
tip = self.generate(self.nodes[0], 1)[0]
|
||||
self.sync_all(self.nodes)
|
||||
|
||||
rawtx = self.nodes[0].getrawtransaction(collateral_txid, 1, tip)
|
||||
@ -1287,7 +1304,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
protx_result = self.nodes[0].protx("register", collateral_txid, collateral_vout, ipAndPort, owner_address, bls['public'], voting_address, operatorReward, reward_address, funds_address, True)
|
||||
|
||||
self.wait_for_instantlock(protx_result, self.nodes[0])
|
||||
tip = self.nodes[0].generate(1)[0]
|
||||
tip = self.generate(self.nodes[0], 1)[0]
|
||||
self.sync_all(self.nodes)
|
||||
|
||||
assert_equal(self.nodes[0].getrawtransaction(protx_result, 1, tip)['confirmations'], 1)
|
||||
@ -1310,7 +1327,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
|
||||
fund_txid = self.nodes[0].sendtoaddress(funds_address, 1)
|
||||
self.wait_for_instantlock(fund_txid, self.nodes[0])
|
||||
tip = self.nodes[0].generate(1)[0]
|
||||
tip = self.generate(self.nodes[0], 1)[0]
|
||||
assert_equal(self.nodes[0].getrawtransaction(fund_txid, 1, tip)['confirmations'], 1)
|
||||
self.sync_all(self.nodes)
|
||||
|
||||
@ -1318,7 +1335,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
try:
|
||||
protx_result = self.nodes[0].protx('update_service_evo', evo_info.proTxHash, evo_info.addr, evo_info.keyOperator, platform_node_id, platform_p2p_port, platform_http_port, operator_reward_address, funds_address)
|
||||
self.wait_for_instantlock(protx_result, self.nodes[0])
|
||||
tip = self.nodes[0].generate(1)[0]
|
||||
tip = self.generate(self.nodes[0], 1)[0]
|
||||
assert_equal(self.nodes[0].getrawtransaction(protx_result, 1, tip)['confirmations'], 1)
|
||||
self.sync_all(self.nodes)
|
||||
self.log.info("Updated EvoNode %s: platformNodeID=%s, platformP2PPort=%s, platformHTTPPort=%s" % (evo_info.proTxHash, platform_node_id, platform_p2p_port, platform_http_port))
|
||||
@ -1369,7 +1386,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
if register_fund:
|
||||
protx_result = self.nodes[0].protx('register_fund', address, ipAndPort, ownerAddr, bls['public'], votingAddr, operatorReward, rewardsAddr, address, submit)
|
||||
else:
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
protx_result = self.nodes[0].protx('register', txid, collateral_vout, ipAndPort, ownerAddr, bls['public'], votingAddr, operatorReward, rewardsAddr, address, submit)
|
||||
|
||||
if submit:
|
||||
@ -1378,7 +1395,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
proTxHash = self.nodes[0].sendrawtransaction(protx_result)
|
||||
|
||||
if operatorReward > 0:
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
operatorPayoutAddress = self.nodes[0].getnewaddress()
|
||||
self.nodes[0].protx('update_service', proTxHash, ipAndPort, bls['secret'], operatorPayoutAddress, address)
|
||||
|
||||
@ -1391,7 +1408,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
rawtx = self.nodes[0].createrawtransaction([{"txid": mn.collateral_txid, "vout": mn.collateral_vout}], {self.nodes[0].getnewaddress(): 999.9999})
|
||||
rawtx = self.nodes[0].signrawtransactionwithwallet(rawtx)
|
||||
self.nodes[0].sendrawtransaction(rawtx["hex"])
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_all()
|
||||
self.mninfo.remove(mn)
|
||||
|
||||
@ -1470,7 +1487,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
self.log.info("Generating %d coins" % required_balance)
|
||||
while self.nodes[0].getbalance() < required_balance:
|
||||
self.bump_mocktime(1)
|
||||
self.nodes[0].generate(10)
|
||||
self.generate(self.nodes[0], 10)
|
||||
|
||||
# create masternodes
|
||||
self.prepare_masternodes()
|
||||
@ -1488,7 +1505,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
self.start_masternodes()
|
||||
|
||||
self.bump_mocktime(1)
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
# sync nodes
|
||||
self.sync_all()
|
||||
for i in range(0, num_simple_nodes):
|
||||
@ -1763,7 +1780,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
if quorum_hash in self.nodes[0].quorum("list")[llmq_type_name]:
|
||||
return True
|
||||
self.bump_mocktime(sleep, nodes=nodes)
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(nodes)
|
||||
return False
|
||||
wait_until_helper(wait_func, timeout=timeout, sleep=sleep)
|
||||
@ -1775,14 +1792,14 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
if quorum_hash_1 in self.nodes[0].quorum("list")[llmq_type_name]:
|
||||
return True
|
||||
self.bump_mocktime(sleep, nodes=nodes)
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(nodes)
|
||||
return False
|
||||
wait_until_helper(wait_func, timeout=timeout, sleep=sleep)
|
||||
|
||||
def move_blocks(self, nodes, num_blocks):
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.nodes[0].generate(num_blocks)
|
||||
self.generate(self.nodes[0], num_blocks)
|
||||
self.sync_blocks(nodes)
|
||||
|
||||
def mine_quorum(self, llmq_type_name="llmq_test", llmq_type=100, expected_connections=None, expected_members=None, expected_contributions=None, expected_complaints=0, expected_justifications=0, expected_commitments=None, mninfos_online=None, mninfos_valid=None):
|
||||
@ -1812,7 +1829,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
skip_count = 24 - (self.nodes[0].getblockcount() % 24)
|
||||
if skip_count != 0:
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.nodes[0].generate(skip_count)
|
||||
self.generate(self.nodes[0], skip_count)
|
||||
self.sync_blocks(nodes)
|
||||
|
||||
q = self.nodes[0].getbestblockhash()
|
||||
@ -1854,7 +1871,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
self.log.info("Mining final commitment")
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.nodes[0].getblocktemplate() # this calls CreateNewBlock
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(nodes)
|
||||
|
||||
self.log.info("Waiting for quorum to appear in the list")
|
||||
@ -1865,7 +1882,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
quorum_info = self.nodes[0].quorum("info", llmq_type, new_quorum)
|
||||
|
||||
# Mine 8 (SIGN_HEIGHT_OFFSET) more blocks to make sure that the new quorum gets eligible for signing sessions
|
||||
self.nodes[0].generate(8)
|
||||
self.generate(self.nodes[0], 8)
|
||||
|
||||
self.sync_blocks(nodes)
|
||||
|
||||
@ -1975,7 +1992,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
self.log.info("Mining final commitments")
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.nodes[0].getblocktemplate() # this calls CreateNewBlock
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(nodes)
|
||||
|
||||
self.log.info("Waiting for quorum(s) to appear in the list")
|
||||
@ -1984,7 +2001,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
quorum_info_0 = self.nodes[0].quorum("info", llmq_type, q_0)
|
||||
quorum_info_1 = self.nodes[0].quorum("info", llmq_type, q_1)
|
||||
# Mine 8 (SIGN_HEIGHT_OFFSET) more blocks to make sure that the new quorum gets eligible for signing sessions
|
||||
self.nodes[0].generate(8)
|
||||
self.generate(self.nodes[0], 8)
|
||||
|
||||
self.sync_blocks(nodes)
|
||||
self.log.info("New quorum: height=%d, quorumHash=%s, quorumIndex=%d, minedBlock=%s" % (quorum_info_0["height"], q_0, quorum_info_0["quorumIndex"], quorum_info_0["minedBlock"]))
|
||||
@ -2010,7 +2027,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
skip_count = cycle_length - (cur_block % cycle_length)
|
||||
if skip_count != 0:
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.nodes[0].generate(skip_count)
|
||||
self.generate(self.nodes[0], skip_count)
|
||||
self.sync_blocks(nodes)
|
||||
self.log.info('Moved from block %d to %d' % (cur_block, self.nodes[0].getblockcount()))
|
||||
|
||||
@ -2072,7 +2089,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
if recover:
|
||||
if self.mocktime % 2:
|
||||
self.bump_mocktime(self.quorum_data_request_expiration_timeout + 1)
|
||||
self.nodes[0].generate(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks()
|
||||
else:
|
||||
self.bump_mocktime(self.quorum_data_thread_request_timeout_seconds + 1)
|
||||
|
@ -514,10 +514,10 @@ def find_output(node, txid, amount, *, blockhash=None):
|
||||
|
||||
# Helper to create at least "count" utxos
|
||||
# Pass in a fee that is sufficient for relay and mining new transactions.
|
||||
def create_confirmed_utxos(fee, node, count):
|
||||
def create_confirmed_utxos(test_framework, fee, node, count):
|
||||
to_generate = int(0.5 * count) + 101
|
||||
while to_generate > 0:
|
||||
node.generate(min(25, to_generate))
|
||||
test_framework.generate(node, min(25, to_generate))
|
||||
to_generate -= 25
|
||||
utxos = node.listunspent()
|
||||
iterations = count - len(utxos)
|
||||
@ -538,7 +538,7 @@ def create_confirmed_utxos(fee, node, count):
|
||||
node.sendrawtransaction(signed_tx)
|
||||
|
||||
while (node.getmempoolinfo()['size'] > 0):
|
||||
node.generate(1)
|
||||
test_framework.generate(node, 1)
|
||||
|
||||
utxos = node.listunspent()
|
||||
assert len(utxos) >= count
|
||||
@ -610,7 +610,7 @@ def create_lots_of_big_transactions(node, txouts, utxos, num, fee):
|
||||
return txids
|
||||
|
||||
|
||||
def mine_large_block(node, utxos=None):
|
||||
def mine_large_block(test_framework, node, utxos=None):
|
||||
# generate a 66k transaction,
|
||||
# and 14 of them is close to the 1MB block limit
|
||||
num = 14
|
||||
@ -621,17 +621,17 @@ def mine_large_block(node, utxos=None):
|
||||
utxos.extend(node.listunspent())
|
||||
fee = 100 * node.getnetworkinfo()["relayfee"]
|
||||
create_lots_of_big_transactions(node, txouts, utxos, num, fee=fee)
|
||||
node.generate(1)
|
||||
test_framework.generate(node, 1)
|
||||
|
||||
|
||||
def generate_to_height(node, target_height):
|
||||
def generate_to_height(test_framework, node, target_height):
|
||||
"""Generates blocks until a given target block height has been reached.
|
||||
To prevent timeouts, only up to 200 blocks are generated per RPC call.
|
||||
Can be used to activate certain soft-forks (e.g. CSV, CLTV)."""
|
||||
current_height = node.getblockcount()
|
||||
while current_height < target_height:
|
||||
nblocks = min(200, target_height - current_height)
|
||||
current_height += len(node.generate(nblocks))
|
||||
current_height += len(test_framework.generate(node, nblocks))
|
||||
assert_equal(node.getblockcount(), target_height)
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ class WalletDescriptorTest(BitcoinTestFramework):
|
||||
send_wrpc = self.nodes[0].get_wallet_rpc("desc1")
|
||||
|
||||
# Generate some coins
|
||||
send_wrpc.generatetoaddress(101, send_wrpc.getnewaddress())
|
||||
self.generatetoaddress(send_wrpc, 101, send_wrpc.getnewaddress())
|
||||
|
||||
# Make transactions
|
||||
self.log.info("Test sending and receiving")
|
||||
|
@ -73,7 +73,7 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||
assert_equal(wpriv.getwalletinfo()['keypoolsize'], 0)
|
||||
|
||||
self.log.info('Mining coins')
|
||||
w0.generatetoaddress(101, w0.getnewaddress())
|
||||
self.generatetoaddress(w0, 101, w0.getnewaddress())
|
||||
|
||||
# RPC importdescriptors -----------------------------------------------
|
||||
|
||||
@ -380,7 +380,7 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||
solvable=True,
|
||||
ismine=True)
|
||||
txid = w0.sendtoaddress(address, 49.99995540)
|
||||
w0.generatetoaddress(6, w0.getnewaddress())
|
||||
self.generatetoaddress(w0, 6, w0.getnewaddress())
|
||||
self.sync_blocks()
|
||||
tx = wpriv.createrawtransaction([{"txid": txid, "vout": 0}], {w0.getnewaddress(): 49.999})
|
||||
signed_tx = wpriv.signrawtransactionwithwallet(tx)
|
||||
|
Loading…
Reference in New Issue
Block a user