diff options
| author | historia <[not public]> | 2026-09-18 18:38:35 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 18:38:35 -0400 |
| commit | 1f118d79e319da4e765502e9ca5b661772de94f1 (patch) | |
| tree | bca8a3fd1e538f1c302480511e6ba872c92e10b8 /internal/casino/manager_test.go | |
| parent | 5ad42a51df4dcc5ccc3aa6a6d902085ce2ee4239 (diff) | |
| download | thehouseoficarus-1f118d79e319da4e765502e9ca5b661772de94f1.tar.gz | |
refactor: casino table core; fix: stake/migration/validation gaps
Diffstat (limited to 'internal/casino/manager_test.go')
| -rw-r--r-- | internal/casino/manager_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/casino/manager_test.go b/internal/casino/manager_test.go index b037efa..6601b52 100644 --- a/internal/casino/manager_test.go +++ b/internal/casino/manager_test.go @@ -127,3 +127,37 @@ func eventText(events []Event) string { } return "" } + +// TestRekeyRoomsKeepsTableIdentityAndWhitespaceIDs: a room rekey must move +// the manager key and the shared table identity together, and must not +// truncate a table ID that legally contains whitespace. +func TestRekeyRoomsKeepsTableIdentityAndWhitespaceIDs(t *testing.T) { + m := NewManager(1) + const id = "high stakes bj" + cfg := TableConfig{ID: id, Game: GameBlackjack} + m.Join(1, cfg, "alice") + table := m.Table(1, id) + if table == nil { + t.Fatal("table was not created for a valid whitespace-containing ID") + } + m.RekeyRooms(map[int]int{1: 12}) + if m.Table(1, id) != nil { + t.Fatal("table left under the old room key") + } + moved := m.Table(12, id) + if moved != table { + t.Fatalf("rekey lost the table (or truncated its key): Table(12, %q)=%p want %p", id, moved, table) + } + if moved.RoomID != 12 { + t.Fatalf("moved table RoomID = %d, want 12", moved.RoomID) + } + // The game shares the table's base, so events must route to the new room. + events := moved.join("bob") + if len(events) == 0 || events[0].RoomID != 12 { + t.Fatalf("post-rekey events route to the wrong room: %+v", events) + } + // The old, truncated key must not have been created. + if m.Table(12, "high") != nil { + t.Fatal("rekey created a truncated table key from a whitespace ID") + } +} |
