aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/correct_audit_fixes_test.go
blob: dc33c47dbc68825eb7e2cacb27919dad7398e24f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package casino

import (
	"math/rand"
	"testing"
)

// Regression: when the shooter leaves and others remain, the next shooter must
// start a fresh come-out rather than inheriting the previous point and
// made/seen bonus progress (which blocked line and bonus bets).
func TestCrapsShooterChangeResetsHand(t *testing.T) {
	tb := newCrapsTable(1, TableConfig{ID: "craps", Game: GameCraps, BettingTicks: 2}, rand.New(rand.NewSource(7)))
	tb.join("alice")
	tb.join("bob")
	tb.point = 6
	tb.rolled = true
	tb.made = map[int]bool{4: true}
	tb.seen = map[int]bool{4: true}
	tb.remove("alice")
	if tb.point != 0 || tb.rolled || len(tb.made) != 0 || len(tb.seen) != 0 {
		t.Fatalf("new shooter inherited hand: point=%d rolled=%v made=%v seen=%v", tb.point, tb.rolled, tb.made, tb.seen)
	}
}

// Regression: a video-poker cabinet addressed by an ID that collides with a
// machine variant/game name validated but was unreachable (the machine won the
// address lookup).
func TestVideoPokerCabinetIDCollisionIsRejected(t *testing.T) {
	machines := []MachineConfig{{ID: "m1", Game: GameSlots, Variant: "x"}}
	tables := []TableConfig{{ID: "x", Game: GameVideoPoker}}
	if err := ValidateRoomConfigs(tables, machines); err == nil {
		t.Fatal("cabinet ID colliding with a machine variant was accepted; the cabinet would be unreachable")
	}
}