From 810e212b4b255914cfa73e85b52ec23db281c0e3 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 23:06:22 +0100 Subject: v3.1.0: warn on shrink, but let a live round finish --- tests/client_core.rs | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'tests/client_core.rs') diff --git a/tests/client_core.rs b/tests/client_core.rs index dea6808..a7c5716 100644 --- a/tests/client_core.rs +++ b/tests/client_core.rs @@ -1060,3 +1060,78 @@ fn a_forfeit_that_arrives_after_the_bust_still_leaves_cleanly() { assert!(h.screen.lines.iter().any(|line| line == "Game exited.")); assert!(!h.screen.lines.iter().any(|line| line.contains("PLN lost"))); } + +#[test] +fn a_round_is_live_only_while_money_is_reserved() { + let mut h = Harness::new(); + + // Placed chips are not a live round: nothing is debited until the spin. + h.enter_roulette(); + h.key(Key::Enter); + assert!(h.board()[9].contains("1 10")); + assert!(!h.core.is_live_game()); + h.key(Key::Char('q')); + + // Blackjack is live while the player owes an action. + h.enter_blackjack(); + assert!(!h.core.is_live_game()); + h.key(Key::Char(' ')); + assert!(!h.core.is_live_game(), "not live until the server deals"); + let player = bj_state( + "bj1", + "player", + &["10S", "6H"], + &["9D", "?"], + 16, + 9, + 10, + 10, + 990, + &["hit", "stand"], + "playing", + 0, + ); + h.reply(&format!( + "BLACKJACK_STATE {}", + serde_json::to_string(&player).unwrap() + )); + assert!(h.core.is_live_game()); + + h.key(Key::Char('s')); + assert_eq!( + h.sent.last().map(String::as_str), + Some("BLACKJACK_ACTION bj1 stand") + ); + let done = bj_state( + "bj1", + "done", + &["10S", "6H"], + &["9D", "8C"], + 16, + 17, + 10, + 10, + 990, + &[], + "lose", + 0, + ); + h.reply(&format!( + "BLACKJACK_STATE {}", + serde_json::to_string(&done).unwrap() + )); + assert!(!h.core.is_live_game()); + h.key(Key::Char('q')); + + // Crash is live while the multiplier runs. + h.enter_crash(); + h.key(Key::Char(' ')); + assert!(!h.core.is_live_game(), "not live until the round starts"); + let running = crash_state("running", 1.0, None, 0, 990); + h.reply(&crash_line("CRASH_START", &running)); + assert!(h.core.is_live_game()); + + let busted = crash_state("crashed", 1.2, Some(1.2), 0, 990); + h.push(&crash_line("CRASH_BUSTED", &busted)); + assert!(!h.core.is_live_game()); +} -- cgit v1.2.3