File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 15
15
assert_equal ,
16
16
assert_raises_rpc_error ,
17
17
find_vout_for_address ,
18
+ generate_to_height ,
18
19
hex_str_to_bytes ,
19
20
)
20
21
from test_framework .messages import (
@@ -270,7 +271,7 @@ def test_signing_with_csv(self):
270
271
getcontext ().prec = 8
271
272
272
273
# Make sure CSV is active
273
- self .nodes [0 ]. generate ( 500 )
274
+ generate_to_height ( self .nodes [0 ], 500 )
274
275
assert self .nodes [0 ].getblockchaininfo ()['softforks' ]['csv' ]['active' ]
275
276
276
277
# Create a P2WSH script with CSV
@@ -306,7 +307,7 @@ def test_signing_with_cltv(self):
306
307
getcontext ().prec = 8
307
308
308
309
# Make sure CLTV is active
309
- self .nodes [0 ]. generate ( 1500 )
310
+ generate_to_height ( self .nodes [0 ], 1500 )
310
311
assert self .nodes [0 ].getblockchaininfo ()['softforks' ]['bip65' ]['active' ]
311
312
312
313
# Create a P2WSH script with CLTV
Original file line number Diff line number Diff line change @@ -559,6 +559,17 @@ def mine_large_block(node, utxos=None):
559
559
node .generate (1 )
560
560
561
561
562
+ def generate_to_height (node , target_height ):
563
+ """Generates blocks until a given target block height has been reached.
564
+ To prevent timeouts, only up to 200 blocks are generated per RPC call.
565
+ Can be used to activate certain soft-forks (e.g. CSV, CLTV)."""
566
+ current_height = node .getblockcount ()
567
+ while current_height < target_height :
568
+ nblocks = min (200 , target_height - current_height )
569
+ current_height += len (node .generate (nblocks ))
570
+ assert_equal (node .getblockcount (), target_height )
571
+
572
+
562
573
def find_vout_for_address (node , txid , addr ):
563
574
"""
564
575
Locate the vout index of the given transaction sending to the
You can’t perform that action at this time.
0 commit comments