aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/machine_ownership_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-15 14:18:14 -0400
committerhistoria <[not public]>2026-09-15 14:18:14 -0400
commit396c3facb8287b9a34076cae8f3d7b300d366d99 (patch)
tree941f280d051fac474fa68ca08318a8d16adc8d0f /internal/casino/machine_ownership_test.go
parentb3568f03e4103dd46db2ccc680fbab0a6454d604 (diff)
downloadthehouseoficarus-396c3facb8287b9a34076cae8f3d7b300d366d99.tar.gz
fix: atomic saves, casino RNG/config isolation, tick lifecycle
Diffstat (limited to 'internal/casino/machine_ownership_test.go')
-rw-r--r--internal/casino/machine_ownership_test.go24
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)
+ }
+ }
+ }
+}