summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/client_core.rs33
1 files changed, 31 insertions, 2 deletions
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() {
987 let mut h = Harness::new(); 987 let mut h = Harness::new();
988 h.enter_crash(); 988 h.enter_crash();
989 989
990 assert_eq!(h.board().len(), 6); 990 assert_eq!(h.board().len(), 7);
991 assert!(h.board()[4].contains("Press [SPACE] to start.")); 991 assert!(h.board()[4].contains("Press [SPACE] to start."));
992 assert!(h.board()[5].contains("[SPACE] Play")); 992 assert!(h.board()[5].contains("[SPACE] Play"));
993 assert!(h.board()[6].contains("Commit: —"));
993 994
994 h.key(Key::Char(' ')); 995 h.key(Key::Char(' '));
995 assert!(h.sent.iter().any(|line| line == "PLAY_START crash 10")); 996 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() {
997 let running = crash_state("running", 1.0, None, 0, 990); 998 let running = crash_state("running", 1.0, None, 0, 990);
998 h.reply(&crash_line("CRASH_START", &running)); 999 h.reply(&crash_line("CRASH_START", &running));
999 1000
1000 assert_eq!(h.board().len(), 6); 1001 assert_eq!(h.board().len(), 7);
1001 assert!(h.board()[2].contains("Multiplier: 1.00x")); 1002 assert!(h.board()[2].contains("Multiplier: 1.00x"));
1002 assert!(h.board()[3].contains("Potential: 10 Kr")); 1003 assert!(h.board()[3].contains("Potential: 10 Kr"));
1003 assert!(h.board()[4].contains("Rising")); 1004 assert!(h.board()[4].contains("Rising"));
@@ -1709,3 +1710,31 @@ fn a_crash_tick_updates_the_board_for_its_own_session() {
1709 h.push("crash.tick session=other t=1700000000200 m=9.0"); 1710 h.push("crash.tick session=other t=1700000000200 m=9.0");
1710 assert!(h.board()[2].contains("Multiplier: 1.50x")); 1711 assert!(h.board()[2].contains("Multiplier: 1.50x"));
1711} 1712}
1713
1714#[test]
1715fn the_crash_board_verifies_the_revealed_seed() {
1716 use zagan_bet::crash::{commit_seed, crash_point_from_seed};
1717
1718 let mut h = Harness::new();
1719 h.enter_crash();
1720 h.key(Key::Char(' '));
1721 let mut seed = [0u8; 32];
1722 seed[..8].copy_from_slice(&(0.67_f64 * 18_446_744_073_709_551_616.0).to_be_bytes());
1723 let commit = commit_seed(&seed);
1724 let point = crash_point_from_seed(&seed);
1725 let hex = seed
1726 .iter()
1727 .map(|byte| format!("{byte:02x}"))
1728 .collect::<String>();
1729
1730 let mut cashed = crash_state("cashed", 2.0, Some(point), 20, 1010);
1731 cashed.commit = Some(commit);
1732 cashed.seed = Some(hex);
1733 h.reply(&crash_line("CRASH_STATE", &cashed));
1734
1735 assert!(
1736 h.board()[6].contains("verified"),
1737 "fairness line: {}",
1738 h.board()[6]
1739 );
1740}