mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 13:42:10 +02:00
This is a whitespace-only clang-format change. To verify it, one can run: ```sh (git show | git apply --reverse ) && ( git diff -U0 | ./contrib/devtools/clang-format-diff.py -p1 -i -v ) && git diff HEAD ``` A few minor, non-macro formatting adjustments were made in touched files: * `src/wallet/test/fuzz/crypter.cpp`: Removed a redundant double semicolon * `src/test/fuzz/txorphan.cpp`: Corrected indentation on an `else if` block. * `src/test/fuzz/mini_miner.cpp`: Removed an unnecessary empty line.
43 lines
1.9 KiB
C++
43 lines
1.9 KiB
C++
// Copyright (c) 2020-present The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <pubkey.h>
|
|
#include <script/descriptor.h>
|
|
#include <test/fuzz/FuzzedDataProvider.h>
|
|
#include <test/fuzz/fuzz.h>
|
|
#include <test/fuzz/util.h>
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
FUZZ_TARGET(script_descriptor_cache)
|
|
{
|
|
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
|
DescriptorCache descriptor_cache;
|
|
LIMITED_WHILE (fuzzed_data_provider.ConsumeBool(), 10000) {
|
|
const std::vector<uint8_t> code = fuzzed_data_provider.ConsumeBytes<uint8_t>(BIP32_EXTKEY_SIZE);
|
|
if (code.size() == BIP32_EXTKEY_SIZE) {
|
|
CExtPubKey xpub;
|
|
xpub.Decode(code.data());
|
|
const uint32_t key_exp_pos = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
|
|
CExtPubKey xpub_fetched;
|
|
if (fuzzed_data_provider.ConsumeBool()) {
|
|
(void)descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched);
|
|
descriptor_cache.CacheParentExtPubKey(key_exp_pos, xpub);
|
|
assert(descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched));
|
|
} else {
|
|
const uint32_t der_index = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
|
|
(void)descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched);
|
|
descriptor_cache.CacheDerivedExtPubKey(key_exp_pos, der_index, xpub);
|
|
assert(descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched));
|
|
}
|
|
assert(xpub == xpub_fetched);
|
|
}
|
|
(void)descriptor_cache.GetCachedParentExtPubKeys();
|
|
(void)descriptor_cache.GetCachedDerivedExtPubKeys();
|
|
}
|
|
}
|