mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge #20375: fuzz: Improve coverage for CPartialMerkleTree fuzzing harness
3c77b8009de9457c356c0bf4362d11bb99a17bb7 fuzz: Improve coverage for CPartialMerkleTree fuzzing harness (practicalswift) Pull request description: Improve coverage for `CPartialMerkleTree` fuzzing harness. See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the [Bitcoin Core fuzzing corpus repo](https://github.com/bitcoin-core/qa-assets). Happy fuzzing :) ACKs for top commit: MarcoFalke: ACK 3c77b8009de9457c356c0bf4362d11bb99a17bb7 Tree-SHA512: a1fa0f7650a5ee5ff83f35e41b9faf6c34671fc304b9af00e5b83073f21d50bcbe91c2428fa64d05dc42a7c521bfd24031e307c7f4abf9ded469d69a55c5d64a
This commit is contained in:
parent
25ae9444cd
commit
c545e11426
@ -16,12 +16,36 @@
|
||||
FUZZ_TARGET(merkleblock)
|
||||
{
|
||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||
std::optional<CPartialMerkleTree> partial_merkle_tree = ConsumeDeserializable<CPartialMerkleTree>(fuzzed_data_provider);
|
||||
if (!partial_merkle_tree) {
|
||||
return;
|
||||
CPartialMerkleTree partial_merkle_tree;
|
||||
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 1)) {
|
||||
case 0: {
|
||||
const std::optional<CPartialMerkleTree> opt_partial_merkle_tree = ConsumeDeserializable<CPartialMerkleTree>(fuzzed_data_provider);
|
||||
if (opt_partial_merkle_tree) {
|
||||
partial_merkle_tree = *opt_partial_merkle_tree;
|
||||
}
|
||||
break;
|
||||
}
|
||||
(void)partial_merkle_tree->GetNumTransactions();
|
||||
case 1: {
|
||||
CMerkleBlock merkle_block;
|
||||
const std::optional<CBlock> opt_block = ConsumeDeserializable<CBlock>(fuzzed_data_provider);
|
||||
CBloomFilter bloom_filter;
|
||||
std::set<uint256> txids;
|
||||
if (opt_block && !opt_block->vtx.empty()) {
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
merkle_block = CMerkleBlock{*opt_block, bloom_filter};
|
||||
} else if (fuzzed_data_provider.ConsumeBool()) {
|
||||
while (fuzzed_data_provider.ConsumeBool()) {
|
||||
txids.insert(ConsumeUInt256(fuzzed_data_provider));
|
||||
}
|
||||
merkle_block = CMerkleBlock{*opt_block, txids};
|
||||
}
|
||||
}
|
||||
partial_merkle_tree = merkle_block.txn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
(void)partial_merkle_tree.GetNumTransactions();
|
||||
std::vector<uint256> matches;
|
||||
std::vector<unsigned int> indices;
|
||||
(void)partial_merkle_tree->ExtractMatches(matches, indices);
|
||||
(void)partial_merkle_tree.ExtractMatches(matches, indices);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user