From a8ff9863a6c6d0f2fcca822b1ea8e965d87190e9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Oct 2026 19:52:44 +0000 Subject: [PATCH] Fix a race in ScorekeeperSessionTest's admittedGuest helper A guest counts as connected before the host's sheet has arrived over the socket, so tests that read the guest's players straight away could see an empty list. The helper now waits for the guest to hold the host's sheet. 0 failures in 12 runs (was ~1 in 3). Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_016eTor2tpxKb4dXbd8RqnvZ --- .../org/prolibertate/games/net/ScorekeeperSessionTest.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/test/java/org/prolibertate/games/net/ScorekeeperSessionTest.kt b/app/src/test/java/org/prolibertate/games/net/ScorekeeperSessionTest.kt index 7f10647..fbcd846 100644 --- a/app/src/test/java/org/prolibertate/games/net/ScorekeeperSessionTest.kt +++ b/app/src/test/java/org/prolibertate/games/net/ScorekeeperSessionTest.kt @@ -145,6 +145,11 @@ class ScorekeeperSessionTest { await("$name to be asking") { host.state.requests.any { it.id == deviceId } } host.session.allow(deviceId) await("$name to be let in") { guest.state.value.connected } + // The sheet follows the connection over the socket, so `connected` can + // flip while it is still in flight. Callers read the guest's sheet at + // once (its players, its rounds), and on a slow runner that was an empty + // one: wait until the guest is looking at the host's. + await("$name to receive the sheet") { guest.state.value.sheet == host.state.sheet } return guest }