From c6c8ddb7e4117628549afdb382b0d46f830f242d Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 8 Nov 2026 03:36:26 +0100 Subject: crash: show and verify the revealed seed in the TUI and GUI The crash board gained a fairness line: the short commit while the round runs, then the short seed marked verified when sha256(seed) and the recomputed crash point both match. The terminal board grew from six to seven lines and the GUI sidebar shows the same values. --- tests/client_core.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/client_core.rs b/tests/client_core.rs index 3a2fb27..65fd1e6 100644 --- a/tests/client_core.rs +++ b/tests/client_core.rs @@ -987,9 +987,10 @@ fn crash_starts_a_round_and_draws_the_multiplier_locally() { let mut h = Harness::new(); h.enter_crash(); - assert_eq!(h.board().len(), 6); + assert_eq!(h.board().len(), 7); assert!(h.board()[4].contains("Press [SPACE] to start.")); assert!(h.board()[5].contains("[SPACE] Play")); + assert!(h.board()[6].contains("Commit: —")); h.key(Key::Char(' ')); assert!(h.sent.iter().any(|line| line == "PLAY_START crash 10")); @@ -997,7 +998,7 @@ fn crash_starts_a_round_and_draws_the_multiplier_locally() { let running = crash_state("running", 1.0, None, 0, 990); h.reply(&crash_line("CRASH_START", &running)); - assert_eq!(h.board().len(), 6); + assert_eq!(h.board().len(), 7); assert!(h.board()[2].contains("Multiplier: 1.00x")); assert!(h.board()[3].contains("Potential: 10 Kr")); assert!(h.board()[4].contains("Rising")); @@ -1709,3 +1710,31 @@ fn a_crash_tick_updates_the_board_for_its_own_session() { h.push("crash.tick session=other t=1700000000200 m=9.0"); assert!(h.board()[2].contains("Multiplier: 1.50x")); } + +#[test] +fn the_crash_board_verifies_the_revealed_seed() { + use zagan_bet::crash::{commit_seed, crash_point_from_seed}; + + let mut h = Harness::new(); + h.enter_crash(); + h.key(Key::Char(' ')); + let mut seed = [0u8; 32]; + seed[..8].copy_from_slice(&(0.67_f64 * 18_446_744_073_709_551_616.0).to_be_bytes()); + let commit = commit_seed(&seed); + let point = crash_point_from_seed(&seed); + let hex = seed + .iter() + .map(|byte| format!("{byte:02x}")) + .collect::(); + + let mut cashed = crash_state("cashed", 2.0, Some(point), 20, 1010); + cashed.commit = Some(commit); + cashed.seed = Some(hex); + h.reply(&crash_line("CRASH_STATE", &cashed)); + + assert!( + h.board()[6].contains("verified"), + "fairness line: {}", + h.board()[6] + ); +} -- cgit v1.2.3