@@ -9,6 +9,7 @@ import sc.framework.plugins.AbstractGame
9
9
import sc.framework.plugins.protocol.MoveRequest
10
10
import sc.networking.clients.LobbyClient
11
11
import sc.protocol.requests.*
12
+ import sc.protocol.room.ErrorMessage
12
13
import sc.server.Configuration
13
14
import sc.server.client.PlayerListener
14
15
import sc.server.client.TestLobbyClientListener
@@ -166,6 +167,8 @@ class RequestTest: RealServerTest() {
166
167
// Second player sends Move with value 42
167
168
player2.sendMessageToRoom(room.id, TestMove (42 ));
168
169
Thread .sleep(100 );
170
+ TestHelper .waitUntilTrue({ listener.newStateReceived }, 2000 )
171
+ listener.newStateReceived = false
169
172
170
173
// Request a move
171
174
admin.send(StepRequest (room.id))
@@ -177,15 +180,15 @@ class RequestTest: RealServerTest() {
177
180
p1Listener.waitForMessage(MoveRequest ::class )
178
181
179
182
p1Listener.clearMessages() shouldBe 0
183
+ p2Listener.clearMessages() shouldBe 0
180
184
// Second player sends Move not being his turn
181
185
player2.sendMessageToRoom(room.id, TestMove (73 ))
182
- // TODO this still fails sporadically
183
- TestHelper .waitUntilTrue({ listener.newStateReceived }, 1000 )
184
- listener.newStateReceived = false
186
+ p2Listener.waitForMessage(ErrorMessage ::class )
185
187
186
188
// There should not come another request
187
189
Thread .sleep(500 )
188
190
p1Listener.clearMessages() shouldBe 0
191
+ p2Listener.clearMessages() shouldBe 0
189
192
// should not result in a new game state
190
193
assertFalse(listener.newStateReceived)
191
194
@@ -201,8 +204,8 @@ class RequestTest: RealServerTest() {
201
204
val listener = TestLobbyClientListener ()
202
205
player1.addListener(listener)
203
206
204
- await(" Lobby creates a room" ) {
205
- lobby.games.isNotEmpty() && listener.gameJoinedReceived && listener.roomId != null
207
+ await(" Lobby creates a room and Game starts " ) {
208
+ lobby.games.isNotEmpty() && lobby.games.single().status == GameRoom . GameStatus . ACTIVE
206
209
}
207
210
208
211
player1.send(CancelRequest (listener.roomId))
0 commit comments