MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / FUZZ_TARGET

Function FUZZ_TARGET

src/test/fuzz/script_interpreter.cpp:19–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17bool CastToBool(const std::vector<unsigned char>& vch);
18
19FUZZ_TARGET(script_interpreter)
20{
21 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
22 {
23 const CScript script_code = ConsumeScript(fuzzed_data_provider);
24 const std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
25 if (mtx) {
26 const CTransaction tx_to{*mtx};
27 const unsigned int in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
28 if (in < tx_to.vin.size()) {
29 auto n_hash_type = fuzzed_data_provider.ConsumeIntegral<int>();
30 auto amount = ConsumeMoney(fuzzed_data_provider);
31 auto sigversion = fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0});
32 (void)SignatureHash(script_code, tx_to, in, n_hash_type, amount, sigversion, nullptr);
33 const std::optional<CMutableTransaction> mtx_precomputed = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
34 if (mtx_precomputed) {
35 const CTransaction tx_precomputed{*mtx_precomputed};
36 const PrecomputedTransactionData precomputed_transaction_data{tx_precomputed};
37 n_hash_type = fuzzed_data_provider.ConsumeIntegral<int>();
38 amount = ConsumeMoney(fuzzed_data_provider);
39 sigversion = fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0});
40 (void)SignatureHash(script_code, tx_to, in, n_hash_type, amount, sigversion, &precomputed_transaction_data);
41 }
42 }
43 }
44 }
45 {
46 (void)CastToBool(ConsumeRandomLengthByteVector(fuzzed_data_provider));
47 }
48}
49
50/** Differential fuzzing for SignatureHash with and without cache. */
51FUZZ_TARGET(sighash_cache)

Callers

nothing calls this directly

Calls 11

ConsumeScriptFunction · 0.85
ConsumeMoneyFunction · 0.85
SignatureHashFunction · 0.85
CastToBoolFunction · 0.85
ConsumeTransactionFunction · 0.85
PickValueInArrayMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected