aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/machine_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/machine_test.go')
-rw-r--r--internal/casino/machine_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/casino/machine_test.go b/internal/casino/machine_test.go
index 1e8cdad..8942936 100644
--- a/internal/casino/machine_test.go
+++ b/internal/casino/machine_test.go
@@ -14,6 +14,20 @@ func TestBetRangeTextFormatsUnlimitedMax(t *testing.T) {
}
}
+// Regression: standing up while a feature was banked silently dropped the
+// credits; leave must settle them like markDisconnected does.
+func TestMachineLeavePaysBankedFeature(t *testing.T) {
+ m := newMachine(1, MachineConfig{ID: "slots", Game: GameSlots}, rand.New(rand.NewSource(7)))
+ w := &testWallet{}
+ m.player = &Participant{Name: "alice", Connected: true, Wallet: w}
+ m.featureBank = 25
+ m.phase = machineReady
+ _ = m.leave("alice")
+ if w.paid != 25 {
+ t.Fatalf("banked feature not paid on leave: paid = %d, want 25", w.paid)
+ }
+}
+
func TestMachineSetBetUnsetDefaultMaxMessage(t *testing.T) {
m := newMachine(1, MachineConfig{ID: "slots", Game: GameSlots, MinBet: 1}, rand.New(rand.NewSource(7)))
m.player = &Participant{Name: "alice", Connected: true}