Skip to content

Commit

Permalink
add embed_zip_reverse test
Browse files Browse the repository at this point in the history
  • Loading branch information
monoid committed Aug 8, 2024
1 parent c8f8297 commit 9725bf9
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions air/tests/test_module/instructions/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,53 @@ async fn embed_with_join_behavior() {
let trace = trace_from_result(&result);
assert_eq!(trace.len(), 2);
}

#[tokio::test]
async fn embed_zip_reverse() {
let mut vm = create_avm(echo_call_service(), "").await;

let script = r##"
(seq
(seq
(seq
(ap 1 $stream)
(ap 2 $stream))
(canon %init_peer_id% $stream #canon))
(seq
(embed [#canon #canon]
#"
v1 = get_value(0)
v2 = get_value(1)
if get_tetraplet(0)['peer_pk'] != get_tetraplet(1)['peer_pk']:
fail(42, "tetraplet peer_pk mismatch")
(list(zip(v1, reversed(v2))), get_tetraplet(0))
"#
var2)
(call %init_peer_id% ("" "") [var2] var3)))"##;

let result = call_vm!(vm, <_>::default(), script, "", "");

assert_eq!(result.error_message, "", "{}", result.error_message);
assert_eq!(result.ret_code, 0);

let expected_trace = vec![
ap(0),
ap(0),
canon(json!({
"tetraplet": {"function_name": "", "lens": "", "peer_pk": "", "service_id": ""},
"values": [{
"tetraplet": {"function_name": "", "lens": "", "peer_pk": "", "service_id": ""},
"result": 1
}, {
"tetraplet": {"function_name": "", "lens": "", "peer_pk": "", "service_id": ""},
"result": 2
}]
})),
scalar!(json!([(1, 2), (2, 1)]), args = [json!([[1, 2], (2, 1)])]),
];
let data = data_from_result(&result);
let trace = trace_from_result(&result);
assert_eq!(&*trace, expected_trace, "{:#?}", data.cid_info);
}

0 comments on commit 9725bf9

Please sign in to comment.