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

pull jeanpablojp wants to merge 1 commits into bitcoin:master from jeanpablojp:script-tests-const-scriptcode changing 1 files +11 −0
  1. jeanpablojp commented at 1:25 PM on July 29, 2026: none

    Follow-up to #35664.

    While going through which script error codes are covered by src/test/data/script_tests.json, I noticed that the two errors gated behind SCRIPT_VERIFY_CONST_SCRIPTCODE are never asserted anywhere in the test suite:

    • SCRIPT_ERR_OP_CODESEPARATOR shows up only once, as a mempool reject string in test/functional/data/invalid_txs.py. Nothing asserts it at the script level.
    • SCRIPT_ERR_SIG_FINDANDDELETE is not asserted by any test.

    tx_invalid.json does contain a SCRIPT_VERIFY_CONST_SCRIPTCODE section, but those tests can only state that a transaction is invalid, not which error made it fail. script_tests.json is the harness that verifies exact error codes, and today it has no vector that uses the CONST_SCRIPTCODE flag.

    This PR adds one section with six static vectors:

    • OP_CODESEPARATOR in an executed pre-segwit script fails with its own error code.
    • OP_CODESEPARATOR inside an unexecuted IF branch fails as well: the check in EvalScript happens before the fExec guard, so the opcode is rejected even though it never runs. This rule had no error-level coverage before.
    • A control vector: the same unexecuted-branch script passes when the flag is off.
    • A signature push that also appears in the scriptPubKey makes CHECKSIG fail with SIG_FINDANDDELETE, since FindAndDelete locates the signature inside the scriptCode.
    • The same case for CHECKMULTISIG, which calls FindAndDelete for each signature in its own loop.
    • A control vector: with the flag off, FindAndDelete silently removes the push and the script still evaluates.

    Both checks trigger before any signature verification happens, so the vectors can rely on a dummy signature — the same approach used in #35664.

    To confirm that the expected errors are the ones that really fire, I first added the vectors expecting OK, let the harness report the actual error for each one, and then set the expectations accordingly. Tested with:

    cmake --build build --target test_bitcoin
    build/bin/test_bitcoin --run_test=script_tests/script_json_test
    
  2. test: add CONST_SCRIPTCODE failure-path vectors to script_tests.json 829e44a115
  3. DrahtBot added the label Tests on Jul 29, 2026
  4. DrahtBot commented at 1:25 PM on July 29, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35835.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-31 20:50 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me