From 21ed051bc29c3fddc0471f04c9c95d87afb83b72 Mon Sep 17 00:00:00 2001 From: prosolis <5590409+prosolis@users.noreply.github.com> Date: Tue, 22 Sep 2026 22:54:31 -0700 Subject: [PATCH] games: the natural the deal test didn't expect TestDealTakesTheStakeAndHidesTheHoleCard checked for a 900 stack straight after a 100 bet, and only afterwards looked at whether the hand had already settled. A dealt natural settles inside the deal, so the stake is back (with the win, or as a push) before the test looks, and it failed whenever the shoe handed out a blackjack. It now checks for a settled natural first and, if it finds one, only asks that the stack didn't lose more than the bet. --- internal/web/games_play_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/web/games_play_test.go b/internal/web/games_play_test.go index e7d81cd..02603c1 100644 --- a/internal/web/games_play_test.go +++ b/internal/web/games_play_test.go @@ -93,9 +93,6 @@ func TestDealTakesTheStakeAndHidesTheHoleCard(t *testing.T) { if code != 200 { t.Fatalf("deal = %d, want 200", code) } - if v.Chips != 900 { - t.Fatalf("chips after a 100 bet = %d, want 900", v.Chips) - } if v.Hand == nil { t.Fatal("deal returned no hand") } @@ -103,10 +100,18 @@ func TestDealTakesTheStakeAndHidesTheHoleCard(t *testing.T) { t.Fatalf("player was dealt %d cards, want 2", len(v.Hand.Hands[0].Cards)) } - // A natural settles on the spot and legitimately shows both dealer cards. + // A natural settles on the spot: the stake has already come back (with the + // win, or as a push), and both dealer cards are legitimately shown. Checking + // the stack for 900 before this made the test fail on every dealt natural. if v.Hand.Phase == "done" { + if v.Chips < 900 { + t.Fatalf("chips after a settled natural = %d, want at least the 900 left after the bet", v.Chips) + } return } + if v.Chips != 900 { + t.Fatalf("chips after a 100 bet = %d, want 900", v.Chips) + } if !v.Hand.Hole || len(v.Hand.Dealer) != 1 { t.Fatalf("dealer shows %d cards (hole=%v), want 1 with the hole card held back", len(v.Hand.Dealer), v.Hand.Hole)