aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/manager_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/manager_test.go')
-rw-r--r--internal/casino/manager_test.go52
1 files changed, 6 insertions, 46 deletions
diff --git a/internal/casino/manager_test.go b/internal/casino/manager_test.go
index 818f397..134798a 100644
--- a/internal/casino/manager_test.go
+++ b/internal/casino/manager_test.go
@@ -32,54 +32,14 @@ func TestMixedWagerUsesChipsFirst(t *testing.T) {
}
}
-func TestSoloBetResolvesImmediately(t *testing.T) {
+func TestJoinUnknownTableGameRejected(t *testing.T) {
m := NewManager(1)
- cfg := TableConfig{ID: "slots", Game: GameSlots}
- m.Join(1, cfg, "alice")
- w := &testWallet{credits: 100}
- events := m.Bet(1, "slots", "alice", "", 10, w)
- found := false
- for _, event := range events {
- if event.Type == EventRoundStarted {
- found = true
- }
- }
- if !found {
- t.Fatal("solo bet did not resolve immediately")
- }
-}
-
-func TestMultiplePlayersWaitForBets(t *testing.T) {
- m := NewManager(1)
- cfg := TableConfig{ID: "slots", Game: GameSlots, BettingTicks: 2}
- m.Join(1, cfg, "alice")
- m.Join(1, cfg, "bob")
- wa, wb := &testWallet{credits: 100}, &testWallet{credits: 100}
- events := m.Bet(1, "slots", "alice", "", 10, wa)
- for _, event := range events {
- if event.Type == EventRoundStarted {
- t.Fatal("round started before all players bet or timeout")
- }
- }
- m.Bet(1, "slots", "bob", "", 10, wb)
-}
-
-func TestTableBettingIgnoresDisconnected(t *testing.T) {
- m := NewManager(1)
- cfg := TableConfig{ID: "slots", Game: GameSlots, BettingTicks: 20}
- m.Join(1, cfg, "alice")
- m.Join(1, cfg, "bob")
- m.MarkDisconnected("bob")
- w := &testWallet{credits: 100}
- events := m.Bet(1, "slots", "alice", "", 10, w)
- found := false
- for _, event := range events {
- if event.Type == EventRoundStarted {
- found = true
- }
+ events := m.Join(1, TableConfig{ID: "slots", Game: GameSlots}, "alice")
+ if len(events) != 1 || !contains(events[0].Message, "not available") {
+ t.Fatalf("joining an unsupported table game: %+v", events)
}
- if !found {
- t.Fatal("disconnected player stalled the table's round")
+ if m.Table(1, "slots") != nil {
+ t.Fatal("unsupported game was cached as a table")
}
}