File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+
3+ use crate :: build_solidity;
4+ use soroban_sdk:: { IntoVal , String , Vec } ;
5+
6+ #[ test]
7+ fn hello_world ( ) {
8+ let runtime = build_solidity (
9+ r#"
10+ contract HelloWorld {
11+ function hello(string memory to) public pure returns (string[] memory) {
12+ string[] memory res = new string[](2);
13+ res[0] = "Hello";
14+ res[1] = to;
15+ return res;
16+ }
17+ }"# ,
18+ |_| { } ,
19+ ) ;
20+
21+ let addr = runtime. contracts . last ( ) . unwrap ( ) ;
22+
23+ let to_str = String :: from_str ( & runtime. env , "Dev" ) ;
24+ let res = runtime. invoke_contract ( addr, "hello" , vec ! [ to_str. into_val( & runtime. env) ] ) ;
25+
26+ let vec_res: Vec < String > = res. into_val ( & runtime. env ) ;
27+ println ! ( "Logs: {:?}" , runtime. env. logs( ) . all( ) ) ;
28+ assert_eq ! ( vec_res. len( ) , 2 ) ;
29+
30+ // Check elements
31+ let _str0 = vec_res. get ( 0 ) . unwrap ( ) ;
32+ let _str1 = vec_res. get ( 1 ) . unwrap ( ) ;
33+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ mod auth;
66mod constructor;
77mod cross_contract_calls;
88mod events;
9+ mod hello_world;
910mod i256_u256;
1011mod integer_width_rounding;
1112mod integer_width_warnings;
You can’t perform that action at this time.
0 commit comments