Skip to content

Commit 4e43d57

Browse files
author
vis2k
committed
Tests: MultipleClientServerTests use the same test config for faster runs
1 parent 7ac3f31 commit 4e43d57

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

kcp2k/Assets/Tests/Editor/MultiClientServerTests.cs

+16-16
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public class MultipleClientServerTests
2525
Interval: 1, // 1ms so at interval code at least runs.
2626
Timeout: 2000,
2727

28-
// windows can be configured separately to test differently sized windows
29-
// use 2x defaults so we can test larger max message than defaults too.
30-
// IMPORTANT: default max message needs 127 fragments.
31-
// default x2 needs 255 fragments.
32-
// kcp sends 'frg' as 1 byte, so 255 still fits.
33-
// need to try x3 to find possible bugs.
34-
SendWindowSize: Kcp.WND_SND * 3,
35-
ReceiveWindowSize: Kcp.WND_RCV * 3,
28+
// large window sizes so large messages are flushed with very few
29+
// update calls. otherwise tests take too long.
30+
SendWindowSize: Kcp.WND_SND * 1000,
31+
ReceiveWindowSize: Kcp.WND_RCV * 1000,
32+
33+
// congestion window _heavily_ restricts send/recv window sizes
34+
// sending a max sized message would require thousands of updates.
35+
CongestionWindow: false,
3636

3737
// maximum retransmit attempts until dead_link detected
3838
// default * 2 to check if configuration works
@@ -147,13 +147,13 @@ int ServerLastConnectionId()
147147
return server.connections.Last().Key;
148148
}
149149

150-
void UpdateSeveralTimes()
150+
void UpdateSeveralTimes(int amount)
151151
{
152152
// update serveral times to avoid flaky tests.
153153
// => need to update at 120 times for default maxed sized messages
154154
// where it requires 120+ fragments.
155155
// => need to update even more often for 2x default max sized
156-
for (int i = 0; i < 500; ++i)
156+
for (int i = 0; i < amount; ++i)
157157
{
158158
clientA.Tick();
159159
clientB.Tick();
@@ -168,37 +168,37 @@ void UpdateSeveralTimes()
168168
void ConnectClientsBlocking(string hostname = "127.0.0.1")
169169
{
170170
clientA.Connect(hostname, Port, config);
171-
UpdateSeveralTimes();
171+
UpdateSeveralTimes(5);
172172

173173
clientB.Connect(hostname, Port, config);
174-
UpdateSeveralTimes();
174+
UpdateSeveralTimes(5);
175175
}
176176

177177
// disconnect and give it enough time to handle
178178
void DisconnectClientsBlocking()
179179
{
180180
clientA.Disconnect();
181181
clientB.Disconnect();
182-
UpdateSeveralTimes();
182+
UpdateSeveralTimes(5);
183183
}
184184

185185
// kick and give it enough time to handle
186186
void KickClientBlocking(int connectionId)
187187
{
188188
server.Disconnect(connectionId);
189-
UpdateSeveralTimes();
189+
UpdateSeveralTimes(5);
190190
}
191191

192192
void SendClientToServerBlocking(KcpClient client, ArraySegment<byte> message, KcpChannel channel)
193193
{
194194
client.Send(message, channel);
195-
UpdateSeveralTimes();
195+
UpdateSeveralTimes(10);
196196
}
197197

198198
void SendServerToClientBlocking(int connectionId, ArraySegment<byte> message, KcpChannel channel)
199199
{
200200
server.Send(connectionId, message, channel);
201-
UpdateSeveralTimes();
201+
UpdateSeveralTimes(10);
202202
}
203203

204204
// tests ///////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)