mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-14 03:52:14 +00:00
feat: persist matchmaking recovery state
This commit is contained in:
@@ -64,3 +64,13 @@ func test_assignment_lifecycle_has_explicit_connecting_and_live_states() -> void
|
||||
assert_eq(state.phase, MatchmakingState.CONNECTING, "transport connection is visible")
|
||||
state.mark_live()
|
||||
assert_eq(state.phase, MatchmakingState.LIVE, "live match is visible")
|
||||
|
||||
|
||||
func test_restart_restore_requires_valid_identity_and_requests_authoritative_recovery() -> void:
|
||||
var state := MatchmakingState.new()
|
||||
assert_true(state.restore_snapshot({"phase": "QUEUED", "ticket_id": "ticket-1", "playlist": "casual", "revision": 2}), "valid active snapshot restores")
|
||||
assert_true(state.needs_resync, "restored active state must recover from the server")
|
||||
assert_eq(state.revision, 2, "revision is retained for diagnostics")
|
||||
assert_true(not state.restore_snapshot({"phase": "QUEUED", "ticket_id": "", "playlist": "casual"}), "missing ticket identity is rejected")
|
||||
assert_eq(state.phase, MatchmakingState.IDLE, "invalid restore cannot leave stale active state")
|
||||
assert_true(not state.restore_snapshot({"phase": "NOT_A_STATE", "ticket_id": "ticket-1", "playlist": "casual"}), "unknown state is rejected")
|
||||
|
||||
Reference in New Issue
Block a user