Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions server/ladder_service/ladder_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,7 @@ def make_game_options(player: Player) -> GameLaunchOptions:
game_options=game_options,
team=game.get_player_option(player.id, "Team"),
faction=game.get_player_option(player.id, "Faction"),
map_position=game.get_player_option(player.id, "StartSpot"),
map_pool_map_version_id=game_map.map_pool_map_version_id
map_position=game.get_player_option(player.id, "StartSpot")
)

await self.launch_match(game, host, all_guests, make_game_options)
Expand Down
1 change: 0 additions & 1 deletion server/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class GameLaunchOptions(NamedTuple):
expected_players: Optional[int] = None
map_position: Optional[int] = None
game_options: Optional[dict[str, Any]] = None
map_pool_map_version_id: Optional[int] = None


class MatchmakerQueueMapPoolVetoData(NamedTuple):
Expand Down
5 changes: 1 addition & 4 deletions tests/integration_tests/test_matchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ async def test_game_launch_message(lobby_server):

assert "scmp_015" in msg1["mapname"]
del msg1["mapname"]
mpmv_id = msg1["map_pool_map_version_id"]
assert mpmv_id in [1, 2, 3]
assert msg1 == {
"command": "game_launch",
"args": ["/numgames", 0],
Expand All @@ -59,8 +57,7 @@ async def test_game_launch_message(lobby_server):
"team": 2,
"faction": 1,
"expected_players": 2,
"map_position": 1,
"map_pool_map_version_id": mpmv_id
"map_position": 1
}


Expand Down
34 changes: 24 additions & 10 deletions tests/integration_tests/test_matchmaker_vetoes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@
)


async def test_used_pools_have_some_maps_and_all_map_names_are_unique(ladder_service):
used_map_pools = {}
for queue in ladder_service.queues.values():
for mq_map_pool in queue.map_pools.values():
pool_id = mq_map_pool.map_pool.id
if pool_id in [1, 2, 3]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on your first attempt there were 4 pool ids, and tests failed. so you reduced their amount to 3. why? wasn't the failure legitimate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error was not due to that
pool 4 just is not used in any veto tests so it doesnt care about its content

used_map_pools[pool_id] = mq_map_pool

assert len(used_map_pools) == 3

for mq_map_pool in used_map_pools.values():
maps = list(mq_map_pool.map_pool.maps.values())
folder_names = [m.folder_name for m in maps if hasattr(m, "folder_name")]
assert len(folder_names) > 0, f"Pool {mq_map_pool.map_pool.id} has no regular maps"
assert len(folder_names) == len(set(folder_names)), f"Pool {mq_map_pool.map_pool.id} has duplicate map names: {folder_names}"


async def test_vetoes_are_assigned_to_player_with_adjusting(lobby_server, player_service):
async def test_vetoes(proto, vetoes, expected_vetoes):
await proto.send_message({
Expand Down Expand Up @@ -51,8 +68,7 @@ async def test_if_veto_bans_working(lobby_server, mocker):

msg1 = await client_response(proto1)

chosen_map_pool_version_id = msg1["map_pool_map_version_id"]
assert chosen_map_pool_version_id == 3
assert msg1["mapname"] == "scmp_015.v0003"

await end_game_as_draw([proto1, proto2], msg1["uid"])

Expand All @@ -75,8 +91,7 @@ async def test_dynamic_max_tokens_per_map(lobby_server, mocker):

msg1 = await client_response(proto1)

chosen_map_pool_version_id = msg1["map_pool_map_version_id"]
assert chosen_map_pool_version_id == 8
assert msg1["mapname"] == "scmp_015.v0003"
await end_game_as_draw([proto1, proto2], msg1["uid"])


Expand All @@ -99,12 +114,12 @@ async def test_partial_vetoes(lobby_server, mocker):

msg1 = await client_response(proto1)

chosen_map_pool_version_id = msg1["map_pool_map_version_id"]
chosen_maps.add(chosen_map_pool_version_id)
assert chosen_map_pool_version_id in [10, 11], f"Expected map 10 or 11, got {chosen_map_pool_version_id}"
chosen_mapname = msg1["mapname"]
chosen_maps.add(chosen_mapname)
assert chosen_mapname in ["scmp_002", "scmp_003"], f"Expected scmp_002 or scmp_003, got {chosen_mapname}"
await end_game_as_draw([proto1, proto2], msg1["uid"])

assert chosen_maps == {10, 11}, f"Expected games on both maps 10 and 11, got {chosen_maps}"
assert chosen_maps == {"scmp_002", "scmp_003"}, f"Expected games on both scmp_002 and scmp_003, got {chosen_maps}"


@fast_forward(120)
Expand All @@ -130,8 +145,7 @@ async def test_vetoes_tmm(lobby_server, mocker):
await read_until_command(proto, "match_found", timeout=30)

msg1 = await client_response(players[0])
chosen_map_pool_version_id = msg1["map_pool_map_version_id"]
assert chosen_map_pool_version_id == 10
assert msg1["mapname"] == "scmp_002"
await end_game_as_draw(players, msg1["uid"])


Expand Down