diff options
Diffstat (limited to 'internal/casino/machine_ownership_test.go')
| -rw-r--r-- | internal/casino/machine_ownership_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/casino/machine_ownership_test.go b/internal/casino/machine_ownership_test.go new file mode 100644 index 0000000..47e068a --- /dev/null +++ b/internal/casino/machine_ownership_test.go @@ -0,0 +1,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) + } + } + } +} |
