diff options
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r-- | test/functional/test_framework/util.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 54f2fdee21..d66499dbcb 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -364,6 +364,11 @@ def write_config(config_path, *, n, chain, extra_config="", disable_autoconnect= f.write("dnsseed=0\n") f.write("fixedseeds=0\n") f.write("listenonion=0\n") + # Increase peertimeout to avoid disconnects while using mocktime. + # peertimeout is measured in wall clock time, so setting it to the + # duration of the longest test is sufficient. It can be overriden in + # tests. + f.write("peertimeout=999999\n") f.write("printtoconsole=0\n") f.write("upnp=0\n") f.write("natpmp=0\n") @@ -445,10 +450,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) @@ -469,7 +474,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 @@ -541,7 +546,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 @@ -552,17 +557,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) |