@@ -209,6 +209,7 @@ def create_bip112txs(self, bip112inputs, varyOP_CSV, txversion, locktime_delta=0
209
209
return txs
210
210
211
211
def get_tests (self ):
212
+ self .log .info ("Generate blocks in the past for coinbase outputs." )
212
213
long_past_time = int (time .time ()) - 600 * 1000 # enough to build up to 1000 blocks 10 minutes apart without worrying about getting into the future
213
214
self .nodes [0 ].setmocktime (long_past_time - 100 ) # enough so that the generated blocks will still all be before long_past_time
214
215
self .coinbase_blocks = self .nodes [0 ].generate (1 + 16 + 2 * 32 + 1 ) # 82 blocks generated for inputs
@@ -218,33 +219,39 @@ def get_tests(self):
218
219
self .tip = int (self .nodes [0 ].getbestblockhash (), 16 )
219
220
self .nodeaddress = self .nodes [0 ].getnewaddress ()
220
221
222
+ self .log .info ("Test that the csv softfork is DEFINED" )
221
223
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'defined' )
222
224
test_blocks = self .generate_blocks (61 , 4 )
223
225
yield TestInstance (test_blocks , sync_every_block = False )
224
- # Advanced from DEFINED to STARTED, height = 143
226
+
227
+ self .log .info ("Advance from DEFINED to STARTED, height = 143" )
225
228
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'started' )
226
229
227
- # Fail to achieve LOCKED_IN 100 out of 144 signal bit 0
228
- # using a variety of bits to simulate multiple parallel softforks
230
+ self .log .info ("Fail to achieve LOCKED_IN" )
231
+ # 100 out of 144 signal bit 0. Use a variety of bits to simulate multiple parallel softforks
232
+
229
233
test_blocks = self .generate_blocks (50 , 536870913 ) # 0x20000001 (signalling ready)
230
234
test_blocks = self .generate_blocks (20 , 4 , test_blocks ) # 0x00000004 (signalling not)
231
235
test_blocks = self .generate_blocks (50 , 536871169 , test_blocks ) # 0x20000101 (signalling ready)
232
236
test_blocks = self .generate_blocks (24 , 536936448 , test_blocks ) # 0x20010000 (signalling not)
233
237
yield TestInstance (test_blocks , sync_every_block = False )
234
- # Failed to advance past STARTED, height = 287
238
+
239
+ self .log .info ("Failed to advance past STARTED, height = 287" )
235
240
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'started' )
236
241
242
+ self .log .info ("Generate blocks to achieve LOCK-IN" )
237
243
# 108 out of 144 signal bit 0 to achieve lock-in
238
244
# using a variety of bits to simulate multiple parallel softforks
239
245
test_blocks = self .generate_blocks (58 , 536870913 ) # 0x20000001 (signalling ready)
240
246
test_blocks = self .generate_blocks (26 , 4 , test_blocks ) # 0x00000004 (signalling not)
241
247
test_blocks = self .generate_blocks (50 , 536871169 , test_blocks ) # 0x20000101 (signalling ready)
242
248
test_blocks = self .generate_blocks (10 , 536936448 , test_blocks ) # 0x20010000 (signalling not)
243
249
yield TestInstance (test_blocks , sync_every_block = False )
244
- # Advanced from STARTED to LOCKED_IN, height = 431
250
+
251
+ self .log .info ("Advanced from STARTED to LOCKED_IN, height = 431" )
245
252
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'locked_in' )
246
253
247
- # 140 more version 4 blocks
254
+ # Generate 140 more version 4 blocks
248
255
test_blocks = self .generate_blocks (140 , 4 )
249
256
yield TestInstance (test_blocks , sync_every_block = False )
250
257
@@ -256,22 +263,26 @@ def get_tests(self):
256
263
bip68inputs = []
257
264
for i in range (16 ):
258
265
bip68inputs .append (self .send_generic_input_tx (self .nodes [0 ], self .coinbase_blocks ))
266
+
259
267
# 2 sets of 16 inputs with 10 OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
260
268
bip112basicinputs = []
261
269
for j in range (2 ):
262
270
inputs = []
263
271
for i in range (16 ):
264
272
inputs .append (self .send_generic_input_tx (self .nodes [0 ], self .coinbase_blocks ))
265
273
bip112basicinputs .append (inputs )
274
+
266
275
# 2 sets of 16 varied inputs with (relative_lock_time) OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
267
276
bip112diverseinputs = []
268
277
for j in range (2 ):
269
278
inputs = []
270
279
for i in range (16 ):
271
280
inputs .append (self .send_generic_input_tx (self .nodes [0 ], self .coinbase_blocks ))
272
281
bip112diverseinputs .append (inputs )
282
+
273
283
# 1 special input with -1 OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
274
284
bip112specialinput = self .send_generic_input_tx (self .nodes [0 ], self .coinbase_blocks )
285
+
275
286
# 1 normal input
276
287
bip113input = self .send_generic_input_tx (self .nodes [0 ], self .coinbase_blocks )
277
288
@@ -286,7 +297,8 @@ def get_tests(self):
286
297
# 2 more version 4 blocks
287
298
test_blocks = self .generate_blocks (2 , 4 )
288
299
yield TestInstance (test_blocks , sync_every_block = False )
289
- # Not yet advanced to ACTIVE, height = 574 (will activate for block 576, not 575)
300
+
301
+ self .log .info ("Not yet advanced to ACTIVE, height = 574 (will activate for block 576, not 575)" )
290
302
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'locked_in' )
291
303
292
304
# Test both version 1 and version 2 transactions for all tests
@@ -319,13 +331,11 @@ def get_tests(self):
319
331
bip112tx_special_v1 = self .create_bip112special (bip112specialinput , 1 )
320
332
bip112tx_special_v2 = self .create_bip112special (bip112specialinput , 2 )
321
333
334
+ self .log .info ("TESTING" )
335
+
336
+ self .log .info ("Pre-Soft Fork Tests. All txs should pass." )
337
+ self .log .info ("Test version 1 txs" )
322
338
323
- ### TESTING ###
324
- ##################################
325
- ### Before Soft Forks Activate ###
326
- ##################################
327
- # All txs should pass
328
- ### Version 1 txs ###
329
339
success_txs = []
330
340
# add BIP113 tx and -1 CSV tx
331
341
bip113tx_v1 .nLockTime = self .last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
@@ -343,7 +353,8 @@ def get_tests(self):
343
353
yield TestInstance ([[self .create_test_block (success_txs ), True ]])
344
354
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
345
355
346
- ### Version 2 txs ###
356
+ self .log .info ("Test version 2 txs" )
357
+
347
358
success_txs = []
348
359
# add BIP113 tx and -1 CSV tx
349
360
bip113tx_v2 .nLockTime = self .last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
@@ -366,10 +377,9 @@ def get_tests(self):
366
377
yield TestInstance (test_blocks , sync_every_block = False )
367
378
assert_equal (get_bip9_status (self .nodes [0 ], 'csv' )['status' ], 'active' )
368
379
369
- #################################
370
- ### After Soft Forks Activate ###
371
- #################################
372
- ### BIP 113 ###
380
+ self .log .info ("Post-Soft Fork Tests." )
381
+
382
+ self .log .info ("BIP 113 tests" )
373
383
# BIP 113 tests should now fail regardless of version number if nLockTime isn't satisfied by new rules
374
384
bip113tx_v1 .nLockTime = self .last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
375
385
bip113signed1 = self .sign_transaction (self .nodes [0 ], bip113tx_v1 )
@@ -390,15 +400,16 @@ def get_tests(self):
390
400
test_blocks = self .generate_blocks (4 , 1234 )
391
401
yield TestInstance (test_blocks , sync_every_block = False )
392
402
393
- ### BIP 68 ###
394
- ### Version 1 txs ###
395
- # All still pass
403
+ self . log . info ( " BIP 68 tests" )
404
+ self . log . info ( "Test version 1 txs - all should still pass" )
405
+
396
406
success_txs = []
397
407
success_txs .extend (all_rlt_txs (bip68txs_v1 ))
398
408
yield TestInstance ([[self .create_test_block (success_txs ), True ]])
399
409
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
400
410
401
- ### Version 2 txs ###
411
+ self .log .info ("Test version 2 txs" )
412
+
402
413
bip68success_txs = []
403
414
# All txs with SEQUENCE_LOCKTIME_DISABLE_FLAG set pass
404
415
for b25 in range (2 ):
@@ -441,8 +452,9 @@ def get_tests(self):
441
452
yield TestInstance ([[self .create_test_block (bip68success_txs ), True ]])
442
453
self .nodes [0 ].invalidateblock (self .nodes [0 ].getbestblockhash ())
443
454
444
- ### BIP 112 ###
445
- ### Version 1 txs ###
455
+ self .log .info ("BIP 112 tests" )
456
+ self .log .info ("Test version 1 txs" )
457
+
446
458
# -1 OP_CSV tx should fail
447
459
yield TestInstance ([[self .create_test_block ([bip112tx_special_v1 ]), False ]])
448
460
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
@@ -468,7 +480,8 @@ def get_tests(self):
468
480
for tx in fail_txs :
469
481
yield TestInstance ([[self .create_test_block ([tx ]), False ]])
470
482
471
- ### Version 2 txs ###
483
+ self .log .info ("Version 2 txs" )
484
+
472
485
# -1 OP_CSV tx should fail
473
486
yield TestInstance ([[self .create_test_block ([bip112tx_special_v2 ]), False ]])
474
487
0 commit comments