test: add CHECKLOCKTIMEVERIFY failure-path script test vectors
What changed, and why it matters
This commit only adds new test cases to a JSON test file for the Bitcoin Core test suite. It exercises ways the CHECKLOCKTIMEVERIFY (CLTV) script operation can fail, but does not change any production code, consensus rules, or network behavior. It is a test-only addition with no direct security impact on running software.
No action required; review as ordinary test coverage improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff appends 13 lines to src/test/data/script_tests.json, adding failure-path test vectors for OP_CHECKLOCKTIMEVERIFY. The vectors cover empty stack, negative stack top, non-minimal encoding, final nSequence, mismatched height/time lock semantics, and a 5-byte operand. No C++/Python build or runtime code is modified.
Changed components
src/test/data/script_tests.jsonInspect captured patch +13 / −0
diff --git a/src/test/data/script_tests.json b/src/test/data/script_tests.json
index a90ec795..027f1986 100644
--- a/src/test/data/script_tests.json
+++ b/src/test/data/script_tests.json
@@ -2573,6 +2573,19 @@
["0", "0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 CHECKSIGVERIFY 1", "P2SH,STRICTENC", "CHECKSIGVERIFY", "CHECKSIGVERIFY fails with its own error code when the signature check fails"],
["0 0", "1 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 1 CHECKMULTISIGVERIFY 1", "P2SH,STRICTENC", "CHECKMULTISIGVERIFY", "CHECKMULTISIGVERIFY fails with its own error code when the signature check fails"],
+["CHECKLOCKTIMEVERIFY tests"],
+["All tests below can only exercise failure paths: the spending transaction in these tests"],
+["has nLockTime 0 and a final nSequence, so CheckLockTime never succeeds."],
+["", "CHECKLOCKTIMEVERIFY", "CHECKLOCKTIMEVERIFY", "INVALID_STACK_OPERATION", "CLTV automatically fails on an empty stack"],
+["-1", "CHECKLOCKTIMEVERIFY", "CHECKLOCKTIMEVERIFY", "NEGATIVE_LOCKTIME", "CLTV automatically fails if stack top is negative"],
+["0x0180", "CHECKLOCKTIMEVERIFY", "CHECKLOCKTIMEVERIFY", "UNSATISFIED_LOCKTIME", "Negative zero is treated as 0, so CLTV fails with UNSATISFIED_LOCKTIME rather than NEGATIVE_LOCKTIME"],
+["0x0100", "CHECKLOCKTIMEVERIFY", "CHECKLOCKTIMEVERIFY,MINIMALDATA", "SCRIPTNUM", "CLTV use is non-standard if stack top is not minimally encoded"],
+["0", "CHECKLOCKTIMEVERIFY", "CHECKLOCKTIMEVERIFY", "UNSATISFIED_LOCKTIME", "CLTV fails if the input's nSequence is final, even when the lock time requirement is met"],
+["499999999", "CHECKLOCKTIMEVERIFY", "CHECKLOCKTIMEVERIFY", "UNSATISFIED_LOCKTIME", "CLTV fails if the stack operand (height) is greater than the tx nLockTime"],
+["500000000", "CHECKLOCKTIMEVERIFY", "CHECKLOCKTIMEVERIFY", "UNSATISFIED_LOCKTIME", "CLTV fails if the operand is time-based while the tx nLockTime is height-based"],
+["0x050000000001", "CHECKLOCKTIMEVERIFY", "CHECKLOCKTIMEVERIFY", "UNSATISFIED_LOCKTIME",
+ "CLTV accepts a 5-byte operand (2^32), but it is time-based while the tx nLockTime is height-based"],
+
["CHECKSEQUENCEVERIFY tests"],
["", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "INVALID_STACK_OPERATION", "CSV automatically fails on an empty stack"],
["-1", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "NEGATIVE_LOCKTIME", "CSV automatically fails if stack top is negative"],
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.