Skip to content

Commit

Permalink
Add game id to match_cancelled message
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Dec 14, 2021
1 parent 0b987e8 commit 337bd57
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion server/ladder_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ def game_options(player: Player) -> GameLaunchOptions:
if game:
await game.on_game_end()

msg = {"command": "match_cancelled"}
game_id = game.id if game else None
msg = {"command": "match_cancelled", "game_id": game_id}
for player in all_players:
if player.state == PlayerState.STARTING_AUTOMATCH:
player.state = PlayerState.IDLE
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_matchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ async def test_game_matchmaking_disconnect(lobby_server):

msg = await read_until_command(proto2, "match_cancelled", timeout=120)

assert msg == {"command": "match_cancelled"}
assert msg == {"command": "match_cancelled", "game_id": 41956}


@fast_forward(130)
Expand Down
10 changes: 8 additions & 2 deletions tests/unit_tests/test_ladder_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,14 @@ async def test_start_game_timeout(

LadderGame.timeout_game.assert_called_once()
LadderGame.on_game_end.assert_called()
p1.lobby_connection.write.assert_called_once_with({"command": "match_cancelled"})
p2.lobby_connection.write.assert_called_once_with({"command": "match_cancelled"})
p1.lobby_connection.write.assert_called_once_with({
"command": "match_cancelled",
"game_id": 41956
})
p2.lobby_connection.write.assert_called_once_with({
"command": "match_cancelled",
"game_id": 41956
})
assert p1.lobby_connection.launch_game.called
# TODO: Once client supports `match_cancelled` change this to `assert not`
# and uncomment the following lines.
Expand Down

0 comments on commit 337bd57

Please sign in to comment.