Merge bitcoin/bitcoin#35218: test: fix P2SH script in coins cache fuzz target

ac58e6c53c test: fix P2SH output in coins cache fuzz (Lőrinc)

Pull request description:

  ### 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:
  fa2670bd4b/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.

ACKs for top commit:
  Crypt-iQ:
    crACK ac58e6c53c
  brunoerg:
    ACK ac58e6c53c
  sedited:
    ACK ac58e6c53c

Tree-SHA512: 1f909dd25d9df87a923e6496145da0ada2b1fa6511b61fb2d203db4c7724f2341c898862a15e7051b952bca834e6654c70fba64a7bf223bfd6d399b3b5d9e59b
This commit is contained in:
merge-script
2026-05-07 00:06:45 +02:00

View File

@@ -70,7 +70,7 @@ struct PrecomputedData
coins[i].out.scriptPubKey[0] = OP_HASH160;
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;
coins[i].out.scriptPubKey[22] = OP_EQUAL;
break;
case 2: /* P2WPKH */
coins[i].out.scriptPubKey.resize(22);
@@ -446,7 +446,7 @@ FUZZ_TARGET(coinscache_sim)
}
}
// HaveCoinInCache ignores spent coins, so GetCacheSize() may exceed it. */
// HaveCoinInCache ignores spent coins, so GetCacheSize() may exceed it.
assert(cache.GetCacheSize() >= cache_size);
}