test: fix `P2SH` script in coins cache fuzz target #35218

pull l0rinc wants to merge 1 commits into bitcoin:master from l0rinc:l0rinc/fix-coinscache-p2sh-script changing 1 files +2 −2
  1. l0rinc commented at 7:41 AM on May 6, 2026: contributor

    Problem

    coinscache_sim manually constructs a 23-byte P2SH scriptPubKey, but placed OP_EQUAL at byte index 12. That index is inside the 20-byte script hash payload, so the constructed script did not match the standard P2SH layout: https://github.com/bitcoin/bitcoin/blob/fa2670bd4b5b199c417011942228ba87d1613030/src/script/script.cpp#L223-L230

    Fix

    Place OP_EQUAL after OP_HASH160, the 20-byte push opcode, and the 20-byte script hash. Also remove a stray trailing comment terminator in the same fuzz target.

  2. test: fix P2SH output in coins cache fuzz
    The `coinscache_sim` fuzz target builds a 23-byte P2SH scriptPubKey manually.
    Place `OP_EQUAL` at index 22, after `OP_HASH160`, the 20-byte push opcode, and the 20-byte script hash.
    This matches `CScript::IsPayToScriptHash()`, which checks byte 22 for `OP_EQUAL`, see src/script/script.cpp#L229
    ac58e6c53c
  3. DrahtBot added the label Tests on May 6, 2026
  4. DrahtBot commented at 7:41 AM on May 6, 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/35218.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK brunoerg, Crypt-iQ, sedited

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. brunoerg approved
  6. brunoerg commented at 9:06 AM on May 6, 2026: contributor

    ACK ac58e6c53c262e08584cb809daf3fbc8dd4d3732

    Can be tested with (instantly crashes on master):

    diff --git a/src/test/fuzz/coinscache_sim.cpp b/src/test/fuzz/coinscache_sim.cpp
    index 9d41a6c058..c0a0d4e4d2 100644
    --- a/src/test/fuzz/coinscache_sim.cpp
    +++ b/src/test/fuzz/coinscache_sim.cpp
    @@ -71,6 +71,7 @@ struct PrecomputedData
                     coins[i].out.scriptPubKey[1] = 20;
                     std::copy(hash.begin(), hash.begin() + 20, coins[i].out.scriptPubKey.begin() + 2);
                     coins[i].out.scriptPubKey[12] = OP_EQUAL;
    +                assert(coins[i].out.scriptPubKey.IsPayToScriptHash());
                     break;
                 case 2: /* P2WPKH */
                     coins[i].out.scriptPubKey.resize(22);
    
  7. Crypt-iQ commented at 12:02 PM on May 6, 2026: contributor

    crACK ac58e6c53c262e08584cb809daf3fbc8dd4d3732

  8. sedited approved
  9. sedited commented at 9:58 PM on May 6, 2026: contributor

    ACK ac58e6c53c262e08584cb809daf3fbc8dd4d3732

  10. sedited merged this on May 6, 2026
  11. sedited closed this on May 6, 2026

  12. luke-jr commented at 3:32 PM on May 7, 2026: member

    For reference, this fixes #27011 first released in v25.0


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-05-11 12:12 UTC

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