1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package casino
import "testing"
func TestMachineRejectsStaleAndNonOwnerCommands(t *testing.T) {
m := NewManager(1)
cfg := MachineConfig{ID: "slots", Game: GameSlots}
m.JoinMachine(1, cfg, "alice")
m.MarkDisconnected("alice")
for _, occupied := range []bool{false, true} {
if occupied {
m.JoinMachine(1, cfg, "bob")
}
for _, events := range [][]Event{
m.SetMachineBet(1, "slots", "alice", 10, nil),
m.StartMachine(1, "slots", "alice", nil),
m.EnableMachineAutoBet(1, "slots", "alice", nil),
} {
if len(events) != 1 || events[0].PrivateTo != "alice" || events[0].Public {
t.Fatalf("rejection misrouted (occupied=%v): %+v", occupied, events)
}
}
}
}
|