From 0e60567a7a0addb9421769ee7be7853bfa8788cb Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sat, 19 Sep 2026 03:15:59 -0400 Subject: refactor: simplifcation, change how rooms are stored in player yaml, remove legacy code --- internal/casino/config_validate_test.go | 50 +++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'internal/casino/config_validate_test.go') diff --git a/internal/casino/config_validate_test.go b/internal/casino/config_validate_test.go index f0f87f5..5e72054 100644 --- a/internal/casino/config_validate_test.go +++ b/internal/casino/config_validate_test.go @@ -75,15 +75,16 @@ func TestTableConfigValidation(t *testing.T) { } } -func TestRoomCasinoIDsAndLegacySlots(t *testing.T) { - tables := []TableConfig{{ID: "slots", Game: GameSlots}} +func TestRoomCasinoIDsRejectDuplicates(t *testing.T) { machines := []MachineConfig{{ID: "slots", Game: GameSlots}} - if err := ValidateRoomConfigs(tables, nil); err != nil { - t.Fatalf("legacy slots rejected: %v", err) - } - if ValidateRoomConfigs(tables, machines) == nil || ValidateRoomConfigs(nil, append(machines, machines...)) == nil { + if ValidateRoomConfigs(nil, append(machines, machines...)) == nil { t.Fatal("duplicate casino IDs accepted") } + + // Slots are machines only: declaring them under casino_tables is invalid. + if err := ValidateRoomConfigs([]TableConfig{{ID: "slots", Game: GameSlots}}, nil); err == nil { + t.Fatal("slots table accepted; slots must be declared under casino_machines") + } } func TestManagerGamesHaveIndependentRandomStreams(t *testing.T) { @@ -122,3 +123,40 @@ func TestScaleToRTPDoesNotChangeSourceProfile(t *testing.T) { t.Fatal("profiles share mutable paytables") } } + +func TestSlotProfileEmptySymbolsRejected(t *testing.T) { + // A new slotVariants entry that forgets its symbol table must not validate + // and silently play the built-in cabinet. + if err := (SlotProfile{}).Validate(); err == nil { + t.Fatal("empty slot profile validated; expected an error") + } +} + +func TestTableConfigRejectsForeignRuleBlock(t *testing.T) { + c := TableConfig{ID: "t", Game: GameBaccarat, Blackjack: BlackjackConfig{BlackjackPayout: 15}} + if err := c.Validate(); err == nil { + t.Fatal("baccarat table with a blackjack rule block validated; expected an error") + } + ok := TableConfig{ID: "t", Game: GameBlackjack} + if err := ok.Validate(); err != nil { + t.Fatalf("valid blackjack table rejected: %v", err) + } +} + +func TestTableConfigTimerCaps(t *testing.T) { + cases := map[string]TableConfig{ + "huge betting window": {ID: "t", Game: GameBaccarat, BettingTicks: maxBettingTicks + 1}, + "huge action window": {ID: "t", Game: GameBlackjack, Blackjack: BlackjackConfig{ActionTicks: maxActionTicks + 1}}, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + if err := c.Validate(); err == nil { + t.Fatal("expected an error") + } + }) + } + m := MachineConfig{ID: "m", Game: GameSlots, SpinTicks: maxSpinTicks + 1} + if err := m.Validate(); err == nil { + t.Fatal("expected an error for an oversized spin window") + } +} -- cgit v1.2.3