From ac58e6c53c262e08584cb809daf3fbc8dd4d3732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Wed, 6 May 2026 09:34:12 +0200 Subject: [PATCH] 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 --- src/test/fuzz/coinscache_sim.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/fuzz/coinscache_sim.cpp b/src/test/fuzz/coinscache_sim.cpp index 9d41a6c058b..15ece2e4af0 100644 --- a/src/test/fuzz/coinscache_sim.cpp +++ b/src/test/fuzz/coinscache_sim.cpp @@ -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); }