6#include <chainparams.h>
28 return std::clamp<int32_t>(
g_setup->m_node.args->GetIntArg(
"-checkaddrman", 0), 0, 1000000);
45 auto addr_man_ptr{std::make_unique<AddrManDeterministic>(netgroupman, fuzzed_data_provider,
GetCheckRatio())};
51 }
catch (
const std::ios_base::failure&) {
52 addr_man_ptr = std::make_unique<AddrManDeterministic>(netgroupman, fuzzed_data_provider,
GetCheckRatio());
60 CreateSock = [&fuzzed_data_provider](int, int, int) {
61 return std::make_unique<FuzzedSock>(fuzzed_data_provider);
66 g_dns_lookup = [&fuzzed_data_provider](
const std::string&, bool) {
67 return std::vector<CNetAddr>{
ConsumeNetAddr(fuzzed_data_provider)};
78 const uint64_t max_outbound_limit{fuzzed_data_provider.
ConsumeIntegral<uint64_t>()};
82 connman.
Init(options);
137 auto filtered = fuzzed_data_provider.
ConsumeBool();
143 (void)connman.
GetAddresses(random_node, max_addresses, max_pct);
149 (void)connman.
GetNodeCount(fuzzed_data_provider.
PickValueInArray({ConnectionDirection::None, ConnectionDirection::In, ConnectionDirection::Out, ConnectionDirection::Both}));
158 connman.
PushMessage(&random_node, std::move(serialized_net_msg));
188 CreateSock(AF_INET, SOCK_STREAM, IPPROTO_TCP),
198 options.
vWhiteBinds = std::vector<NetWhitebindPermissions>{
223 std::vector<CNodeStats> stats;
static int32_t GetCheckRatio(const NodeContext &node_ctx)
const TestingSetup * g_setup
const CChainParams & Params()
Return the currently selected parameters.
A CService with information about it as peer.
void ForEachNode(const NodeFn &func)
bool ForNode(NodeId id, std::function< bool(CNode *pnode)> func)
bool GetNetworkActive() const
bool GetTryNewOutboundPeer() const
std::vector< CAddress > GetAddresses(CNode &requestor, size_t max_addresses, size_t max_pct)
Return addresses from the per-requestor cache.
void SetTryNewOutboundPeer(bool flag)
bool OutboundTargetReached(bool historicalBlockServingLimit) const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex)
uint64_t GetMaxOutboundTarget() const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex)
bool DisconnectNode(std::string_view node)
std::chrono::seconds GetMaxOutboundTimeframe() const
ServiceFlags GetLocalServices() const
bool AddNode(const AddedNodeParams &add) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex)
CSipHasher GetDeterministicRandomizer(uint64_t id) const
Get a unique deterministic randomizer.
std::vector< AddedNodeInfo > GetAddedNodeInfo(bool include_connected) const EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex)
size_t GetNodeCount(ConnectionDirection) const
void GetNodeStats(std::vector< CNodeStats > &vstats) const
int GetExtraFullOutboundCount() const
uint64_t GetTotalBytesRecv() const
bool OpenNetworkConnection(const CAddress &addrConnect, bool fCountFailure, CountingSemaphoreGrant<> &&grant_outbound, const char *pszDest, ConnectionType conn_type, bool use_v2transport, const std::optional< Proxy > &proxy_override=std::nullopt) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex)
Open a new P2P connection and initialize it with the PeerManager at m_msgproc.
void SetNetworkActive(bool active)
std::chrono::seconds GetMaxOutboundTimeLeftInCycle() const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex)
bool RemoveAddedNode(std::string_view node) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex)
std::vector< CAddress > GetAddressesUnsafe(size_t max_addresses, size_t max_pct, std::optional< Network > network, bool filtered=true) const
Return randomly selected addresses.
bool CheckIncomingNonce(uint64_t nonce)
void Init(const Options &connOptions) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex
uint64_t GetTotalBytesSent() const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex)
uint64_t GetOutboundTargetBytesLeft() const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex)
void PushMessage(CNode *pnode, CSerializedNetMsg &&msg) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex)
bool GetUseAddrmanOutgoing() const
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])
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()
#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::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
std::vector< NetWhitebindPermissions > vWhiteBinds
uint64_t nMaxOutboundLimit
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< unsigned char > data
void SocketHandlerPublic()
void CreateNodeFromAcceptedSocketPublic(std::unique_ptr< Sock > sock, NetPermissionFlags permissions, const CAddress &addr_bind, const CAddress &addr_peer)
bool InitBindsPublic(const CConnman::Options &options)
void AddTestNode(CNode &node)
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)
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.