Merge bitcoin/bitcoin#36128: test: add script_tests cases covering more interpreter mutants
What changed, and why it matters
This commit only adds new test cases to Bitcoin Core's test suite. It does not change any production consensus code. The tests are designed to catch accidental code changes ('mutants') in the script interpreter that could break consensus rules, but the commit itself is a defensive testing improvement, not a vulnerability fix.
No security response required. Treat as a normal test-coverage improvement. Reviewers may optionally verify that the new test vectors correctly exercise the intended consensus rules.
Security signals we found
Adds consensus-relevant test coverage for script interpreter behavior
Pull request description discusses hypothetical mutants in interpreter.cpp, but these are not present in the diff
No changes to production consensus, networking, wallet, or RPC code
Evidence from the diff
The merge commit adds three test vectors to src/test/data/script_tests.json and registers the TAPSCRIPT_MINIMALIF error string in src/test/script_tests.cpp. The new tests cover: (1) P2WSH witness script hash mismatch when only the last byte differs, (2) MAX_OPS_PER_SCRIPT enforcement in P2WSH witness scripts, and (3) TAPSCRIPT_MINIMALIF failure for OP_IF/OP_NOTIF with a 1-byte 0x00 vector. The pull request description illustrates which hypothetical mutations in src/script/interpreter.cpp these tests would kill, but the diff contains no changes to interpreter.cpp.
Changed components
src/test/data/script_tests.jsonsrc/test/script_tests.cppInspect captured patch +34 / −0
### src/test/data/script_tests.json
@@ -1297,12 +1297,19 @@
["Some basic segwit checks"],
[["00", 0.00000000 ], "", "0 0x206e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d", "P2SH,WITNESS", "EVAL_FALSE", "Invalid witness script"],
[["51", 0.00000000 ], "", "0 0x206e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d", "P2SH,WITNESS", "WITNESS_PROGRAM_MISMATCH", "Witness script hash mismatch"],
+[["51", 0.00000000 ], "", "0 0x204ae81572f06e1b88fd5ced7a1a000945432e83e1551e6f721ee9c00b8cc33261", "P2SH,WITNESS", "WITNESS_PROGRAM_MISMATCH", "Witness script hash mismatch (last byte differs)"],
[["00", 0.00000000 ], "", "0 0x206e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d", "", "OK", "Invalid witness script without WITNESS"],
[["51", 0.00000000 ], "", "0 0x206e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d", "", "OK", "Witness script hash mismatch without WITNESS"],
[["51", 0.00000000 ], "", "-1 0x021234", "P2SH,WITNESS", "WITNESS_UNEXPECTED", "OP_1NEGATE does not introduce a witness program"],
[["51", 0.00000000 ], "00", "1 0x021234", "P2SH,WITNESS", "WITNESS_MALLEATED", "OP_1 does introduce a witness program"],
[["51", 0.00000000 ], "00", "16 0x021234", "P2SH,WITNESS", "WITNESS_MALLEATED", "OP_16 does introduce a witness program"],
[["51", 0.00000000 ], "", "NOP 0x021234", "P2SH,WITNESS", "WITNESS_UNEXPECTED", "NOP does not introduce a witness program"],
+[["6161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616151", 0.00000000 ],
+"",
+"0 0x20 0x73a0a078cb5f8f39cffbaeac999da2572e65229ef9cf4510cfa765bfe1aa1854",
+"P2SH,WITNESS",
+"OP_COUNT",
+">201 opcodes executed in a P2WSH witness script."],
["Automatically generated test cases"],
[
@@ -2740,6 +2747,32 @@
"OK",
"TAPSCRIPT Test that DROP operations do not execute inside of a false IF conditional"
],
+[
+ [
+ "00",
+ "#SCRIPT# IF 1 ENDIF",
+ "#CONTROLBLOCK#",
+ 0.00000001
+ ],
+ "",
+ "0x51 0x20 #TAPROOTOUTPUT#",
+ "P2SH,WITNESS,TAPROOT",
+ "TAPSCRIPT_MINIMALIF",
+ "TAPSCRIPT Test that OP_IF with 1-byte vector 0x00 must fail with TAPSCRIPT_MINIMALIF"
+],
+[
+ [
+ "00",
+ "#SCRIPT# NOTIF 1 ENDIF",
+ "#CONTROLBLOCK#",
+ 0.00000001
+ ],
+ "",
+ "0x51 0x20 #TAPROOTOUTPUT#",
+ "P2SH,WITNESS,TAPROOT",
+ "TAPSCRIPT_MINIMALIF",
+ "TAPSCRIPT Test that OP_NOTIF with 1-byte vector 0x00 must fail with TAPSCRIPT_MINIMALIF"
+],
[
[
"aa",
### src/test/script_tests.cpp
@@ -92,6 +92,7 @@ static ScriptErrorDesc script_errors[]={
{SCRIPT_ERR_WITNESS_UNEXPECTED, "WITNESS_UNEXPECTED"},
{SCRIPT_ERR_WITNESS_PUBKEYTYPE, "WITNESS_PUBKEYTYPE"},
{SCRIPT_ERR_TAPSCRIPT_EMPTY_PUBKEY, "TAPSCRIPT_EMPTY_PUBKEY"},
+ {SCRIPT_ERR_TAPSCRIPT_MINIMALIF, "TAPSCRIPT_MINIMALIF"},
{SCRIPT_ERR_OP_CODESEPARATOR, "OP_CODESEPARATOR"},
{SCRIPT_ERR_SIG_FINDANDDELETE, "SIG_FINDANDDELETE"},
{SCRIPT_ERR_SCRIPTNUM, "SCRIPTNUM"}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.