Skip to content

Commit ff2b9e9

Browse files
author
DogLooksGood
committed
Add one test for example/minimal
1 parent b0a5b27 commit ff2b9e9

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

examples/minimal/src/lib.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ enum MinimalEvent {
88

99
impl CustomEvent for MinimalEvent {}
1010

11-
#[derive(BorshDeserialize)]
11+
#[derive(BorshSerialize, BorshDeserialize)]
1212
struct MinimalAccountData {
1313
init_n: u64,
1414
}
@@ -51,3 +51,37 @@ impl GameHandler for Minimal {
5151
vec![]
5252
}
5353
}
54+
55+
56+
#[cfg(test)]
57+
mod tests {
58+
59+
use race_test::prelude::*;
60+
use super::*;
61+
62+
#[test]
63+
fn test_random_state() {
64+
65+
let mut transactor = TestClient::transactor("tx");
66+
let mut alice = TestClient::player("alice");
67+
68+
let (mut ctx, _) = TestContextBuilder::default()
69+
.with_max_players(10)
70+
.with_deposit_range(100, 200)
71+
.with_data(MinimalAccountData { init_n: 1 })
72+
.set_transactor(&mut transactor)
73+
.add_player(&mut alice, 100)
74+
.build_with_init_state::<Minimal>().unwrap();
75+
76+
{
77+
assert_eq!(ctx.state().n, 1);
78+
}
79+
80+
let e = alice.custom_event(MinimalEvent::Increment(10));
81+
ctx.handle_event(&e).unwrap();
82+
83+
{
84+
assert_eq!(ctx.state().n, 11);
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)