MCPcopy Create free account
hub / github.com/ElementsProject/elements / FUZZ_TARGET

Function FUZZ_TARGET

src/test/fuzz/script_descriptor_cache.cpp:16–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include <vector>
15
16FUZZ_TARGET(script_descriptor_cache)
17{
18 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
19 DescriptorCache descriptor_cache;
20 LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
21 const std::vector<uint8_t> code = fuzzed_data_provider.ConsumeBytes<uint8_t>(BIP32_EXTKEY_SIZE);
22 if (code.size() == BIP32_EXTKEY_SIZE) {
23 CExtPubKey xpub;
24 xpub.Decode(code.data());
25 const uint32_t key_exp_pos = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
26 CExtPubKey xpub_fetched;
27 if (fuzzed_data_provider.ConsumeBool()) {
28 (void)descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched);
29 descriptor_cache.CacheParentExtPubKey(key_exp_pos, xpub);
30 assert(descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched));
31 } else {
32 const uint32_t der_index = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
33 (void)descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched);
34 descriptor_cache.CacheDerivedExtPubKey(key_exp_pos, der_index, xpub);
35 assert(descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched));
36 }
37 assert(xpub == xpub_fetched);
38 }
39 (void)descriptor_cache.GetCachedParentExtPubKeys();
40 (void)descriptor_cache.GetCachedDerivedExtPubKeys();
41 }
42}

Callers

nothing calls this directly

Calls 10

ConsumeBoolMethod · 0.80
CacheParentExtPubKeyMethod · 0.80
CacheDerivedExtPubKeyMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
DecodeMethod · 0.45

Tested by

no test coverage detected