HTTPServer: implement and test AcceptConnection()

AcceptConnection() is mostly copied from CConmann in net.cpp
and then modernized.

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This commit is contained in:
Matthew Zipkin
2025-06-04 14:14:13 -04:00
parent f5bc018948
commit 5a3aa1af28
5 changed files with 78 additions and 0 deletions

View File

@@ -395,5 +395,15 @@ BOOST_AUTO_TEST_CASE(http_server_socket_tests)
BOOST_REQUIRE(server.BindAndStartListening(addr_bind));
// We are bound and listening
BOOST_REQUIRE_EQUAL(server.GetListeningSocketCount(), 1);
// Pick up the phone, there's no one there
CService addr_connection;
BOOST_REQUIRE(!server.AcceptConnectionFromListeningSocket(addr_connection));
// Create a mock client and add it to the local CreateSock queue
ConnectClient();
// Accept the connection
BOOST_REQUIRE(server.AcceptConnectionFromListeningSocket(addr_connection));
BOOST_CHECK_EQUAL(addr_connection.ToStringAddrPort(), "5.5.5.5:6789");
}
BOOST_AUTO_TEST_SUITE_END()