diff options
| author | historia <[not public]> | 2026-09-15 20:35:23 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-15 20:35:23 -0400 |
| commit | fcb806c3445ce56f2e57e208de773b4dac957c8d (patch) | |
| tree | 3b08c3d51bfe5456dcd215449cf07509aca2353a /internal/game/casino_forfeit_regression_test.go | |
| parent | 69235cac5b3da5ff0dc20310e7474cabd8e63ba3 (diff) | |
| download | thehouseoficarus-fcb806c3445ce56f2e57e208de773b4dac957c8d.tar.gz | |
fix: owner re-entrancy deadlock, telnet write queue, recovery/refund money safety, admin path traversal
Diffstat (limited to 'internal/game/casino_forfeit_regression_test.go')
| -rw-r--r-- | internal/game/casino_forfeit_regression_test.go | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/internal/game/casino_forfeit_regression_test.go b/internal/game/casino_forfeit_regression_test.go index 9ad8016..db5ba31 100644 --- a/internal/game/casino_forfeit_regression_test.go +++ b/internal/game/casino_forfeit_regression_test.go @@ -42,10 +42,27 @@ func TestDisconnectForfeitsBlackjackStake(t *testing.T) { h := newHarness(t) h.seedAccount("alice", "pw", false) p := h.seedCharacter("alice", "alice") + // A natural opening hand (player or dealer blackjack) settles the round + // inside Bet() itself, before any disconnect can forfeit anything. Deal + // from deterministic seeds until the opening hand leaves the stake + // outstanding, so the regression exercises the mid-round forfeit path + // on every run instead of failing ~5% of the time on a lucky deal. + committed := false + for seed := 0; seed < 1000 && !committed; seed++ { + h.g.RunOnOwner(func() { + h.g.Casino = casino.NewManager(int64(seed)) + p.Credits = 100 + h.g.Casino.Join(1, casino.TableConfig{ID: "bj", Game: casino.GameBlackjack, MaxPlayers: 2}, "alice") + h.g.Casino.Bet(1, "bj", "alice", "", 10, casinoWallet{g: h.g, p: p}) + committed = len(h.g.Economy.openStakes("alice")) == 1 + }) + h.barrier() + } + if !committed { + t.Fatal("no manager seed left the blackjack stake outstanding; deal or settle logic changed") + } h.g.RunOnOwner(func() { - p.Credits = 100 - h.g.Casino.Join(1, casino.TableConfig{ID: "bj", Game: casino.GameBlackjack, MaxPlayers: 2}, "alice") - h.g.Casino.Bet(1, "bj", "alice", "", 10, casinoWallet{g: h.g, p: p}) + // The disconnect path forfeits the in-flight hand. h.g.Casino.MarkDisconnected("alice") }) h.barrier() |
