@@ -262,3 +262,49 @@ pub async fn sign_tx(
262262
263263 Ok ( cbor)
264264}
265+
266+ #[ cfg( test) ]
267+ mod tests {
268+ use super :: * ;
269+
270+ // The invoke glue cshell owns: `prepare_invocation` (load the .tii + select
271+ // the tx) → `load_args` (parse `--args-json` → `set_args`) →
272+ // `into_resolve_request`. A complex record arg must serialize to the tagged
273+ // wire form while scalars stay bare — the `05-invoke` arg surface.
274+ #[ test]
275+ fn invoke_encodes_diverse_args_into_resolve_request ( ) {
276+ let tii = format ! ( "{}/tests/fixtures/invoke.tii" , env!( "CARGO_MANIFEST_DIR" ) ) ;
277+ let mut invocation =
278+ prepare_invocation ( Path :: new ( & tii) , Some ( "transfer" ) , None ) . unwrap ( ) ;
279+
280+ let args_json = r#"{
281+ "quantity": 2000000,
282+ "urgent": true,
283+ "memo": "deadbeef",
284+ "meta": { "tags": [1, 2, 3], "level": 7 }
285+ }"# ;
286+ load_args ( & mut invocation, Some ( args_json) , None ) . unwrap ( ) ;
287+
288+ let request = invocation. into_resolve_request ( ) . unwrap ( ) ;
289+
290+ // Record `meta` → tagged struct; fields positional in declared order
291+ // (tags, level), not alphabetical.
292+ assert_eq ! (
293+ request. args[ "meta" ] ,
294+ json!( {
295+ "struct" : {
296+ "constructor" : 0 ,
297+ "fields" : [
298+ { "list" : [ { "int" : 1 } , { "int" : 2 } , { "int" : 3 } ] } ,
299+ { "int" : 7 }
300+ ]
301+ }
302+ } )
303+ ) ;
304+
305+ // Scalars stay bare for the resolver to coerce via the flat type.
306+ assert_eq ! ( request. args[ "quantity" ] , json!( 2000000 ) ) ;
307+ assert_eq ! ( request. args[ "urgent" ] , json!( true ) ) ;
308+ assert_eq ! ( request. args[ "memo" ] , json!( "deadbeef" ) ) ;
309+ }
310+ }
0 commit comments