5#ifndef BITCOIN_TEST_UTIL_NET_H
6#define BITCOIN_TEST_UTIL_NET_H
29 vNodes.push_back(&
node);
106 assert(
false &&
"Move of Sock into MockSock not allowed.");
115 ssize_t
Send(
const void*,
size_t len,
int)
const override {
return len; }
117 ssize_t
Recv(
void* buf,
size_t len,
int flags)
const override
121 if ((
flags & MSG_PEEK) == 0) {
124 return consume_bytes;
127 int Connect(
const sockaddr*, socklen_t)
const override {
return 0; }
129 int GetSockOpt(
int level,
int opt_name,
void* opt_val, socklen_t* opt_len)
const override
131 std::memset(opt_val, 0x0, *opt_len);
135 bool Wait(std::chrono::milliseconds timeout,
137 Event* occurred =
nullptr)
const override
139 if (occurred !=
nullptr) {
140 *occurred = requested;
std::atomic< bool > flagInterruptMsgProc
int64_t m_peer_connect_timeout
NetEventsInterface * m_msgproc
CConnman(uint64_t seed0, uint64_t seed1, AddrMan &addrman, bool network_active=true)
Information about a peer.
virtual bool ProcessMessages(CNode *pnode, std::atomic< bool > &interrupt)=0
Process protocol messages received from a given node.
RAII helper class that manages a socket.
SOCKET m_socket
Contained socket.
A Span is an object that can refer to a contiguous sequence of objects.
A mocked Sock alternative that returns a statically contained data upon read and succeeds and ignores...
bool Wait(std::chrono::milliseconds timeout, Event requested, Event *occurred=nullptr) const override
Wait for readiness for input (recv) or output (send).
int GetSockOpt(int level, int opt_name, void *opt_val, socklen_t *opt_len) const override
getsockopt(2) wrapper.
void Reset() override
Close if non-empty.
int Connect(const sockaddr *, socklen_t) const override
connect(2) wrapper.
const std::string m_contents
ssize_t Send(const void *, size_t len, int) const override
send(2) wrapper.
StaticContentsSock & operator=(Sock &&other) override
Move assignment operator, grab the socket from another object and close ours (if set).
~StaticContentsSock() override
StaticContentsSock(const std::string &contents)
ssize_t Recv(void *buf, size_t len, int flags) const override
recv(2) wrapper.
ConnectionType
Different types of connections to a peer.
@ BLOCK_RELAY
We use block-relay-only connections to help prevent against partition attacks.
@ MANUAL
We open manual connections to addresses that users explicitly requested via the addnode RPC or the -a...
@ OUTBOUND_FULL_RELAY
These are the default connections that we use to connect with the network.
@ FEELER
Feeler connections are short-lived connections made to check that a node is alive.
@ INBOUND
Inbound connections are those initiated by a peer.
@ ADDR_FETCH
AddrFetch connections are short lived connections used to solicit addresses from peers.
@ NET_ONION
TOR (v2 or v3)
@ NET_UNROUTABLE
Addresses from these networks are not publicly routable on the global Internet.
@ NET_INTERNAL
A set of addresses that represent the hash of a string or FQDN.
ServiceFlags
nServices flags
void ProcessMessagesOnce(CNode &node)
bool ReceiveMsgFrom(CNode &node, CSerializedNetMsg &ser_msg) const
void SetPeerConnectTimeout(int64_t timeout)
void NodeReceiveMsgBytes(CNode &node, Span< const uint8_t > msg_bytes, bool &complete) const
void AddTestNode(CNode &node)
std::vector< NodeEvictionCandidate > GetRandomNodeEvictionCandidates(int n_candidates, FastRandomContext &random_context)
constexpr ServiceFlags ALL_SERVICE_FLAGS[]
constexpr ConnectionType ALL_CONNECTION_TYPES[]
constexpr auto ALL_NETWORKS
constexpr NetPermissionFlags ALL_NET_PERMISSION_FLAGS[]