mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
This commit effectively moves the definition of these constants out of the chainparamsbase to their own file. Using the ChainType enums provides better type safety compared to passing around strings. The commit is part of an ongoing effort to decouple the libbitcoinkernel library from the ArgsManager and other functionality that should not be part of the kernel library.
105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
// Copyright (c) 2009-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 <chainparams.h>
|
|
#include <core_io.h>
|
|
#include <rpc/client.h>
|
|
#include <rpc/util.h>
|
|
#include <test/fuzz/fuzz.h>
|
|
#include <util/chaintype.h>
|
|
|
|
#include <limits>
|
|
#include <string>
|
|
|
|
void initialize_parse_univalue()
|
|
{
|
|
SelectParams(ChainType::REGTEST);
|
|
}
|
|
|
|
FUZZ_TARGET_INIT(parse_univalue, initialize_parse_univalue)
|
|
{
|
|
const std::string random_string(buffer.begin(), buffer.end());
|
|
bool valid = true;
|
|
const UniValue univalue = [&] {
|
|
try {
|
|
return ParseNonRFCJSONValue(random_string);
|
|
} catch (const std::runtime_error&) {
|
|
valid = false;
|
|
return UniValue{};
|
|
}
|
|
}();
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
try {
|
|
(void)ParseHashO(univalue, "A");
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHashO(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHashV(univalue, "A");
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHashV(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHexO(univalue, "A");
|
|
} catch (const UniValue&) {
|
|
}
|
|
try {
|
|
(void)ParseHexO(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
}
|
|
try {
|
|
(void)ParseHexUV(univalue, "A");
|
|
(void)ParseHexUV(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHexV(univalue, "A");
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHexV(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseSighashString(univalue);
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)AmountFromValue(univalue);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
FlatSigningProvider provider;
|
|
(void)EvalDescriptorStringOrObject(univalue, provider);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseConfirmTarget(univalue, std::numeric_limits<unsigned int>::max());
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseDescriptorRange(univalue);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
}
|