mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-12 06:53:11 +02:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user