mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-15 11:36:00 -05:00
![Ryan Ofsky](/assets/img/avatar_default.png)
db77f87c63
scripted-diff: move settings to common namespace (TheCharlatan)c27e4bdc35
move-only: Move settings to the common library (TheCharlatan)c2dae5d7d8
kernel: Remove chainparams, chainparamsbase, args, settings from kernel library (TheCharlatan)05870b1c92
refactor: Remove gArgs access from validation.cpp (TheCharlatan)8789b11114
refactor: Add path argument to FindSnapshotChainstateDir (TheCharlatan)ef95be334f
refactor: Add stop_at_height option in ChainstateManager (TheCharlatan) Pull request description: This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/27587 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". --- This completes the removal of the node's chainparams, chainparamsbase, args and settings files and their respective classes from the kernel library. This is the last pull request in a long series working towards decoupling the `ArgsManager` and the `gArgs` global from kernel code. These prior pull requests are: https://github.com/bitcoin/bitcoin/pull/26177 https://github.com/bitcoin/bitcoin/pull/27125 https://github.com/bitcoin/bitcoin/pull/25527 https://github.com/bitcoin/bitcoin/pull/25487 https://github.com/bitcoin/bitcoin/pull/25290 ACKs for top commit: MarcoFalke: lgtm ACKdb77f87c63
🍄 hebasto: ACKdb77f87c63
, I have reviewed the code and it looks OK. ryanofsky: Code review ACKdb77f87c63
. Looks great! Tree-SHA512: cbfbd705d056f2f10f16810d4f869eb152362fff2c5ddae5e1ac6785deae095588e52ad48b29d921962b085e51de1e0ecab6e50f46149ffe3c16250608a2c93a
142 lines
5.3 KiB
C++
142 lines
5.3 KiB
C++
// Copyright (c) 2020-2022 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 <blockfilter.h>
|
|
#include <clientversion.h>
|
|
#include <common/args.h>
|
|
#include <common/settings.h>
|
|
#include <common/system.h>
|
|
#include <common/url.h>
|
|
#include <netbase.h>
|
|
#include <outputtype.h>
|
|
#include <rpc/client.h>
|
|
#include <rpc/request.h>
|
|
#include <rpc/server.h>
|
|
#include <rpc/util.h>
|
|
#include <script/descriptor.h>
|
|
#include <script/script.h>
|
|
#include <serialize.h>
|
|
#include <streams.h>
|
|
#include <test/fuzz/FuzzedDataProvider.h>
|
|
#include <test/fuzz/fuzz.h>
|
|
#include <test/fuzz/util.h>
|
|
#include <util/error.h>
|
|
#include <util/fees.h>
|
|
#include <util/strencodings.h>
|
|
#include <util/string.h>
|
|
#include <util/translation.h>
|
|
|
|
#include <cassert>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <ios>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
enum class FeeEstimateMode;
|
|
|
|
FUZZ_TARGET(string)
|
|
{
|
|
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
|
const std::string random_string_1 = fuzzed_data_provider.ConsumeRandomLengthString(32);
|
|
const std::string random_string_2 = fuzzed_data_provider.ConsumeRandomLengthString(32);
|
|
const std::vector<std::string> random_string_vector = ConsumeRandomLengthStringVector(fuzzed_data_provider);
|
|
|
|
(void)AmountErrMsg(random_string_1, random_string_2);
|
|
(void)AmountHighWarn(random_string_1);
|
|
BlockFilterType block_filter_type;
|
|
(void)BlockFilterTypeByName(random_string_1, block_filter_type);
|
|
(void)Capitalize(random_string_1);
|
|
(void)CopyrightHolders(random_string_1);
|
|
FeeEstimateMode fee_estimate_mode;
|
|
(void)FeeModeFromString(random_string_1, fee_estimate_mode);
|
|
const auto width{fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 1000)};
|
|
(void)FormatParagraph(random_string_1, width, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, width));
|
|
(void)FormatSubVersion(random_string_1, fuzzed_data_provider.ConsumeIntegral<int>(), random_string_vector);
|
|
(void)GetDescriptorChecksum(random_string_1);
|
|
(void)HelpExampleCli(random_string_1, random_string_2);
|
|
(void)HelpExampleRpc(random_string_1, random_string_2);
|
|
(void)HelpMessageGroup(random_string_1);
|
|
(void)HelpMessageOpt(random_string_1, random_string_2);
|
|
(void)IsDeprecatedRPCEnabled(random_string_1);
|
|
(void)Join(random_string_vector, random_string_1);
|
|
(void)JSONRPCError(fuzzed_data_provider.ConsumeIntegral<int>(), random_string_1);
|
|
const common::Settings settings;
|
|
(void)OnlyHasDefaultSectionSetting(settings, random_string_1, random_string_2);
|
|
(void)ParseNetwork(random_string_1);
|
|
(void)ParseOutputType(random_string_1);
|
|
(void)RemovePrefix(random_string_1, random_string_2);
|
|
(void)ResolveErrMsg(random_string_1, random_string_2);
|
|
try {
|
|
(void)RPCConvertNamedValues(random_string_1, random_string_vector);
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)RPCConvertValues(random_string_1, random_string_vector);
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
(void)SanitizeString(random_string_1);
|
|
(void)SanitizeString(random_string_1, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 3));
|
|
#ifndef WIN32
|
|
(void)ShellEscape(random_string_1);
|
|
#endif // WIN32
|
|
uint16_t port_out;
|
|
std::string host_out;
|
|
SplitHostPort(random_string_1, port_out, host_out);
|
|
(void)TimingResistantEqual(random_string_1, random_string_2);
|
|
(void)ToLower(random_string_1);
|
|
(void)ToUpper(random_string_1);
|
|
(void)TrimString(random_string_1);
|
|
(void)TrimString(random_string_1, random_string_2);
|
|
(void)urlDecode(random_string_1);
|
|
(void)ContainsNoNUL(random_string_1);
|
|
(void)_(random_string_1.c_str());
|
|
try {
|
|
throw scriptnum_error{random_string_1};
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
|
|
{
|
|
DataStream data_stream{};
|
|
std::string s;
|
|
auto limited_string = LIMITED_STRING(s, 10);
|
|
data_stream << random_string_1;
|
|
try {
|
|
data_stream >> limited_string;
|
|
assert(data_stream.empty());
|
|
assert(s.size() <= random_string_1.size());
|
|
assert(s.size() <= 10);
|
|
if (!random_string_1.empty()) {
|
|
assert(!s.empty());
|
|
}
|
|
} catch (const std::ios_base::failure&) {
|
|
}
|
|
}
|
|
{
|
|
DataStream data_stream{};
|
|
const auto limited_string = LIMITED_STRING(random_string_1, 10);
|
|
data_stream << limited_string;
|
|
std::string deserialized_string;
|
|
data_stream >> deserialized_string;
|
|
assert(data_stream.empty());
|
|
assert(deserialized_string == random_string_1);
|
|
}
|
|
{
|
|
int64_t amount_out;
|
|
(void)ParseFixedPoint(random_string_1, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 1024), &amount_out);
|
|
}
|
|
{
|
|
const auto single_split{SplitString(random_string_1, fuzzed_data_provider.ConsumeIntegral<char>())};
|
|
assert(single_split.size() >= 1);
|
|
const auto any_split{SplitString(random_string_1, random_string_2)};
|
|
assert(any_split.size() >= 1);
|
|
}
|
|
{
|
|
(void)Untranslated(random_string_1);
|
|
const bilingual_str bs1{random_string_1, random_string_2};
|
|
const bilingual_str bs2{random_string_2, random_string_1};
|
|
(void)(bs1 + bs2);
|
|
}
|
|
}
|