diff --git a/tests/Engine/Network/IpAddressTest.cpp b/tests/Engine/Network/IpAddressTest.cpp index 26c912926..4ab437a54 100644 --- a/tests/Engine/Network/IpAddressTest.cpp +++ b/tests/Engine/Network/IpAddressTest.cpp @@ -54,7 +54,7 @@ SCENARIO("IpAddress", "[NETWORK][IPADDRESS]") CHECK(Nz::IpAddress("1:2:3:4:5::7:8") == Nz::IpAddress(1, 2, 3, 4, 5, 0, 7, 8)); CHECK(Nz::IpAddress("1:2:3:4::7:8") == Nz::IpAddress(1, 2, 3, 4, 0, 0, 7, 8)); CHECK(Nz::IpAddress("1:2:3::7:8") == Nz::IpAddress(1, 2, 3, 0, 0, 0, 7, 8)); - CHECK(Nz::IpAddress("1:2::5:6:7:8") == Nz::IpAddress(1, 2, 0, 0, 0, 6, 7, 8)); + CHECK(Nz::IpAddress("1:2::5:6:7:8") == Nz::IpAddress(1, 2, 0, 0, 5, 6, 7, 8)); CHECK(Nz::IpAddress("1::7:8") == Nz::IpAddress(1, 0, 0, 0, 0, 0, 7, 8)); CHECK(Nz::IpAddress("1::8") == Nz::IpAddress(1, 0, 0, 0, 0, 0, 0, 8)); CHECK(Nz::IpAddress("::8") == Nz::IpAddress(0, 0, 0, 0, 0, 0, 0, 8)); diff --git a/tests/Engine/Network/TCPTest.cpp b/tests/Engine/Network/TCPTest.cpp index 04ef2928a..934b66fd5 100644 --- a/tests/Engine/Network/TCPTest.cpp +++ b/tests/Engine/Network/TCPTest.cpp @@ -25,18 +25,27 @@ SCENARIO("TCP", "[NETWORK][TCP]") REQUIRE(serverIP.IsValid()); Nz::TcpClient client; + CHECK(client.WaitForConnected(100) == Nz::SocketState::NotConnected); REQUIRE(client.Connect(serverIP) == Nz::SocketState::Connecting); Nz::IpAddress clientIP = client.GetRemoteAddress(); CHECK(clientIP.IsValid()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + REQUIRE(client.WaitForConnected(100) == Nz::SocketState::Connected); + + CHECK(client.IsBlockingEnabled()); + CHECK_FALSE(client.IsKeepAliveEnabled()); + CHECK_FALSE(client.IsLowDelayEnabled()); + CHECK(client.QueryReceiveBufferSize() > 0); + CHECK(client.QuerySendBufferSize() > 0); Nz::TcpClient serverToClient; REQUIRE(server.AcceptClient(&serverToClient)); WHEN("We send data from client") { + CHECK(serverToClient.EndOfStream()); + Nz::NetPacket packet(1); Nz::Vector3f vector123(1.f, 2.f, 3.f); packet << vector123; @@ -44,6 +53,8 @@ SCENARIO("TCP", "[NETWORK][TCP]") THEN("We should get it on the server") { + CHECK(!serverToClient.EndOfStream()); + Nz::NetPacket resultPacket; REQUIRE(serverToClient.ReceivePacket(&resultPacket)); diff --git a/tests/Engine/Network/UdpSocketTest.cpp b/tests/Engine/Network/UdpSocketTest.cpp index e078dd734..c933bd1f7 100644 --- a/tests/Engine/Network/UdpSocketTest.cpp +++ b/tests/Engine/Network/UdpSocketTest.cpp @@ -2,27 +2,22 @@ #include #include #include -#include SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]") { GIVEN("Two UdpSocket, one client, one server") { - std::random_device rd; - std::uniform_int_distribution dis(1025, 65535); - - Nz::UInt16 port = dis(rd); Nz::UdpSocket server(Nz::NetProtocol::IPv4); - REQUIRE(server.Bind(port) == Nz::SocketState::Bound); + REQUIRE(server.Bind(0) == Nz::SocketState::Bound); + + Nz::UInt16 port = server.GetBoundPort(); Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port); REQUIRE(serverIP.IsValid()); Nz::UdpSocket client(Nz::NetProtocol::IPv4); - REQUIRE(client.Bind(port + 1) == Nz::SocketState::Bound); - - Nz::IpAddress clientIP = client.GetBoundAddress(); - REQUIRE(clientIP.IsValid()); + CHECK_FALSE(client.IsBroadcastingEnabled()); + CHECK(client.QueryMaxDatagramSize() > 1500); WHEN("We send data from client") {