File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed
Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ enum MinimalEvent {
88
99impl CustomEvent for MinimalEvent { }
1010
11- #[ derive( BorshDeserialize ) ]
11+ #[ derive( BorshSerialize , BorshDeserialize ) ]
1212struct 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+ }
You can’t perform that action at this time.
0 commit comments