6#include <chainparams.h>
36 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
52 }
catch (
const std::ios_base::failure&) {
84 auto consume_whitelist = [&]() {
86 for (
auto& entry : result) {
95 connman.Init(options);
106 p2p_node.fSuccessfullyConnected =
true;
107 connman.AddTestNode(p2p_node);
135 connman.DisconnectNode(random_netaddr);
141 connman.DisconnectNode(random_subnet);
144 connman.ForEachNode([](
auto) {});
153 (void)connman.GetAddressesUnsafe(max_addresses, max_pct, std::nullopt, filtered);
158 (void)connman.GetAddresses(random_node, max_addresses, max_pct);
173 connman.PushMessage(&random_node, std::move(serialized_net_msg));
191 connman.OpenNetworkConnection(
202 connman.CreateNodeFromAcceptedSocketPublic(
203 CreateSock(AF_INET, SOCK_STREAM, IPPROTO_TCP),
213 options.
vWhiteBinds = std::vector<NetWhitebindPermissions>{
225 connman.InitBindsPublic(options);
228 connman.SocketHandlerPublic();
232 (void)connman.GetExtraFullOutboundCount();
233 (void)connman.GetLocalServices();
234 assert(connman.GetMaxOutboundTarget() == max_outbound_limit);
235 (void)connman.GetMaxOutboundTimeframe();
236 (void)connman.GetMaxOutboundTimeLeftInCycle();
237 (void)connman.GetNetworkActive();
238 std::vector<CNodeStats> stats;
239 connman.GetNodeStats(stats);
240 (void)connman.GetOutboundTargetBytesLeft();
241 (void)connman.GetTotalBytesRecv();
242 (void)connman.GetTotalBytesSent();
243 (void)connman.GetTryNewOutboundPeer();
244 (void)connman.GetUseAddrmanOutgoing();
245 (void)connman.ASMapHealthCheck();
247 connman.ClearTestNodes();
static int32_t GetCheckRatio(const NodeContext &node_ctx)
const TestingSetup * g_setup
const CChainParams & Params()
Return the currently selected parameters.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
A CService with information about it as peer.
Information about a peer.
Double ended buffer combining vector and stream-like interfaces.
std::string ConsumeRandomLengthString(size_t max_length)
T ConsumeIntegralInRange(T min, T max)
T PickValueInArray(const T(&array)[size])
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
ConnectionType
Different types of connections to a peer.
@ OUTBOUND_FULL_RELAY
These are the default connections that we use to connect with the network.
@ INBOUND
Inbound connections are those initiated by a peer.
void initialize_connman()
FUZZ_TARGET(connman,.init=initialize_connman)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
std::function< std::unique_ptr< Sock >(int, int, int)> CreateSock
Socket factory.
std::vector< NetWhitebindPermissions > vWhiteBinds
uint64_t nMaxOutboundLimit
std::vector< NetWhitelistPermissions > vWhitelistedRangeIncoming
std::vector< CService > onion_binds
NetEventsInterface * m_msgproc
std::vector< CService > vBinds
bool bind_on_any
True if the user did not specify -bind= or -whitebind= and thus we should bind on 0....
std::vector< NetWhitelistPermissions > vWhitelistedRangeOutgoing
std::vector< unsigned char > data
Testing setup that configures a complete environment.
CAddress ConsumeAddress(FuzzedDataProvider &fuzzed_data_provider) noexcept
CNetAddr ConsumeNetAddr(FuzzedDataProvider &fuzzed_data_provider, FastRandomContext *rand) noexcept
Create a CNetAddr.
CService ConsumeService(FuzzedDataProvider &fuzzed_data_provider) noexcept
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)
std::vector< CService > ConsumeServiceVector(FuzzedDataProvider &fuzzed_data_provider, size_t max_vector_size=5) noexcept
auto ConsumeNode(FuzzedDataProvider &fuzzed_data_provider, const std::optional< NodeId > &node_id_in=std::nullopt) noexcept
FuzzedNetEvents ConsumeNetEvents(FuzzedDataProvider &fdp) noexcept
std::shared_ptr< CThreadInterrupt > ConsumeThreadInterrupt(FuzzedDataProvider &fuzzed_data_provider)
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
WeakEnumType ConsumeWeakEnum(FuzzedDataProvider &fuzzed_data_provider, const WeakEnumType(&all_types)[size]) 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
constexpr ConnectionType ALL_CONNECTION_TYPES[]
constexpr NetPermissionFlags ALL_NET_PERMISSION_FLAGS[]
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.
std::string random_string(uint32_t length)
FuzzedDataProvider & fuzzed_data_provider