aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/money_regression_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-18 18:38:35 -0400
committerhistoria <[not public]>2026-09-18 18:38:35 -0400
commit1f118d79e319da4e765502e9ca5b661772de94f1 (patch)
treebca8a3fd1e538f1c302480511e6ba872c92e10b8 /internal/casino/money_regression_test.go
parent5ad42a51df4dcc5ccc3aa6a6d902085ce2ee4239 (diff)
downloadthehouseoficarus-1f118d79e319da4e765502e9ca5b661772de94f1.tar.gz
refactor: casino table core; fix: stake/migration/validation gaps
Diffstat (limited to 'internal/casino/money_regression_test.go')
-rw-r--r--internal/casino/money_regression_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/casino/money_regression_test.go b/internal/casino/money_regression_test.go
index 79f9b46..31cd0e6 100644
--- a/internal/casino/money_regression_test.go
+++ b/internal/casino/money_regression_test.go
@@ -249,3 +249,40 @@ func TestSlotsStakeResolvesOnlyAfterFullRound(t *testing.T) {
t.Errorf("refundAll double-paid a completed round: paid %d -> %d", paidBefore, wallet.paid)
}
}
+
+// TestSlotsSecondSpinDoesNotResolveFailedPayoutStake: a spin whose payout
+// could not be persisted leaves its stake OPEN as recovery evidence. The
+// next round must resolve only its own stake — a player-wide ResolveStakes
+// would silently erase the failed round's evidence and drop the refund.
+func TestSlotsSecondSpinDoesNotResolveFailedPayoutStake(t *testing.T) {
+ machine := newMachine(1, MachineConfig{ID: "slots", Game: GameSlots, SpinTicks: 1}, newTestRand())
+ wallet := &failingPayoutWallet{testWallet{credits: 100}}
+ machine.join("alice")
+ machine.setBet("alice", 10, wallet)
+ machine.spin = &SlotSpin{Payout: 20} // winning spin the wallet refuses to pay
+ for i := 0; i < 20 && machine.phase != machineReady; i++ {
+ machine.tick()
+ }
+ if len(wallet.open) != 1 {
+ t.Fatal("setup: a failed payout must leave the stake open")
+ }
+
+ // A second, losing round must not resolve the first (still-open) stake.
+ machine.setBet("alice", 10, wallet)
+ machine.spin = &SlotSpin{}
+ for i := 0; i < 20 && machine.phase != machineReady; i++ {
+ machine.tick()
+ }
+ if len(wallet.open) != 1 {
+ t.Fatalf("the second spin resolved the failed-payout stake; open=%d, want 1", len(wallet.open))
+ }
+
+ // The preserved stake is still refundable at shutdown.
+ machine.refundAll()
+ if len(wallet.open) != 0 {
+ t.Fatalf("failed-payout stake was not refunded: open=%+v", wallet.open)
+ }
+ if got := wallet.credits + wallet.paid; got != 90 {
+ t.Fatalf("balance %d, want 90 (first stake refunded, second leg lost)", got)
+ }
+}