From 3f0b8da68afeb9b02e8a26ba015b8f0fd85c3ac2 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sun, 24 Mar 2024 14:28:25 +0100 Subject: [PATCH] Fix players ID mismatch --- api-webapp/src/test/kotlin/PairingTests.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/api-webapp/src/test/kotlin/PairingTests.kt b/api-webapp/src/test/kotlin/PairingTests.kt index 71bda05..272514c 100644 --- a/api-webapp/src/test/kotlin/PairingTests.kt +++ b/api-webapp/src/test/kotlin/PairingTests.kt @@ -314,7 +314,17 @@ class PairingTests: TestBase() { val skipSeeding = round <= 2 assertTrue(compare_weights(getOutputFile("weights.txt"), getTestFile("opengotha/simplemm/simplemm_weights_R$round.txt"), skipSeeding), "Not matching opengotha weights for round $round") logger.info("Weights for round $round match OpenGotha") - assertTrue(compare_games(games, Json.parse(pairings[round - 1])!!.asArray(), skipColor=true),"pairings for round $round differ") + + // fix players ids (TODO - reset memstore between each test for simplicity) + val maxId = games.flatMap { listOf((it as Json.Object).getInt("b")!!, (it as Json.Object).getInt("w")!!) }.max() + val fixedGames = games.mapTo(Json.MutableArray()) { + val game = it as Json.Object + Json.MutableObject(game) + .set("b", game.getInt("b")!! - maxId + 16) + .set("w", game.getInt("w")!! - maxId + 16) + } + + assertTrue(compare_games(fixedGames, Json.parse(pairings[round - 1])!!.asArray(), skipColor=true),"pairings for round $round differ") logger.info("Pairing for round $round match OpenGotha") forcedGames = Json.parse(pairings[round-1])!!.asArray()