Skip to content

Commit 54be4e7

Browse files
committed
test: check specific reject reasons in feature_csv_activation.py
this also fixes a bug that was uncovered with this checks: for the BIP112 version 1 tx tests, certain txs (bip112txs_vary_OP_CSV_v1) have been sent twice due to a typo, leading also to a failure as expected but for the wrong reason
1 parent 5ad80be commit 54be4e7

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

test/functional/feature_csv_activation.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def run_test(self):
343343
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
344344
bip113signed2 = sign_transaction(self.nodes[0], bip113tx_v2)
345345
for bip113tx in [bip113signed1, bip113signed2]:
346-
self.send_blocks([self.create_test_block([bip113tx])], success=False)
346+
self.send_blocks([self.create_test_block([bip113tx])], success=False, reject_reason='bad-txns-nonfinal')
347347
# BIP 113 tests should now pass if the locktime is < MTP
348348
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 - 1 # < MTP of prior block
349349
bip113signed1 = sign_transaction(self.nodes[0], bip113tx_v1)
@@ -375,11 +375,11 @@ def run_test(self):
375375
# All txs without flag fail as we are at delta height = 8 < 10 and delta time = 8 * 600 < 10 * 512
376376
bip68timetxs = [tx['tx'] for tx in bip68txs_v2 if not tx['sdf'] and tx['stf']]
377377
for tx in bip68timetxs:
378-
self.send_blocks([self.create_test_block([tx])], success=False)
378+
self.send_blocks([self.create_test_block([tx])], success=False, reject_reason='bad-txns-nonfinal')
379379

380380
bip68heighttxs = [tx['tx'] for tx in bip68txs_v2 if not tx['sdf'] and not tx['stf']]
381381
for tx in bip68heighttxs:
382-
self.send_blocks([self.create_test_block([tx])], success=False)
382+
self.send_blocks([self.create_test_block([tx])], success=False, reject_reason='bad-txns-nonfinal')
383383

384384
# Advance one block to 438
385385
test_blocks = self.generate_blocks(1)
@@ -390,7 +390,7 @@ def run_test(self):
390390
self.send_blocks([self.create_test_block(bip68success_txs)])
391391
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
392392
for tx in bip68heighttxs:
393-
self.send_blocks([self.create_test_block([tx])], success=False)
393+
self.send_blocks([self.create_test_block([tx])], success=False, reject_reason='bad-txns-nonfinal')
394394

395395
# Advance one block to 439
396396
test_blocks = self.generate_blocks(1)
@@ -405,7 +405,8 @@ def run_test(self):
405405
self.log.info("Test version 1 txs")
406406

407407
# -1 OP_CSV tx and (empty stack) OP_CSV tx should fail
408-
self.send_blocks([self.create_test_block([bip112tx_special_v1])], success=False)
408+
self.send_blocks([self.create_test_block([bip112tx_special_v1])], success=False,
409+
reject_reason='non-mandatory-script-verify-flag (Negative locktime)')
409410
self.send_blocks([self.create_test_block([bip112tx_emptystack_v1])], success=False,
410411
reject_reason='non-mandatory-script-verify-flag (Operation not valid with the current stack size)')
411412
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
@@ -418,15 +419,17 @@ def run_test(self):
418419
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is unset in argument to OP_CSV, version 1 txs should now fail
419420
fail_txs = all_rlt_txs(bip112txs_vary_nSequence_v1)
420421
fail_txs += all_rlt_txs(bip112txs_vary_nSequence_9_v1)
421-
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_9_v1 if not tx['sdf']]
422+
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_v1 if not tx['sdf']]
422423
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_9_v1 if not tx['sdf']]
423424
for tx in fail_txs:
424-
self.send_blocks([self.create_test_block([tx])], success=False)
425+
self.send_blocks([self.create_test_block([tx])], success=False,
426+
reject_reason='non-mandatory-script-verify-flag (Locktime requirement not satisfied)')
425427

426428
self.log.info("Test version 2 txs")
427429

428430
# -1 OP_CSV tx and (empty stack) OP_CSV tx should fail
429-
self.send_blocks([self.create_test_block([bip112tx_special_v2])], success=False)
431+
self.send_blocks([self.create_test_block([bip112tx_special_v2])], success=False,
432+
reject_reason='non-mandatory-script-verify-flag (Negative locktime)')
430433
self.send_blocks([self.create_test_block([bip112tx_emptystack_v2])], success=False,
431434
reject_reason='non-mandatory-script-verify-flag (Operation not valid with the current stack size)')
432435

@@ -443,18 +446,21 @@ def run_test(self):
443446
fail_txs = all_rlt_txs(bip112txs_vary_nSequence_9_v2)
444447
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_9_v2 if not tx['sdf']]
445448
for tx in fail_txs:
446-
self.send_blocks([self.create_test_block([tx])], success=False)
449+
self.send_blocks([self.create_test_block([tx])], success=False,
450+
reject_reason='non-mandatory-script-verify-flag (Locktime requirement not satisfied)')
447451

448452
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
449453
fail_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if tx['sdf']]
450454
for tx in fail_txs:
451-
self.send_blocks([self.create_test_block([tx])], success=False)
455+
self.send_blocks([self.create_test_block([tx])], success=False,
456+
reject_reason='non-mandatory-script-verify-flag (Locktime requirement not satisfied)')
452457

453458
# If sequencelock types mismatch, tx should fail
454459
fail_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if not tx['sdf'] and tx['stf']]
455460
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_v2 if not tx['sdf'] and tx['stf']]
456461
for tx in fail_txs:
457-
self.send_blocks([self.create_test_block([tx])], success=False)
462+
self.send_blocks([self.create_test_block([tx])], success=False,
463+
reject_reason='non-mandatory-script-verify-flag (Locktime requirement not satisfied)')
458464

459465
# Remaining txs should pass, just test masking works properly
460466
success_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if not tx['sdf'] and not tx['stf']]

0 commit comments

Comments
 (0)