@@ -168,7 +168,7 @@ def create_test_block(self, txs, version=536870912):
168
168
block .solve ()
169
169
return block
170
170
171
- def sync_blocks (self , blocks , success = True ):
171
+ def send_blocks (self , blocks , success = True ):
172
172
"""Sends blocks to test node. Syncs and verifies that tip has advanced to most recent block.
173
173
174
174
Call with success = False if the tip shouldn't advance to the most recent block."""
@@ -190,7 +190,7 @@ def run_test(self):
190
190
self .log .info ("Test that the csv softfork is DEFINED" )
191
191
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'defined' )
192
192
test_blocks = self .generate_blocks (61 , 4 )
193
- self .sync_blocks (test_blocks )
193
+ self .send_blocks (test_blocks )
194
194
195
195
self .log .info ("Advance from DEFINED to STARTED, height = 143" )
196
196
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'started' )
@@ -202,7 +202,7 @@ def run_test(self):
202
202
test_blocks = self .generate_blocks (20 , 4 , test_blocks ) # 0x00000004 (signalling not)
203
203
test_blocks = self .generate_blocks (50 , 536871169 , test_blocks ) # 0x20000101 (signalling ready)
204
204
test_blocks = self .generate_blocks (24 , 536936448 , test_blocks ) # 0x20010000 (signalling not)
205
- self .sync_blocks (test_blocks )
205
+ self .send_blocks (test_blocks )
206
206
207
207
self .log .info ("Failed to advance past STARTED, height = 287" )
208
208
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'started' )
@@ -214,14 +214,14 @@ def run_test(self):
214
214
test_blocks = self .generate_blocks (26 , 4 , test_blocks ) # 0x00000004 (signalling not)
215
215
test_blocks = self .generate_blocks (50 , 536871169 , test_blocks ) # 0x20000101 (signalling ready)
216
216
test_blocks = self .generate_blocks (10 , 536936448 , test_blocks ) # 0x20010000 (signalling not)
217
- self .sync_blocks (test_blocks )
217
+ self .send_blocks (test_blocks )
218
218
219
219
self .log .info ("Advanced from STARTED to LOCKED_IN, height = 431" )
220
220
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'locked_in' )
221
221
222
222
# Generate 140 more version 4 blocks
223
223
test_blocks = self .generate_blocks (140 , 4 )
224
- self .sync_blocks (test_blocks )
224
+ self .send_blocks (test_blocks )
225
225
226
226
# Inputs at height = 572
227
227
#
@@ -264,7 +264,7 @@ def run_test(self):
264
264
265
265
# 2 more version 4 blocks
266
266
test_blocks = self .generate_blocks (2 , 4 )
267
- self .sync_blocks (test_blocks )
267
+ self .send_blocks (test_blocks )
268
268
269
269
self .log .info ("Not yet advanced to ACTIVE, height = 574 (will activate for block 576, not 575)" )
270
270
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'locked_in' )
@@ -318,7 +318,7 @@ def run_test(self):
318
318
# try BIP 112 with seq=9 txs
319
319
success_txs .extend (all_rlt_txs (bip112txs_vary_nSequence_9_v1 ))
320
320
success_txs .extend (all_rlt_txs (bip112txs_vary_OP_CSV_9_v1 ))
321
- self .sync_blocks ([self .create_test_block (success_txs )])
321
+ self .send_blocks ([self .create_test_block (success_txs )])
322
322
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
323
323
324
324
self .log .info ("Test version 2 txs" )
@@ -337,12 +337,12 @@ def run_test(self):
337
337
# try BIP 112 with seq=9 txs
338
338
success_txs .extend (all_rlt_txs (bip112txs_vary_nSequence_9_v2 ))
339
339
success_txs .extend (all_rlt_txs (bip112txs_vary_OP_CSV_9_v2 ))
340
- self .sync_blocks ([self .create_test_block (success_txs )])
340
+ self .send_blocks ([self .create_test_block (success_txs )])
341
341
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
342
342
343
343
# 1 more version 4 block to get us to height 575 so the fork should now be active for the next block
344
344
test_blocks = self .generate_blocks (1 , 4 )
345
- self .sync_blocks (test_blocks )
345
+ self .send_blocks (test_blocks )
346
346
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'active' )
347
347
348
348
self .log .info ("Post-Soft Fork Tests." )
@@ -354,74 +354,74 @@ def run_test(self):
354
354
bip113tx_v2 .nLockTime = self .last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
355
355
bip113signed2 = sign_transaction (self .nodes [0 ], bip113tx_v2 )
356
356
for bip113tx in [bip113signed1 , bip113signed2 ]:
357
- self .sync_blocks ([self .create_test_block ([bip113tx ])], success = False )
357
+ self .send_blocks ([self .create_test_block ([bip113tx ])], success = False )
358
358
# BIP 113 tests should now pass if the locktime is < MTP
359
359
bip113tx_v1 .nLockTime = self .last_block_time - 600 * 5 - 1 # < MTP of prior block
360
360
bip113signed1 = sign_transaction (self .nodes [0 ], bip113tx_v1 )
361
361
bip113tx_v2 .nLockTime = self .last_block_time - 600 * 5 - 1 # < MTP of prior block
362
362
bip113signed2 = sign_transaction (self .nodes [0 ], bip113tx_v2 )
363
363
for bip113tx in [bip113signed1 , bip113signed2 ]:
364
- self .sync_blocks ([self .create_test_block ([bip113tx ])])
364
+ self .send_blocks ([self .create_test_block ([bip113tx ])])
365
365
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
366
366
367
367
# Next block height = 580 after 4 blocks of random version
368
368
test_blocks = self .generate_blocks (4 , 1234 )
369
- self .sync_blocks (test_blocks )
369
+ self .send_blocks (test_blocks )
370
370
371
371
self .log .info ("BIP 68 tests" )
372
372
self .log .info ("Test version 1 txs - all should still pass" )
373
373
374
374
success_txs = []
375
375
success_txs .extend (all_rlt_txs (bip68txs_v1 ))
376
- self .sync_blocks ([self .create_test_block (success_txs )])
376
+ self .send_blocks ([self .create_test_block (success_txs )])
377
377
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
378
378
379
379
self .log .info ("Test version 2 txs" )
380
380
381
381
# All txs with SEQUENCE_LOCKTIME_DISABLE_FLAG set pass
382
382
bip68success_txs = [tx ['tx' ] for tx in bip68txs_v2 if tx ['sdf' ]]
383
- self .sync_blocks ([self .create_test_block (bip68success_txs )])
383
+ self .send_blocks ([self .create_test_block (bip68success_txs )])
384
384
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
385
385
386
386
# All txs without flag fail as we are at delta height = 8 < 10 and delta time = 8 * 600 < 10 * 512
387
387
bip68timetxs = [tx ['tx' ] for tx in bip68txs_v2 if not tx ['sdf' ] and tx ['stf' ]]
388
388
for tx in bip68timetxs :
389
- self .sync_blocks ([self .create_test_block ([tx ])], success = False )
389
+ self .send_blocks ([self .create_test_block ([tx ])], success = False )
390
390
391
391
bip68heighttxs = [tx ['tx' ] for tx in bip68txs_v2 if not tx ['sdf' ] and not tx ['stf' ]]
392
392
for tx in bip68heighttxs :
393
- self .sync_blocks ([self .create_test_block ([tx ])], success = False )
393
+ self .send_blocks ([self .create_test_block ([tx ])], success = False )
394
394
395
395
# Advance one block to 581
396
396
test_blocks = self .generate_blocks (1 , 1234 )
397
- self .sync_blocks (test_blocks )
397
+ self .send_blocks (test_blocks )
398
398
399
399
# Height txs should fail and time txs should now pass 9 * 600 > 10 * 512
400
400
bip68success_txs .extend (bip68timetxs )
401
- self .sync_blocks ([self .create_test_block (bip68success_txs )])
401
+ self .send_blocks ([self .create_test_block (bip68success_txs )])
402
402
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
403
403
for tx in bip68heighttxs :
404
- self .sync_blocks ([self .create_test_block ([tx ])], success = False )
404
+ self .send_blocks ([self .create_test_block ([tx ])], success = False )
405
405
406
406
# Advance one block to 582
407
407
test_blocks = self .generate_blocks (1 , 1234 )
408
- self .sync_blocks (test_blocks )
408
+ self .send_blocks (test_blocks )
409
409
410
410
# All BIP 68 txs should pass
411
411
bip68success_txs .extend (bip68heighttxs )
412
- self .sync_blocks ([self .create_test_block (bip68success_txs )])
412
+ self .send_blocks ([self .create_test_block (bip68success_txs )])
413
413
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
414
414
415
415
self .log .info ("BIP 112 tests" )
416
416
self .log .info ("Test version 1 txs" )
417
417
418
418
# -1 OP_CSV tx should fail
419
- self .sync_blocks ([self .create_test_block ([bip112tx_special_v1 ])], success = False )
419
+ self .send_blocks ([self .create_test_block ([bip112tx_special_v1 ])], success = False )
420
420
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
421
421
422
422
success_txs = [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_v1 if tx ['sdf' ]]
423
423
success_txs += [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_9_v1 if tx ['sdf' ]]
424
- self .sync_blocks ([self .create_test_block (success_txs )])
424
+ self .send_blocks ([self .create_test_block (success_txs )])
425
425
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
426
426
427
427
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is unset in argument to OP_CSV, version 1 txs should now fail
@@ -430,18 +430,18 @@ def run_test(self):
430
430
fail_txs += [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_9_v1 if not tx ['sdf' ]]
431
431
fail_txs += [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_9_v1 if not tx ['sdf' ]]
432
432
for tx in fail_txs :
433
- self .sync_blocks ([self .create_test_block ([tx ])], success = False )
433
+ self .send_blocks ([self .create_test_block ([tx ])], success = False )
434
434
435
435
self .log .info ("Test version 2 txs" )
436
436
437
437
# -1 OP_CSV tx should fail
438
- self .sync_blocks ([self .create_test_block ([bip112tx_special_v2 ])], success = False )
438
+ self .send_blocks ([self .create_test_block ([bip112tx_special_v2 ])], success = False )
439
439
440
440
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 2 txs should pass (all sequence locks are met)
441
441
success_txs = [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_v2 if tx ['sdf' ]]
442
442
success_txs += [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_9_v2 if tx ['sdf' ]]
443
443
444
- self .sync_blocks ([self .create_test_block (success_txs )])
444
+ self .send_blocks ([self .create_test_block (success_txs )])
445
445
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
446
446
447
447
# SEQUENCE_LOCKTIME_DISABLE_FLAG is unset in argument to OP_CSV for all remaining txs ##
@@ -450,23 +450,23 @@ def run_test(self):
450
450
fail_txs = all_rlt_txs (bip112txs_vary_nSequence_9_v2 )
451
451
fail_txs += [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_9_v2 if not tx ['sdf' ]]
452
452
for tx in fail_txs :
453
- self .sync_blocks ([self .create_test_block ([tx ])], success = False )
453
+ self .send_blocks ([self .create_test_block ([tx ])], success = False )
454
454
455
455
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
456
456
fail_txs = [tx ['tx' ] for tx in bip112txs_vary_nSequence_v2 if tx ['sdf' ]]
457
457
for tx in fail_txs :
458
- self .sync_blocks ([self .create_test_block ([tx ])], success = False )
458
+ self .send_blocks ([self .create_test_block ([tx ])], success = False )
459
459
460
460
# If sequencelock types mismatch, tx should fail
461
461
fail_txs = [tx ['tx' ] for tx in bip112txs_vary_nSequence_v2 if not tx ['sdf' ] and tx ['stf' ]]
462
462
fail_txs += [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_v2 if not tx ['sdf' ] and tx ['stf' ]]
463
463
for tx in fail_txs :
464
- self .sync_blocks ([self .create_test_block ([tx ])], success = False )
464
+ self .send_blocks ([self .create_test_block ([tx ])], success = False )
465
465
466
466
# Remaining txs should pass, just test masking works properly
467
467
success_txs = [tx ['tx' ] for tx in bip112txs_vary_nSequence_v2 if not tx ['sdf' ] and not tx ['stf' ]]
468
468
success_txs += [tx ['tx' ] for tx in bip112txs_vary_OP_CSV_v2 if not tx ['sdf' ] and not tx ['stf' ]]
469
- self .sync_blocks ([self .create_test_block (success_txs )])
469
+ self .send_blocks ([self .create_test_block (success_txs )])
470
470
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
471
471
472
472
# Additional test, of checking that comparison of two time types works properly
@@ -476,7 +476,7 @@ def run_test(self):
476
476
signtx = sign_transaction (self .nodes [0 ], tx )
477
477
time_txs .append (signtx )
478
478
479
- self .sync_blocks ([self .create_test_block (time_txs )])
479
+ self .send_blocks ([self .create_test_block (time_txs )])
480
480
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
481
481
482
482
# TODO: Test empty stack fails
0 commit comments