summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-29 23:08:25 +0100
committersalmonik <salmonik@tuta.io>2026-10-29 23:08:25 +0100
commit80d9aa13251f7f5c3d3eeaa877bc79dac4435341 (patch)
tree62e8b341749fa0644b9877ae621583929a9c1a29 /tests
parentv3.1.0: warn on shrink, but let a live round finish (diff)
downloadzagan-bet-80d9aa13251f7f5c3d3eeaa877bc79dac4435341.tar.gz
zagan-bet-80d9aa13251f7f5c3d3eeaa877bc79dac4435341.zip
PLN changed to Kromer
Diffstat (limited to 'tests')
-rw-r--r--tests/client_core.rs199
-rw-r--r--tests/crash.rs8
2 files changed, 109 insertions, 98 deletions
diff --git a/tests/client_core.rs b/tests/client_core.rs
index a7c5716..bb8772e 100644
--- a/tests/client_core.rs
+++ b/tests/client_core.rs
@@ -173,7 +173,7 @@ fn play_shows_a_ten_line_board_and_fetches_the_balance() {
173 h.line("play slots 50"); 173 h.line("play slots 50");
174 174
175 assert_eq!(h.board().len(), 10); 175 assert_eq!(h.board().len(), 10);
176 assert!(h.board()[1].contains("Bet: 50 PLN")); 176 assert!(h.board()[1].contains("Bet: 50 Kr"));
177 assert!(!h.board()[1].contains("Lines:")); 177 assert!(!h.board()[1].contains("Lines:"));
178 assert!(h.board()[5].contains("Pays bet x symbol x shape")); 178 assert!(h.board()[5].contains("Pays bet x symbol x shape"));
179 assert!(h.board()[6].contains("Symbol C1 L2 O3 G4 D6 S10")); 179 assert!(h.board()[6].contains("Symbol C1 L2 O3 G4 D6 S10"));
@@ -182,7 +182,7 @@ fn play_shows_a_ten_line_board_and_fetches_the_balance() {
182 182
183 h.reply("INFO alice 1 1000"); 183 h.reply("INFO alice 1 1000");
184 assert_eq!(h.board().len(), 10); 184 assert_eq!(h.board().len(), 10);
185 assert!(h.board()[1].contains("Balance: 1000 PLN")); 185 assert!(h.board()[1].contains("Balance: 1000 Kr"));
186} 186}
187 187
188#[test] 188#[test]
@@ -200,13 +200,14 @@ fn spin_replaces_the_board_and_keeps_the_controls_line() {
200 200
201 h.reply("GAME_RESULT session-1 50 50 1000 CCCCLLCLODGSDGS win 1 0,3,6"); 201 h.reply("GAME_RESULT session-1 50 50 1000 CCCCLLCLODGSDGS win 1 0,3,6");
202 assert_eq!(h.board().len(), 10); 202 assert_eq!(h.board().len(), 10);
203 assert!(h 203 assert!(
204 .board() 204 h.board()
205 .get(2) 205 .get(2)
206 .is_some_and(|line| line.contains("{ C } { C } { C } [ D ] [ D ]"))); 206 .is_some_and(|line| line.contains("{ C } { C } { C } [ D ] [ D ]"))
207 assert!(h.board()[7].contains("Won 50 PLN")); 207 );
208 assert!(h.board()[7].contains("Won 50 Kr"));
208 assert!(h.board()[8].contains("Winning lines: 1 (top)")); 209 assert!(h.board()[8].contains("Winning lines: 1 (top)"));
209 assert!(h.board()[1].contains("Balance: 1000 PLN")); 210 assert!(h.board()[1].contains("Balance: 1000 Kr"));
210 assert!(h.board()[9].contains("[Q] Quit")); 211 assert!(h.board()[9].contains("[Q] Quit"));
211 assert_eq!(h.screen.lines.len(), lines_before_spin); 212 assert_eq!(h.screen.lines.len(), lines_before_spin);
212} 213}
@@ -219,7 +220,7 @@ fn equals_increases_the_bet_like_plus() {
219 h.key(Key::Char('=')); 220 h.key(Key::Char('='));
220 221
221 assert_eq!(h.board().len(), 10); 222 assert_eq!(h.board().len(), 10);
222 assert!(h.board()[1].contains("Bet: 20 PLN")); 223 assert!(h.board()[1].contains("Bet: 20 Kr"));
223} 224}
224 225
225#[test] 226#[test]
@@ -233,11 +234,12 @@ fn changing_the_bet_after_a_spin_does_not_leave_stale_lines() {
233 h.key(Key::Char('+')); 234 h.key(Key::Char('+'));
234 235
235 assert_eq!(h.board().len(), 10); 236 assert_eq!(h.board().len(), 10);
236 assert!(h.board()[1].contains("Bet: 60 PLN")); 237 assert!(h.board()[1].contains("Bet: 60 Kr"));
237 assert!(h 238 assert!(
238 .board() 239 h.board()
239 .get(2) 240 .get(2)
240 .is_some_and(|line| line.contains("{ C } { C } { C } [ D ] [ D ]"))); 241 .is_some_and(|line| line.contains("{ C } { C } { C } [ D ] [ D ]"))
242 );
241 assert_eq!(h.screen.lines.len(), lines_before_bet); 243 assert_eq!(h.screen.lines.len(), lines_before_bet);
242 assert_eq!( 244 assert_eq!(
243 h.screen 245 h.screen
@@ -272,9 +274,11 @@ fn a_mega_win_shows_all_winning_lines() {
272 h.reply(&format!("GAME_RESULT session-1 700 10 1690 {ALL_C} mega 1,2,3,4,5 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14")); 274 h.reply(&format!("GAME_RESULT session-1 700 10 1690 {ALL_C} mega 1,2,3,4,5 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14"));
273 275
274 assert_eq!(h.board().len(), 10); 276 assert_eq!(h.board().len(), 10);
275 assert!(h.board()[7].contains("MEGA WIN! 700 PLN")); 277 assert!(h.board()[7].contains("MEGA WIN! 700 Kr"));
276 assert!(h.board()[8] 278 assert!(
277 .contains("Winning lines: 1 (top), 2 (middle), 3 (bottom), 4 (V), 5 (inverted V)")); 279 h.board()[8]
280 .contains("Winning lines: 1 (top), 2 (middle), 3 (bottom), 4 (V), 5 (inverted V)")
281 );
278 assert_eq!(h.board()[2].matches("{ C }").count(), 5); 282 assert_eq!(h.board()[2].matches("{ C }").count(), 5);
279} 283}
280 284
@@ -371,11 +375,12 @@ fn tab_completion_list_wraps() {
371 375
372 h.key(Key::Tab); 376 h.key(Key::Tab);
373 377
374 assert!(h 378 assert!(
375 .screen 379 h.screen
376 .lines 380 .lines
377 .iter() 381 .iter()
378 .any(|line| line == "Possible completions:")); 382 .any(|line| line == "Possible completions:")
383 );
379 for line in h 384 for line in h
380 .screen 385 .screen
381 .lines 386 .lines
@@ -398,7 +403,7 @@ fn play_without_a_bet_uses_the_default() {
398 h.line("play slots"); 403 h.line("play slots");
399 404
400 assert_eq!(h.board().len(), 10); 405 assert_eq!(h.board().len(), 10);
401 assert!(h.board()[1].contains("Bet: 10 PLN")); 406 assert!(h.board()[1].contains("Bet: 10 Kr"));
402} 407}
403 408
404#[test] 409#[test]
@@ -407,11 +412,12 @@ fn an_invalid_bet_does_not_start_a_game() {
407 h.line("play slots 5"); 412 h.line("play slots 5");
408 413
409 assert!(h.board().is_empty()); 414 assert!(h.board().is_empty());
410 assert!(h 415 assert!(
411 .screen 416 h.screen
412 .lines 417 .lines
413 .iter() 418 .iter()
414 .any(|line| line.contains("Bet must be at least 10 PLN"))); 419 .any(|line| line.contains("Bet must be at least 10 Kr"))
420 );
415} 421}
416 422
417#[test] 423#[test]
@@ -438,20 +444,22 @@ fn play_requires_a_connection_and_a_login() {
438 let mut h = Harness::new(); 444 let mut h = Harness::new();
439 h.core.set_connected(false); 445 h.core.set_connected(false);
440 h.line("play slots"); 446 h.line("play slots");
441 assert!(h 447 assert!(
442 .screen 448 h.screen
443 .lines 449 .lines
444 .iter() 450 .iter()
445 .any(|line| line.contains("Not connected"))); 451 .any(|line| line.contains("Not connected"))
452 );
446 453
447 let mut h = Harness::new(); 454 let mut h = Harness::new();
448 h.core.set_logged_in(None); 455 h.core.set_logged_in(None);
449 h.line("play slots"); 456 h.line("play slots");
450 assert!(h 457 assert!(
451 .screen 458 h.screen
452 .lines 459 .lines
453 .iter() 460 .iter()
454 .any(|line| line.contains("Not logged in"))); 461 .any(|line| line.contains("Not logged in"))
462 );
455} 463}
456 464
457#[test] 465#[test]
@@ -489,26 +497,24 @@ fn info_shows_the_host_and_the_server_fields() {
489 ); 497 );
490 498
491 h.line("info"); 499 h.line("info");
492 assert!(h 500 assert!(
493 .screen 501 h.screen
494 .lines 502 .lines
495 .iter() 503 .iter()
496 .any(|line| line.contains("Connected to: 127.0.0.1:11525"))); 504 .any(|line| line.contains("Connected to: 127.0.0.1:11525"))
497 assert!(h 505 );
498 .screen 506 assert!(
499 .lines 507 h.screen
500 .iter() 508 .lines
501 .any(|line| line.contains("Fingerprint: deadbeef"))); 509 .iter()
510 .any(|line| line.contains("Fingerprint: deadbeef"))
511 );
502 512
503 h.reply("INFO alice 42 1234"); 513 h.reply("INFO alice 42 1234");
504 514
505 assert!(h.screen.lines.iter().any(|line| line == "User: alice")); 515 assert!(h.screen.lines.iter().any(|line| line == "User: alice"));
506 assert!(h.screen.lines.iter().any(|line| line == "Account: 42")); 516 assert!(h.screen.lines.iter().any(|line| line == "Account: 42"));
507 assert!(h 517 assert!(h.screen.lines.iter().any(|line| line == "Balance: 1234 Kr"));
508 .screen
509 .lines
510 .iter()
511 .any(|line| line == "Balance: 1234 PLN"));
512} 518}
513 519
514#[test] 520#[test]
@@ -518,11 +524,12 @@ fn info_without_a_connection_does_not_send() {
518 524
519 h.line("info"); 525 h.line("info");
520 526
521 assert!(h 527 assert!(
522 .screen 528 h.screen
523 .lines 529 .lines
524 .iter() 530 .iter()
525 .any(|line| line.contains("Not connected to any host"))); 531 .any(|line| line.contains("Not connected to any host"))
532 );
526 assert!(h.sent.is_empty()); 533 assert!(h.sent.is_empty());
527} 534}
528 535
@@ -554,11 +561,12 @@ fn disconnect_clears_connection_state() {
554 assert!(h.screen.lines.iter().any(|line| line == "Disconnected")); 561 assert!(h.screen.lines.iter().any(|line| line == "Disconnected"));
555 562
556 h.line("play slots"); 563 h.line("play slots");
557 assert!(h 564 assert!(
558 .screen 565 h.screen
559 .lines 566 .lines
560 .iter() 567 .iter()
561 .any(|line| line.contains("Not connected"))); 568 .any(|line| line.contains("Not connected"))
569 );
562} 570}
563 571
564#[test] 572#[test]
@@ -597,8 +605,8 @@ fn roulette_cursor_places_bets_and_spins() {
597 605
598 assert_eq!(h.board().len(), 12); 606 assert_eq!(h.board().len(), 12);
599 assert_eq!(h.board()[0], "=== ROULETTE ==="); 607 assert_eq!(h.board()[0], "=== ROULETTE ===");
600 assert!(h.board()[1].contains("Balance: 1000 PLN")); 608 assert!(h.board()[1].contains("Balance: 1000 Kr"));
601 assert!(h.board()[1].contains("Chip: 10 PLN")); 609 assert!(h.board()[1].contains("Chip: 10 Kr"));
602 assert!(h.board()[9].contains("Bets: (none)")); 610 assert!(h.board()[9].contains("Bets: (none)"));
603 // The cursor starts on number 1, the bottom-left corner. 611 // The cursor starts on number 1, the bottom-left corner.
604 assert!(h.board()[5].contains("[ 1 ]")); 612 assert!(h.board()[5].contains("[ 1 ]"));
@@ -611,14 +619,14 @@ fn roulette_cursor_places_bets_and_spins() {
611 619
612 h.key(Key::Enter); 620 h.key(Key::Enter);
613 assert!(h.board()[9].contains("2/3 10")); 621 assert!(h.board()[9].contains("2/3 10"));
614 assert!(h.board()[9].contains("Total: 10 PLN")); 622 assert!(h.board()[9].contains("Total: 10 Kr"));
615 623
616 // Back down to number 1 and place a straight. 624 // Back down to number 1 and place a straight.
617 h.key(Key::Down); 625 h.key(Key::Down);
618 h.key(Key::Down); 626 h.key(Key::Down);
619 h.key(Key::Enter); 627 h.key(Key::Enter);
620 assert!(h.board()[9].contains("1 10")); 628 assert!(h.board()[9].contains("1 10"));
621 assert!(h.board()[9].contains("Total: 20 PLN")); 629 assert!(h.board()[9].contains("Total: 20 Kr"));
622 630
623 h.key(Key::Char(' ')); 631 h.key(Key::Char(' '));
624 let request = h 632 let request = h
@@ -637,8 +645,8 @@ fn roulette_cursor_places_bets_and_spins() {
637 )); 645 ));
638 646
639 assert_eq!(h.board().len(), 12); 647 assert_eq!(h.board().len(), 12);
640 assert!(h.board()[1].contains("Balance: 1160 PLN")); 648 assert!(h.board()[1].contains("Balance: 1160 Kr"));
641 assert!(h.board()[10].contains("Won 180 PLN at 3 RED ODD")); 649 assert!(h.board()[10].contains("Won 180 Kr at 3 RED ODD"));
642 assert!(h.board()[10].contains("+160")); 650 assert!(h.board()[10].contains("+160"));
643} 651}
644 652
@@ -672,16 +680,17 @@ fn roulette_rejects_an_empty_spin_and_accepts_the_equals_chip_key() {
672 680
673 h.key(Key::Char(' ')); 681 h.key(Key::Char(' '));
674 assert!(h.board()[10].contains("ERROR: Place at least one bet")); 682 assert!(h.board()[10].contains("ERROR: Place at least one bet"));
675 assert!(!h 683 assert!(
676 .sent 684 !h.sent
677 .iter() 685 .iter()
678 .any(|line| line.starts_with("PLAY_START roulette"))); 686 .any(|line| line.starts_with("PLAY_START roulette"))
687 );
679 688
680 h.key(Key::Char('=')); 689 h.key(Key::Char('='));
681 assert!(h.board()[1].contains("Chip: 20 PLN")); 690 assert!(h.board()[1].contains("Chip: 20 Kr"));
682 h.key(Key::Enter); 691 h.key(Key::Enter);
683 assert!(h.board()[9].contains("1 20")); 692 assert!(h.board()[9].contains("1 20"));
684 assert!(h.board()[9].contains("Total: 20 PLN")); 693 assert!(h.board()[9].contains("Total: 20 Kr"));
685} 694}
686 695
687fn bj_state( 696fn bj_state(
@@ -776,7 +785,7 @@ fn blackjack_deals_hits_and_settles() {
776 serde_json::to_string(&done).unwrap() 785 serde_json::to_string(&done).unwrap()
777 )); 786 ));
778 787
779 assert!(h.board()[4].contains("Win! Won 20 PLN")); 788 assert!(h.board()[4].contains("Win! Won 20 Kr"));
780 assert!(h.board()[5].contains("[SPACE] New hand")); 789 assert!(h.board()[5].contains("[SPACE] New hand"));
781 790
782 h.key(Key::Char('q')); 791 h.key(Key::Char('q'));
@@ -835,11 +844,12 @@ fn blackjack_forfeit_is_sent_when_leaving_an_active_hand() {
835 )); 844 ));
836 845
837 assert!(h.board().is_empty()); 846 assert!(h.board().is_empty());
838 assert!(h 847 assert!(
839 .screen 848 h.screen
840 .lines 849 .lines
841 .iter() 850 .iter()
842 .any(|line| line.contains("forfeited (10 PLN lost)"))); 851 .any(|line| line.contains("forfeited (10 Kr lost)"))
852 );
843} 853}
844 854
845#[test] 855#[test]
@@ -848,7 +858,7 @@ fn blackjack_ready_board_can_change_the_next_bet() {
848 h.enter_blackjack(); 858 h.enter_blackjack();
849 859
850 h.key(Key::Char('=')); 860 h.key(Key::Char('='));
851 assert!(h.board()[1].contains("Bet: 20 PLN")); 861 assert!(h.board()[1].contains("Bet: 20 Kr"));
852 862
853 h.key(Key::Char(' ')); 863 h.key(Key::Char(' '));
854 assert!(h.sent.iter().any(|line| line == "PLAY_START blackjack 20")); 864 assert!(h.sent.iter().any(|line| line == "PLAY_START blackjack 20"));
@@ -917,14 +927,14 @@ fn crash_starts_a_round_and_draws_the_multiplier_locally() {
917 927
918 assert_eq!(h.board().len(), 6); 928 assert_eq!(h.board().len(), 6);
919 assert!(h.board()[2].contains("Multiplier: 1.00x")); 929 assert!(h.board()[2].contains("Multiplier: 1.00x"));
920 assert!(h.board()[3].contains("Potential: 10 PLN")); 930 assert!(h.board()[3].contains("Potential: 10 Kr"));
921 assert!(h.board()[4].contains("Rising")); 931 assert!(h.board()[4].contains("Rising"));
922 assert!(h.board()[5].contains("[C] Cash out")); 932 assert!(h.board()[5].contains("[C] Cash out"));
923 933
924 // The multiplier is drawn from the local clock, with no server round trip. 934 // The multiplier is drawn from the local clock, with no server round trip.
925 h.tick(Duration::from_secs(5)); 935 h.tick(Duration::from_secs(5));
926 assert!(h.board()[2].contains("Multiplier: 2.00x")); 936 assert!(h.board()[2].contains("Multiplier: 2.00x"));
927 assert!(h.board()[3].contains("Potential: 20 PLN")); 937 assert!(h.board()[3].contains("Potential: 20 Kr"));
928 938
929 h.key(Key::Char('c')); 939 h.key(Key::Char('c'));
930 assert_eq!(h.sent.last().map(String::as_str), Some("CRASH_CASHOUT cr1")); 940 assert_eq!(h.sent.last().map(String::as_str), Some("CRASH_CASHOUT cr1"));
@@ -932,9 +942,9 @@ fn crash_starts_a_round_and_draws_the_multiplier_locally() {
932 let cashed = crash_state("cashed", 2.0, Some(3.0), 20, 1010); 942 let cashed = crash_state("cashed", 2.0, Some(3.0), 20, 1010);
933 h.reply(&crash_line("CRASH_STATE", &cashed)); 943 h.reply(&crash_line("CRASH_STATE", &cashed));
934 944
935 assert!(h.board()[4].contains("Cashed out at 2.00x Won 20 PLN")); 945 assert!(h.board()[4].contains("Cashed out at 2.00x Won 20 Kr"));
936 assert!(h.board()[5].contains("[SPACE] Play")); 946 assert!(h.board()[5].contains("[SPACE] Play"));
937 assert_eq!(h.board()[1], "Balance: 1010 PLN Bet: 10 PLN"); 947 assert_eq!(h.board()[1], "Balance: 1010 Kr Bet: 10 Kr");
938} 948}
939 949
940#[test] 950#[test]
@@ -977,11 +987,12 @@ fn crash_q_forfeits_an_active_round() {
977 h.reply(&crash_line("CRASH_STATE", &forfeited)); 987 h.reply(&crash_line("CRASH_STATE", &forfeited));
978 988
979 assert!(h.board().is_empty()); 989 assert!(h.board().is_empty());
980 assert!(h 990 assert!(
981 .screen 991 h.screen
982 .lines 992 .lines
983 .iter() 993 .iter()
984 .any(|line| line.contains("Round forfeited (10 PLN lost)"))); 994 .any(|line| line.contains("Round forfeited (10 Kr lost)"))
995 );
985} 996}
986 997
987#[test] 998#[test]
@@ -990,8 +1001,8 @@ fn crash_ready_board_changes_the_next_bet() {
990 h.enter_crash(); 1001 h.enter_crash();
991 1002
992 h.key(Key::Char('=')); 1003 h.key(Key::Char('='));
993 assert!(h.board()[1].contains("Bet: 20 PLN")); 1004 assert!(h.board()[1].contains("Bet: 20 Kr"));
994 assert!(h.board()[3].contains("Potential: 20 PLN")); 1005 assert!(h.board()[3].contains("Potential: 20 Kr"));
995 1006
996 h.key(Key::Char(' ')); 1007 h.key(Key::Char(' '));
997 assert!(h.sent.iter().any(|line| line == "PLAY_START crash 20")); 1008 assert!(h.sent.iter().any(|line| line == "PLAY_START crash 20"));
@@ -1058,7 +1069,7 @@ fn a_forfeit_that_arrives_after_the_bust_still_leaves_cleanly() {
1058 1069
1059 assert!(h.board().is_empty()); 1070 assert!(h.board().is_empty());
1060 assert!(h.screen.lines.iter().any(|line| line == "Game exited.")); 1071 assert!(h.screen.lines.iter().any(|line| line == "Game exited."));
1061 assert!(!h.screen.lines.iter().any(|line| line.contains("PLN lost"))); 1072 assert!(!h.screen.lines.iter().any(|line| line.contains("Kr lost")));
1062} 1073}
1063 1074
1064#[test] 1075#[test]
diff --git a/tests/crash.rs b/tests/crash.rs
index 49eaf89..c985ebe 100644
--- a/tests/crash.rs
+++ b/tests/crash.rs
@@ -2,8 +2,8 @@
2 2
3use std::time::Duration; 3use std::time::Duration;
4use zagan_bet::crash::{ 4use zagan_bet::crash::{
5 crash_point_from_uniform, multiplier_at, multiplier_at_secs, payout, time_for_multiplier, 5 HOUSE_EDGE, MAX_MULTIPLIER, crash_point_from_uniform, multiplier_at, multiplier_at_secs,
6 HOUSE_EDGE, MAX_MULTIPLIER, 6 payout, time_for_multiplier,
7}; 7};
8 8
9fn close(a: f64, b: f64, tolerance: f64) { 9fn close(a: f64, b: f64, tolerance: f64) {
@@ -38,9 +38,9 @@ fn the_time_for_a_multiplier_is_the_inverse_of_the_curve() {
38} 38}
39 39
40#[test] 40#[test]
41fn cashout_value_is_floored_to_whole_pln() { 41fn cashout_value_is_floored_to_whole_Kr() {
42 assert_eq!(payout(10, 1.0), 10); 42 assert_eq!(payout(10, 1.0), 10);
43 assert_eq!(payout(10, 1.05), 10, "half a PLN is not paid out"); 43 assert_eq!(payout(10, 1.05), 10, "half a Kr is not paid out");
44 assert_eq!(payout(10, 1.10), 11); 44 assert_eq!(payout(10, 1.10), 11);
45 assert_eq!(payout(10, 2.47), 24); 45 assert_eq!(payout(10, 2.47), 24);
46 assert_eq!(payout(7, 3.0), 21); 46 assert_eq!(payout(7, 3.0), 21);