diff --git a/Assets/Mirror/Tests/Editor/NetworkServerTest.cs b/Assets/Mirror/Tests/Editor/NetworkServerTest.cs index 8458574dc..cf1108e2f 100644 --- a/Assets/Mirror/Tests/Editor/NetworkServerTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkServerTest.cs @@ -370,9 +370,11 @@ public void Send_ClientToServerMessage_MaxMessageSize() NetworkServer.Listen(1); ConnectClientBlocking(out _); - // send message & process + // calculate max := transport.max - message header int transportMax = transport.GetMaxPacketSize(Channels.Reliable); int messageMax = transportMax - MessagePacking.HeaderSize; + + // send message & process NetworkClient.Send(new VariableSizedMessage(messageMax)); ProcessMessages(); @@ -392,9 +394,11 @@ public void Send_ServerToClientMessage_MaxMessageSize() NetworkServer.Listen(1); ConnectClientBlocking(out NetworkConnectionToClient connectionToClient); - // send message & process + // calculate max := transport.max - message header int transportMax = transport.GetMaxPacketSize(Channels.Reliable); int messageMax = transportMax - MessagePacking.HeaderSize; + + // send message & process connectionToClient.Send(new VariableSizedMessage(messageMax)); ProcessMessages(); @@ -414,9 +418,11 @@ public void Send_ClientToServerMessage_LargerThanMaxMessageSize() NetworkServer.Listen(1); ConnectClientBlocking(out _); - // send message & process + // calculate max := transport.max - message header int transportMax = transport.GetMaxPacketSize(Channels.Reliable); int messageMax = transportMax - MessagePacking.HeaderSize; + + // send message & process LogAssert.Expect(LogType.Error, $"NetworkConnection.ValidatePacketSize: cannot send packet larger than {transportMax} bytes, was {transportMax + 1} bytes"); NetworkClient.Send(new VariableSizedMessage(messageMax + 1)); ProcessMessages(); @@ -437,9 +443,11 @@ public void Send_ServerToClientMessage_LargerThanMaxMessageSize() NetworkServer.Listen(1); ConnectClientBlocking(out NetworkConnectionToClient connectionToClient); - // send message & process + // calculate max := transport.max - message header int transportMax = transport.GetMaxPacketSize(Channels.Reliable); int messageMax = transportMax - MessagePacking.HeaderSize; + + // send message & process LogAssert.Expect(LogType.Error, $"NetworkConnection.ValidatePacketSize: cannot send packet larger than {transportMax} bytes, was {transportMax + 1} bytes"); connectionToClient.Send(new VariableSizedMessage(messageMax + 1)); ProcessMessages();