Skip to content

Commit

Permalink
Fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Nov 24, 2023
1 parent 6c85077 commit effa447
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 10 additions & 3 deletions e2e_tests/fafclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ async def read_until(self, predicate, timeout=5):
timeout=timeout
)

async def read_until_command(self, command, timeout=5):
return await read_until_command(self.proto, command, timeout=timeout)
async def read_until_command(self, command, timeout=5, **kwargs):
return await read_until_command(
self.proto,
command,
timeout=timeout,
**kwargs,
)

async def read_until_game_launch(self, uid):
return await self.read_until(
Expand Down Expand Up @@ -124,12 +129,14 @@ async def host_game(self, **kwargs):
game_id = int(msg["uid"])

await self.open_fa()
await self.read_until_command("HostGame", target="game")
return game_id

async def join_game(self, game_id, **kwargs):
await self.send_message({
"command": "game_join",
"uid": game_id
"uid": game_id,
**kwargs
})
await self.read_until_command("game_launch")

Expand Down
6 changes: 4 additions & 2 deletions e2e_tests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ async def test_custom_game_1v1_game_stats(client_factory, json_stats_1v1):
for client in (client1, client2):
await client.send_gpg_command("GameState", "Ended")

await client1.read_until_command("updated_achievements", timeout=10)
await client2.read_until_command("updated_achievements", timeout=2)
# The client no longer gets a `updated_achievements` notification, but we
# keep the test in case it could generate an exception on the server side.
await client1.get_player_ratings("test", "test2", timeout=10)
await client2.get_player_ratings("test", "test2", timeout=2)


async def test_custom_game_1v1_extra_gameresults(client_factory):
Expand Down
3 changes: 3 additions & 0 deletions e2e_tests/test_matchmaking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

from .test_game import simulate_result_reports

# NOTE: Tests will cause matchmaker violations, so after running them a few
# times, they may start to fail.


async def test_ladder_1v1_match(client_factory):
"""More or less the same as the regression test version"""
Expand Down

0 comments on commit effa447

Please sign in to comment.