#35835 test: add CONST_SCRIPTCODE failure-path vectors to script_tests.json

full analysis

https://github.com/bitcoin/bitcoin/pull/35835 · jeanpablojp · +11/-0 in 1 files, 1 commits · labels: Tests

Goal

  • Verify script interpreter failure paths for the CONST_SCRIPTCODE flag
  • Add test vectors for previously unexercised error codes in script_tests.json

Adds six test vectors to script_tests.json exercising the SCRIPT_VERIFY_CONST_SCRIPTCODE flag. Four vectors assert specific failure error codes (SCRIPT_ERR_OP_CODESEPARATOR in executed and unexecuted branches, and SCRIPT_ERR_SIG_FINDANDDELETE in CHECKSIG and CHECKMULTISIG), while two control vectors verify passing behavior when the flag is omitted.

Problem: Neither error code gated behind SCRIPT_VERIFY_CONST_SCRIPTCODE was asserted in script_tests.json: SCRIPT_ERR_SIG_FINDANDDELETE had no tests anywhere, and SCRIPT_ERR_OP_CODESEPARATOR was only covered as a mempool reject string in functional tests rather than at the script interpreter level.

Category: Test infrastructure (#18 of 45)

P3 · test coverage

  • P3 because it improves coverage of consensus script evaluation edge cases
  • Directly exercises error codes that had no tests or only functional mempool checks

P3 because it improves coverage of consensus script evaluation edge cases that were previously unexercised at the script level. As the author notes, 'SCRIPT_ERR_SIG_FINDANDDELETE is not asserted by any test; SCRIPT_ERR_OP_CODESEPARATOR appears only as a mempool reject string in invalid_txs.py, never at the script level.'

Membership: Adds failure-path unit test vectors to src/test/data/script_tests.json.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1

Reviewability: Ready

  • Ready to review
  • Small self-contained test changes with passing CI

The diff is small and self-contained with passing CI and no conflicts.

Author status: active

Resolved concerns:

  • darosior asked whether CVE-2024-38365 test cases exist; author clarified that FindAndDelete does not match suffix pushes in that scenario and agreed to address that case in a separate PR.

Agreement: Positive

  • Concept approval without objections (darosior)
  • Clarified related edge case will be addressed in a separate PR (darosior)

Concept ACK from darosior; follow-up question resolved

darosior gave a Concept ACK and asked about coverage for a related btcd FindAndDelete bug, which the author answered, concluding that it belongs in a separate PR.

  • darosior commented: 'Concept ACK. Speaking of const scriptcode quirks, do we have a test case for CVE-2024-38365?'
  • jeanpablojp explained the difference and noted they would add that separately.

Review verdicts (DrahtBot): 0

Files

11 lines under test/bench/ci.

  • src/test/data/script_tests.json +11/-0

Card

This PR adds six test vectors to script_tests.json testing failure paths under SCRIPT_VERIFY_CONST_SCRIPTCODE. It addresses missing test coverage where SCRIPT_ERR_SIG_FINDANDDELETE had zero assertions across the codebase and SCRIPT_ERR_OP_CODESEPARATOR was only checked via mempool reject strings. It carries a Concept ACK from darosior with clean CI and no open objections.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:55, confidence high, input hash 42a250107e72095d