From 1f118d79e319da4e765502e9ca5b661772de94f1 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 18 Sep 2026 18:38:35 -0400 Subject: refactor: casino table core; fix: stake/migration/validation gaps --- internal/game/hardening_queue_cleanup_test.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'internal/game/hardening_queue_cleanup_test.go') diff --git a/internal/game/hardening_queue_cleanup_test.go b/internal/game/hardening_queue_cleanup_test.go index 95b96bf..3285381 100644 --- a/internal/game/hardening_queue_cleanup_test.go +++ b/internal/game/hardening_queue_cleanup_test.go @@ -114,24 +114,27 @@ func TestProcessQueuedCommandsSkipsStaleSession(t *testing.T) { } } -// TestActivePositionsReturnsSortedNamesAndOneBasedPosition pins the documented -// contract of ActivePositions: names sorted, position 1-indexed, 0 when the -// player holds no active command. -func TestActivePositionsReturnsSortedNamesAndOneBasedPosition(t *testing.T) { +// TestActivePositionsReturnsResolutionOrderAndOneBasedPosition pins the +// contract of ActivePositions: names in actual resolution order (earliest +// Timestamp first, matching ProcessQueuedCommands), position 1-indexed, 0 when +// the player holds no active command. +func TestActivePositionsReturnsResolutionOrderAndOneBasedPosition(t *testing.T) { q := NewCommandQueue() - for _, name := range []string{"carol", "alice", "bob"} { - q.EnqueueActive(name, QueuedCommand{Command: "look", Timestamp: time.Now()}) - } + base := time.Now() + // Queue deliberately out of alphabetical order: resolution is first-to-queue. + q.EnqueueActive("alice", QueuedCommand{Command: "look", Timestamp: base.Add(3 * time.Millisecond)}) + q.EnqueueActive("bob", QueuedCommand{Command: "look", Timestamp: base.Add(2 * time.Millisecond)}) + q.EnqueueActive("carol", QueuedCommand{Command: "look", Timestamp: base.Add(1 * time.Millisecond)}) names, pos := q.ActivePositions("bob") - if want := []string{"alice", "bob", "carol"}; !reflect.DeepEqual(names, want) { - t.Errorf("names = %v, want %v", names, want) + if want := []string{"carol", "bob", "alice"}; !reflect.DeepEqual(names, want) { + t.Errorf("names = %v, want %v (timestamp order)", names, want) } if pos != 2 { t.Errorf("position of bob = %d, want 2", pos) } - if _, pos := q.ActivePositions("alice"); pos != 1 { - t.Errorf("position of alice = %d, want 1", pos) + if _, pos := q.ActivePositions("carol"); pos != 1 { + t.Errorf("position of carol = %d, want 1", pos) } if _, pos := q.ActivePositions("nobody"); pos != 0 { t.Errorf("position of an unqueued player = %d, want 0", pos) -- cgit v1.2.3