mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 02:33:24 -03:00
fuzz: add coverage for bitcoinconsensus_verify_script_with_spent_outputs
Co-authored-by: Antonie Poinsot <darosior@protonmail.com>
This commit is contained in:
parent
c5f2a757d7
commit
ff8e2fc2e2
1 changed files with 19 additions and 0 deletions
|
@ -28,4 +28,23 @@ FUZZ_TARGET(script_bitcoin_consensus)
|
|||
}
|
||||
(void)bitcoinconsensus_verify_script(random_bytes_1.data(), random_bytes_1.size(), random_bytes_2.data(), random_bytes_2.size(), n_in, flags, err_p);
|
||||
(void)bitcoinconsensus_verify_script_with_amount(random_bytes_1.data(), random_bytes_1.size(), money, random_bytes_2.data(), random_bytes_2.size(), n_in, flags, err_p);
|
||||
|
||||
std::vector<UTXO> spent_outputs;
|
||||
std::vector<std::vector<unsigned char>> spent_spks;
|
||||
if (n_in <= 24386) {
|
||||
spent_outputs.reserve(n_in);
|
||||
spent_spks.reserve(n_in);
|
||||
for (size_t i = 0; i < n_in; ++i) {
|
||||
spent_spks.push_back(ConsumeRandomLengthByteVector(fuzzed_data_provider));
|
||||
const CAmount value{ConsumeMoney(fuzzed_data_provider)};
|
||||
const auto spk_size{static_cast<unsigned>(spent_spks.back().size())};
|
||||
spent_outputs.push_back({.scriptPubKey = spent_spks.back().data(), .scriptPubKeySize = spk_size, .value = value});
|
||||
}
|
||||
}
|
||||
|
||||
const auto spent_outs_size{static_cast<unsigned>(spent_outputs.size())};
|
||||
|
||||
(void)bitcoinconsensus_verify_script_with_spent_outputs(
|
||||
random_bytes_1.data(), random_bytes_1.size(), money, random_bytes_2.data(), random_bytes_2.size(),
|
||||
spent_outputs.data(), spent_outs_size, n_in, flags, err_p);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue