mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-07-17 18:43:07 +02:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user