6#include <chainparams.h>
26 return std::clamp<int32_t>(g_setup->
m_node.
args->
GetIntArg(
"-checkaddrman", 0), 0, 1000000);
33 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
34 g_setup = testing_setup.get();
43 auto addr_man_ptr{std::make_unique<AddrManDeterministic>(netgroupman, fuzzed_data_provider,
GetCheckRatio())};
44 if (fuzzed_data_provider.ConsumeBool()) {
49 }
catch (
const std::ios_base::failure&) {
50 addr_man_ptr = std::make_unique<AddrManDeterministic>(netgroupman, fuzzed_data_provider,
GetCheckRatio());
54 ConnmanTestMsg connman{fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
55 fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
59 fuzzed_data_provider.ConsumeBool()};
61 const uint64_t max_outbound_limit{fuzzed_data_provider.ConsumeIntegral<uint64_t>()};
64 connman.Init(options);
69 std::string random_string;
73 connman.AddTestNode(p2p_node);
86 random_string = fuzzed_data_provider.ConsumeRandomLengthString(64);
89 connman.AddNode({random_string, fuzzed_data_provider.ConsumeBool()});
92 connman.CheckIncomingNonce(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
95 connman.DisconnectNode(fuzzed_data_provider.ConsumeIntegral<
NodeId>());
98 connman.DisconnectNode(random_netaddr);
101 connman.DisconnectNode(random_string);
104 connman.DisconnectNode(random_subnet);
107 connman.ForEachNode([](
auto) {});
110 (void)connman.ForNode(fuzzed_data_provider.ConsumeIntegral<
NodeId>(), [&](
auto) {
return fuzzed_data_provider.ConsumeBool(); });
113 auto max_addresses = fuzzed_data_provider.ConsumeIntegral<
size_t>();
114 auto max_pct = fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(0, 100);
115 auto filtered = fuzzed_data_provider.ConsumeBool();
116 (void)connman.GetAddresses(max_addresses, max_pct, std::nullopt, filtered);
119 auto max_addresses = fuzzed_data_provider.ConsumeIntegral<
size_t>();
120 auto max_pct = fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(0, 100);
121 (void)connman.GetAddresses(random_node, max_addresses, max_pct);
124 (void)connman.GetDeterministicRandomizer(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
130 (void)connman.OutboundTargetReached(fuzzed_data_provider.ConsumeBool());
136 connman.PushMessage(&random_node, std::move(serialized_net_msg));
139 connman.RemoveAddedNode(random_string);
142 connman.SetNetworkActive(fuzzed_data_provider.ConsumeBool());
145 connman.SetTryNewOutboundPeer(fuzzed_data_provider.ConsumeBool());
148 (void)connman.GetAddedNodeInfo(fuzzed_data_provider.ConsumeBool());
149 (void)connman.GetExtraFullOutboundCount();
150 (void)connman.GetLocalServices();
151 assert(connman.GetMaxOutboundTarget() == max_outbound_limit);
152 (void)connman.GetMaxOutboundTimeframe();
153 (void)connman.GetMaxOutboundTimeLeftInCycle();
154 (void)connman.GetNetworkActive();
155 std::vector<CNodeStats> stats;
156 connman.GetNodeStats(stats);
157 (void)connman.GetOutboundTargetBytesLeft();
158 (void)connman.GetTotalBytesRecv();
159 (void)connman.GetTotalBytesSent();
160 (void)connman.GetTryNewOutboundPeer();
161 (void)connman.GetUseAddrmanOutgoing();
162 (void)connman.ASMapHealthCheck();
164 connman.ClearTestNodes();
static int32_t GetCheckRatio(const NodeContext &node_ctx)
const CChainParams & Params()
Return the currently selected parameters.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Information about a peer.
Double ended buffer combining vector and stream-like interfaces.
void initialize_connman()
FUZZ_TARGET(connman,.init=initialize_connman)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
uint64_t nMaxOutboundLimit
std::vector< unsigned char > data
Testing setup that configures a complete environment.
CNetAddr ConsumeNetAddr(FuzzedDataProvider &fuzzed_data_provider, FastRandomContext *rand) noexcept
Create a CNetAddr.
CSubNet ConsumeSubNet(FuzzedDataProvider &fuzzed_data_provider) noexcept
NetGroupManager ConsumeNetGroupManager(FuzzedDataProvider &fuzzed_data_provider) noexcept
std::unique_ptr< CNode > ConsumeNodeAsUniquePtr(FuzzedDataProvider &fdp, const std::optional< NodeId > &node_id_in=std::nullopt)
auto ConsumeNode(FuzzedDataProvider &fuzzed_data_provider, const std::optional< NodeId > &node_id_in=std::nullopt) noexcept
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
std::vector< B > ConsumeRandomLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
@ ZEROS
Seed with a compile time constant of zeros.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.