test(client): wall-clock deadline + 10s ceiling for input-roundtrip response waits

Second distinct flake in this suite today (gate run: MoveEast observed mid-move at the 5s window). The old accounting accrued elapsed only on empty polls — load-dependent effective window. Wall-clock deadline via Time.get_ticks_msec; ceiling 5s->10s (exit-on-arrival, costs nothing when healthy). Targeted suite 6/6.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-16 20:47:12 +02:00
co-authored by Claude Fable 5
parent 9427b165f0
commit 8d1121d13a
+10 -5
View File
@@ -8,7 +8,10 @@ class_name TestInputRoundtrip
extends GdUnitTestSuite
const CONNECT_TIMEOUT: float = 3.0
const RESPONSE_TIMEOUT: float = 5.0
# Ceiling, not a sleep — the wait loop exits the moment the expected state
# arrives. 5.0s flaked under load (gate run 2026-07-16: MoveEast observed
# mid-move at timeout); 10.0s costs nothing when healthy.
const RESPONSE_TIMEOUT: float = 10.0
const MAX_PORT_ATTEMPTS: int = 5
var _server_pid: int = -1
@@ -162,11 +165,14 @@ func _send_and_receive(
var send_err := _bridge.send_message(encoded)
assert_that(send_err).is_equal(OK)
# Wait for a snapshot that reflects the processed input.
# Wait for a snapshot that reflects the processed input. Wall-clock
# deadline: the old sleep-count accounting only accrued on EMPTY polls,
# so a streaming server made the effective window unbounded in theory and
# load-dependent in practice — measure real time instead.
var min_tick: int = last_tick + 2
var snapshot: Variant = null
var elapsed := 0.0
while elapsed < RESPONSE_TIMEOUT:
var deadline_ms: int = Time.get_ticks_msec() + int(RESPONSE_TIMEOUT * 1000.0)
while Time.get_ticks_msec() < deadline_ms:
_bridge.poll()
var msg := _bridge.poll_message()
if msg.size() > 0:
@@ -187,7 +193,6 @@ func _send_and_receive(
break
continue
await get_tree().create_timer(0.05).timeout
elapsed += 0.05
assert_that(snapshot).override_failure_message(
"no snapshot received within %.1fs after '%s'" % [RESPONSE_TIMEOUT, action_name]