diff options
Diffstat (limited to 'src/test/util/net.h')
-rw-r--r-- | src/test/util/net.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/test/util/net.h b/src/test/util/net.h index 20c45058a1..ec6b4e6e88 100644 --- a/src/test/util/net.h +++ b/src/test/util/net.h @@ -5,7 +5,8 @@ #ifndef BITCOIN_TEST_UTIL_NET_H #define BITCOIN_TEST_UTIL_NET_H -#include <compat.h> +#include <compat/compat.h> +#include <node/eviction.h> #include <netaddress.h> #include <net.h> #include <util/sock.h> @@ -38,6 +39,14 @@ struct ConnmanTestMsg : public CConnman { m_nodes.clear(); } + void Handshake(CNode& node, + bool successfully_connected, + ServiceFlags remote_services, + ServiceFlags local_services, + NetPermissionFlags permission_flags, + int32_t version, + bool relay_txs); + void ProcessMessagesOnce(CNode& node) { m_msgproc->ProcessMessages(&node, flagInterruptMsgProc); } void NodeReceiveMsgBytes(CNode& node, Span<const uint8_t> msg_bytes, bool& complete) const; @@ -100,7 +109,7 @@ public: m_socket = INVALID_SOCKET - 1; } - ~StaticContentsSock() override { Reset(); } + ~StaticContentsSock() override { m_socket = INVALID_SOCKET; } StaticContentsSock& operator=(Sock&& other) override { @@ -108,11 +117,6 @@ public: return *this; } - void Reset() override - { - m_socket = INVALID_SOCKET; - } - ssize_t Send(const void*, size_t len, int) const override { return len; } ssize_t Recv(void* buf, size_t len, int flags) const override @@ -127,6 +131,10 @@ public: int Connect(const sockaddr*, socklen_t) const override { return 0; } + int Bind(const sockaddr*, socklen_t) const override { return 0; } + + int Listen(int) const override { return 0; } + std::unique_ptr<Sock> Accept(sockaddr* addr, socklen_t* addr_len) const override { if (addr != nullptr) { @@ -150,6 +158,14 @@ public: return 0; } + int SetSockOpt(int, int, const void*, socklen_t) const override { return 0; } + + int GetSockName(sockaddr* name, socklen_t* name_len) const override + { + std::memset(name, 0x0, *name_len); + return 0; + } + bool Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred = nullptr) const override @@ -160,6 +176,15 @@ public: return true; } + bool WaitMany(std::chrono::milliseconds timeout, EventsPerSock& events_per_sock) const override + { + for (auto& [sock, events] : events_per_sock) { + (void)sock; + events.occurred = events.requested; + } + return true; + } + private: const std::string m_contents; mutable size_t m_consumed; |