aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-07-26 00:26:55 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-07-27 00:14:52 +0200
commit746f203f1950a7df50b9a7de87a361cc7354ffb4 (patch)
treeedde563a1b28e99f038589687cf47cb70333c110 /test/functional/test_framework
parente3237b1cd07a5099fbb0108218194eb653b6a9f3 (diff)
downloadbitcoin-746f203f1950a7df50b9a7de87a361cc7354ffb4.tar.xz
test: introduce `generate_to_height` helper, use in rpc_signrawtransaction
This will speed up the test a bit and avoid potential .generate() RPC timeouts (in sub-test `test_signing_with_cltv()`) on slower machines.
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r--test/functional/test_framework/util.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 35dbfbba8d..fcaf3b2c29 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -559,6 +559,17 @@ def mine_large_block(node, utxos=None):
node.generate(1)
+def generate_to_height(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))
+ assert_equal(node.getblockcount(), target_height)
+
+
def find_vout_for_address(node, txid, addr):
"""
Locate the vout index of the given transaction sending to the