@@ -10,7 +10,7 @@ use crate::{
1010 budget:: AsBudget , events:: HostEvent , test:: observe:: ObservedHost , xdr:: ScErrorType ,
1111 ContractFunctionSet , Error , Host , HostError , Symbol , Tag ,
1212} ;
13- use soroban_test_wasms:: { ADD_I32 , ALLOC , ERR , INVOKE_CONTRACT , VEC } ;
13+ use soroban_test_wasms:: { ADD_I32 , ALLOC , ERR , INVOKE_CONTRACT , STORAGE_LIST , VEC } ;
1414
1515#[ test]
1616fn invoke_single_contract_function ( ) -> Result < ( ) , HostError > {
@@ -44,6 +44,38 @@ fn invoke_single_contract_function() -> Result<(), HostError> {
4444 Ok ( ( ) )
4545}
4646
47+ #[ test]
48+ fn invoke_storage_list ( ) -> Result < ( ) , HostError > {
49+ let host = observe_host ! ( Host :: test_host_with_recording_footprint( ) ) ;
50+ let contract_id_obj = host. register_test_contract_wasm ( STORAGE_LIST ) ;
51+ let a = 4i32 ;
52+ let b = 7i32 ;
53+ let c = 0x7fffffff_i32 ;
54+
55+ let res = host. call (
56+ contract_id_obj,
57+ Symbol :: try_from_small_str ( "add" ) ?,
58+ host. test_vec_obj ( & [ a, b] ) ?,
59+ ) ?;
60+ assert_eq ! ( i32 :: try_from_val( & * host, & res) ?, a + b) ;
61+ // overflow
62+ let res = host. call (
63+ contract_id_obj,
64+ Symbol :: try_from_small_str ( "add" ) ?,
65+ host. test_vec_obj ( & [ a, c] ) ?,
66+ ) ;
67+ let code = ( ScErrorType :: WasmVm , ScErrorCode :: InvalidAction ) ;
68+
69+ eprintln ! (
70+ "time ellapsed in nano-seconds for VmInstantiation: {}" ,
71+ host. as_budget( )
72+ . get_time( ContractCostType :: VmInstantiation ) ?
73+ ) ;
74+
75+ assert ! ( HostError :: result_matches_err( res, code) ) ;
76+ Ok ( ( ) )
77+ }
78+
4779#[ test]
4880fn invoke_alloc ( ) -> Result < ( ) , HostError > {
4981 let host = observe_host ! ( Host :: test_host_with_recording_footprint( ) ) ;
0 commit comments