diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-29 23:06:22 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-29 23:06:22 +0100 |
| commit | 810e212b4b255914cfa73e85b52ec23db281c0e3 (patch) | |
| tree | 01e8035ce2945112af5ef41ef8959890bb0ef722 /tests/client_core.rs | |
| parent | v3.0.0: cursor-driven roulette felt with splits and corners; drop schema migr... (diff) | |
| download | zagan-bet-810e212b4b255914cfa73e85b52ec23db281c0e3.tar.gz zagan-bet-810e212b4b255914cfa73e85b52ec23db281c0e3.zip | |
v3.1.0: warn on shrink, but let a live round finish
Diffstat (limited to '')
| -rw-r--r-- | tests/client_core.rs | 75 |
1 files changed, 75 insertions, 0 deletions
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() { | |||
| 1060 | assert!(h.screen.lines.iter().any(|line| line == "Game exited.")); | 1060 | assert!(h.screen.lines.iter().any(|line| line == "Game exited.")); |
| 1061 | assert!(!h.screen.lines.iter().any(|line| line.contains("PLN lost"))); | 1061 | assert!(!h.screen.lines.iter().any(|line| line.contains("PLN lost"))); |
| 1062 | } | 1062 | } |
| 1063 | |||
| 1064 | #[test] | ||
| 1065 | fn a_round_is_live_only_while_money_is_reserved() { | ||
| 1066 | let mut h = Harness::new(); | ||
| 1067 | |||
| 1068 | // Placed chips are not a live round: nothing is debited until the spin. | ||
| 1069 | h.enter_roulette(); | ||
| 1070 | h.key(Key::Enter); | ||
| 1071 | assert!(h.board()[9].contains("1 10")); | ||
| 1072 | assert!(!h.core.is_live_game()); | ||
| 1073 | h.key(Key::Char('q')); | ||
| 1074 | |||
| 1075 | // Blackjack is live while the player owes an action. | ||
| 1076 | h.enter_blackjack(); | ||
| 1077 | assert!(!h.core.is_live_game()); | ||
| 1078 | h.key(Key::Char(' ')); | ||
| 1079 | assert!(!h.core.is_live_game(), "not live until the server deals"); | ||
| 1080 | let player = bj_state( | ||
| 1081 | "bj1", | ||
| 1082 | "player", | ||
| 1083 | &["10S", "6H"], | ||
| 1084 | &["9D", "?"], | ||
| 1085 | 16, | ||
| 1086 | 9, | ||
| 1087 | 10, | ||
| 1088 | 10, | ||
| 1089 | 990, | ||
| 1090 | &["hit", "stand"], | ||
| 1091 | "playing", | ||
| 1092 | 0, | ||
| 1093 | ); | ||
| 1094 | h.reply(&format!( | ||
| 1095 | "BLACKJACK_STATE {}", | ||
| 1096 | serde_json::to_string(&player).unwrap() | ||
| 1097 | )); | ||
| 1098 | assert!(h.core.is_live_game()); | ||
| 1099 | |||
| 1100 | h.key(Key::Char('s')); | ||
| 1101 | assert_eq!( | ||
| 1102 | h.sent.last().map(String::as_str), | ||
| 1103 | Some("BLACKJACK_ACTION bj1 stand") | ||
| 1104 | ); | ||
| 1105 | let done = bj_state( | ||
| 1106 | "bj1", | ||
| 1107 | "done", | ||
| 1108 | &["10S", "6H"], | ||
| 1109 | &["9D", "8C"], | ||
| 1110 | 16, | ||
| 1111 | 17, | ||
| 1112 | 10, | ||
| 1113 | 10, | ||
| 1114 | 990, | ||
| 1115 | &[], | ||
| 1116 | "lose", | ||
| 1117 | 0, | ||
| 1118 | ); | ||
| 1119 | h.reply(&format!( | ||
| 1120 | "BLACKJACK_STATE {}", | ||
| 1121 | serde_json::to_string(&done).unwrap() | ||
| 1122 | )); | ||
| 1123 | assert!(!h.core.is_live_game()); | ||
| 1124 | h.key(Key::Char('q')); | ||
| 1125 | |||
| 1126 | // Crash is live while the multiplier runs. | ||
| 1127 | h.enter_crash(); | ||
| 1128 | h.key(Key::Char(' ')); | ||
| 1129 | assert!(!h.core.is_live_game(), "not live until the round starts"); | ||
| 1130 | let running = crash_state("running", 1.0, None, 0, 990); | ||
| 1131 | h.reply(&crash_line("CRASH_START", &running)); | ||
| 1132 | assert!(h.core.is_live_game()); | ||
| 1133 | |||
| 1134 | let busted = crash_state("crashed", 1.2, Some(1.2), 0, 990); | ||
| 1135 | h.push(&crash_line("CRASH_BUSTED", &busted)); | ||
| 1136 | assert!(!h.core.is_live_game()); | ||
| 1137 | } | ||
