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
This commit is contained in:
Lőrinc
2026-05-06 09:34:12 +02:00
parent aa1d0d7cd7
commit ac58e6c53c

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);
}