Skip to content

Commit

Permalink
Fix socks tests in windows and handle errors better
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnerd committed Apr 19, 2019
1 parent ef1f1c5 commit 55aae6a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/unit_tests/net.cpp
Expand Up @@ -546,7 +546,7 @@ namespace
connected(false)
{
acceptor.open(boost::asio::ip::tcp::v4());
acceptor.bind(stream_type::endpoint{boost::asio::ip::tcp::v4(), 0});
acceptor.bind(stream_type::endpoint{boost::asio::ip::address_v4::loopback(), 0});
acceptor.listen();
acceptor.async_accept(server, [this] (boost::system::error_code error) {
this->connected = true;
Expand Down Expand Up @@ -621,7 +621,8 @@ TEST(socks_client, connect_command)
ASSERT_TRUE(test_client->set_connect_command("example.com", 8080));
EXPECT_FALSE(test_client->buffer().empty());
ASSERT_TRUE(net::socks::client::connect_and_send(std::move(test_client), io.acceptor.local_endpoint()));
while (!io.connected);
while (!io.connected)
ASSERT_FALSE(called);

const std::uint8_t expected_bytes[] = {
4, 1, 0x1f, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00,
Expand Down Expand Up @@ -657,7 +658,8 @@ TEST(socks_client, connect_command_failed)
);
EXPECT_FALSE(test_client->buffer().empty());
ASSERT_TRUE(net::socks::client::connect_and_send(std::move(test_client), io.acceptor.local_endpoint()));
while (!io.connected);
while (!io.connected)
ASSERT_FALSE(called);

const std::uint8_t expected_bytes[] = {
4, 1, 0x0b, 0xb8, 0x00, 0x00, 0x13, 0x88, 0x00
Expand Down Expand Up @@ -713,7 +715,8 @@ TEST(socks_client, resolve_command)
ASSERT_TRUE(test_client->set_resolve_command("example.com"));
EXPECT_FALSE(test_client->buffer().empty());
ASSERT_TRUE(net::socks::client::connect_and_send(test_client, io.acceptor.local_endpoint()));
while (!io.connected);
while (!io.connected)
ASSERT_EQ(0u, test_client->called_);

const std::uint8_t expected_bytes[] = {
4, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
Expand Down Expand Up @@ -753,7 +756,8 @@ TEST(socks_connector, host)
boost::unique_future<boost::asio::ip::tcp::socket> sock =
net::socks::connector{io.acceptor.local_endpoint()}("example.com", "8080", timeout);

while (!io.connected);
while (!io.connected)
ASSERT_FALSE(sock.is_ready());
const std::uint8_t expected_bytes[] = {
4, 1, 0x1f, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00,
'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm', 0x00
Expand All @@ -779,7 +783,8 @@ TEST(socks_connector, ipv4)
boost::unique_future<boost::asio::ip::tcp::socket> sock =
net::socks::connector{io.acceptor.local_endpoint()}("250.88.125.99", "8080", timeout);

while (!io.connected);
while (!io.connected)
ASSERT_FALSE(sock.is_ready());
const std::uint8_t expected_bytes[] = {
4, 1, 0x1f, 0x90, 0xfa, 0x58, 0x7d, 0x63, 0x00
};
Expand All @@ -804,7 +809,8 @@ TEST(socks_connector, error)
boost::unique_future<boost::asio::ip::tcp::socket> sock =
net::socks::connector{io.acceptor.local_endpoint()}("250.88.125.99", "8080", timeout);

while (!io.connected);
while (!io.connected)
ASSERT_FALSE(sock.is_ready());
const std::uint8_t expected_bytes[] = {
4, 1, 0x1f, 0x90, 0xfa, 0x58, 0x7d, 0x63, 0x00
};
Expand Down

0 comments on commit 55aae6a

Please sign in to comment.