chore: remove fstrings dep (#627)

* remove fstrings dep

---------

Co-authored-by: Ivan Boldyrev <ivan@fluence.one>
This commit is contained in:
Mike Voronov 2023-07-14 16:02:19 +03:00 committed by GitHub
parent adcf708c95
commit d5a3f768af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 795 additions and 469 deletions

31
Cargo.lock generated
View File

@ -158,7 +158,6 @@ dependencies = [
"avm-server",
"ed25519-dalek",
"fluence-keypair",
"fstrings",
"maplit",
"marine-rs-sdk",
"object-pool",
@ -320,7 +319,6 @@ dependencies = [
"env_logger 0.7.1",
"fluence-app-service",
"fluence-keypair",
"fstrings",
"log",
"maplit",
"marine-rs-sdk",
@ -370,7 +368,6 @@ dependencies = [
"codespan",
"codespan-reporting",
"criterion 0.4.0",
"fstrings",
"itertools",
"lalrpop",
"lalrpop-util",
@ -1596,28 +1593,6 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "fstrings"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7845a0f15da505ac36baad0486612dab57f8b8d34e19c5470a265bbcdd572ae6"
dependencies = [
"fstrings-proc-macro",
"proc-macro-hack",
]
[[package]]
name = "fstrings-proc-macro"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63b58c0e7581dc33478a32299182cbe5ae3b8c028be26728a47fb0a113c92d9d"
dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "fxhash"
version = "0.2.1"
@ -2829,12 +2804,6 @@ dependencies = [
"version_check",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.20+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]]
name = "proc-macro2"
version = "1.0.63"

View File

@ -38,7 +38,6 @@ maplit = "1.0.2"
non-empty-vec = "0.2.3"
log = "0.4.17"
once_cell = "1.17.1"
fstrings = "0.2.3"
thiserror = "1.0.40"
semver = "1.0.17"
strum = "0.24"

View File

@ -28,9 +28,6 @@ use air_parser::ast::CallOutputValue;
use air_trace_handler::merger::MetCallResult;
use air_trace_handler::TraceHandler;
use fstrings::f;
use fstrings::format_args_f;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct StateDescriptor {
should_execute: bool,
@ -203,8 +200,9 @@ fn try_to_service_result(
match serde_json::from_str(&service_result.result) {
Ok(result) => Ok(Rc::new(result)),
Err(e) => {
let error_msg =
f!("call_service result '{service_result}' can't be serialized or deserialized with an error: {e}");
let error_msg = format!(
"call_service result '{service_result}' can't be serialized or deserialized with an error: {e}"
);
let error_msg = Rc::new(error_msg);
let failed_value = CallServiceFailed::new(i32::MAX, error_msg.clone()).to_value();

View File

@ -25,14 +25,16 @@ fn seq_par_call() {
let vm_peer_id = "some_peer_id";
let mut vm = create_avm(unit_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(par
(call "{vm_peer_id}" ("local_service_id" "local_fn_name") [] result_1)
(call "remote_peer_id" ("service_id" "fn_name") [] g)
)
(call "{vm_peer_id}" ("local_service_id" "local_fn_name") [] result_2)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
let actual_trace = trace_from_result(&result);
@ -65,14 +67,16 @@ fn par_par_call() {
let remote_peer_id = "remote_peer_id";
let mut vm = create_avm(unit_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(par
(par
(call "{vm_peer_id}" ("local_service_id" "local_fn_name") [] result_1)
(call "{remote_peer_id}" ("service_id" "fn_name") [] g)
)
(call "{vm_peer_id}" ("local_service_id" "local_fn_name") [] result_2)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
let actual_trace = trace_from_result(&result);

View File

@ -38,7 +38,8 @@ fn merge_streams_in_two_fold() {
let mut vm1 = create_avm(return_string_call_service(vm_1_peer_id), vm_1_peer_id);
let mut vm2 = create_avm(return_string_call_service(vm_2_peer_id), vm_2_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("neighborhood" "") [] neighborhood)
(seq
@ -62,7 +63,8 @@ fn merge_streams_in_two_fold() {
)
)
)
"#);
"#
);
let result_0 = checked_call_vm!(set_variable, <_>::default(), &script, "", "");
let result_1 = checked_call_vm!(vm1, <_>::default(), &script, "", result_0.data.clone());
@ -240,7 +242,7 @@ fn fold_merge() {
let mut local_vms = Vec::with_capacity(7);
let mut local_vms_results = Vec::with_capacity(7);
for vm_id in 0..7 {
let peer_id = f!("peer_{vm_id}");
let peer_id = format!("peer_{vm_id}");
let mut vm = create_avm(echo_call_service(), peer_id);
let result = checked_call_vm!(
vm,

View File

@ -26,14 +26,16 @@ fn executed_trace_seq_par_call() {
let remote_peer_id = "remote_peer_id";
let mut vm = create_avm(unit_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(par
(call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_1)
(call "{remote_peer_id}" ("service_id" "fn_name") [] g)
)
(call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_2)
)"#);
)"#
);
let mut cid_state = ExecutionCidState::new();
let unit_call_service_result = "result from unit_call_service";
@ -91,14 +93,16 @@ fn executed_trace_par_par_call() {
let remote_peer_id = "remote_peer_id";
let mut vm = create_avm(unit_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(par
(par
(call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_1)
(call "{remote_peer_id}" ("service_id" "fn_name") [] g)
)
(call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_2)
)"#);
)"#
);
let unit_call_service_result = "result from unit_call_service";
let mut cid_state = ExecutionCidState::new();
@ -163,7 +167,8 @@ fn executed_trace_seq_seq() {
let mut vm1 = create_avm(unit_call_service(), peer_id_1.clone());
let mut vm2 = create_avm(unit_call_service(), peer_id_2.clone());
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{peer_id_1}" ("identity" "") [] void0)
(seq
@ -171,7 +176,8 @@ fn executed_trace_seq_seq() {
(call "{peer_id_2}" ("addBlueprint-14d8488e-d10d-474d-96b2-878f6a7d74c8" "") [] void1)
)
)
"#);
"#
);
let result = checked_call_vm!(vm2, <_>::default(), &script, "", "");
assert_eq!(result.next_peer_pks, vec![peer_id_1]);
@ -595,7 +601,8 @@ fn executed_trace_seq_par_seq_seq() {
let peer_id_2 = "12D3KooWAzJcYitiZrerycVB4Wryrx22CFKdDGx7c4u31PFdfTbR";
let mut vm1 = create_avm(unit_call_service(), peer_id_1);
let mut vm2 = create_avm(unit_call_service(), peer_id_2);
let script = f!(r#"
let script = format!(
r#"
(seq
(par
(seq
@ -609,7 +616,8 @@ fn executed_trace_seq_par_seq_seq() {
)
(call "{peer_id_2}" ("" "") [] result_5)
)
"#);
"#
);
let result = checked_call_vm!(vm2, <_>::default(), &script, "", "");
assert_eq!(result.next_peer_pks, vec![peer_id_1.to_string()]);

View File

@ -98,7 +98,8 @@ fn not_clear_last_error_in_match() {
let tetraplets = Rc::new(RefCell::new(None));
let mut local_vm = create_avm(create_check_service_closure(args.clone(), tetraplets), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") [] relayVariableName)
(xor
@ -111,7 +112,8 @@ fn not_clear_last_error_in_match() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let _ = checked_call_vm!(local_vm, <_>::default(), &script, "", result.data);
@ -131,7 +133,8 @@ fn not_clear_last_error_in_mismatch() {
let tetraplets = Rc::new(RefCell::new(None));
let mut local_vm = create_avm(create_check_service_closure(args.clone(), tetraplets), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") [] relayVariableName)
(xor
@ -144,7 +147,8 @@ fn not_clear_last_error_in_mismatch() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let _ = checked_call_vm!(local_vm, <_>::default(), &script, "", result.data);
@ -164,12 +168,14 @@ fn track_current_peer_id() {
let tetraplets = Rc::new(RefCell::new(None));
let mut local_vm = create_avm(create_check_service_closure(args.clone(), tetraplets), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(call "{fallible_peer_id}" ("fallible_call_service" "") [""])
(call "{local_peer_id}" ("" "") [%last_error%])
)
"#);
"#
);
let result = checked_call_vm!(fallible_vm, <_>::default(), &script, "", "");
let _ = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
@ -187,7 +193,8 @@ fn variable_names_shown_in_error() {
let echo_vm_peer_id = "echo_vm_peer_id";
let mut echo_vm = create_avm(echo_call_service(), echo_vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(call "{set_variable_vm_peer_id}" ("" "") [""] -relay-)
@ -195,7 +202,8 @@ fn variable_names_shown_in_error() {
)
(call "{echo_vm_peer_id}" ("" "") [%last_error%.$.message])
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(echo_vm, <_>::default(), script, "", result.data);
@ -215,12 +223,14 @@ fn non_initialized_last_error() {
vm_peer_id,
);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [%last_error%])
(null)
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id("init_peer_id");
let _ = checked_call_vm!(vm, test_params.clone(), script, "", "");
@ -243,12 +253,14 @@ fn access_last_error_by_not_exists_field() {
let local_peer_id = "local_peer_id";
let non_exists_field_name = "non_exists_field";
let script = f!(r#"
let script = format!(
r#"
(xor
(call "{fallible_peer_id}" ("fallible_call_service" "") [""])
(call "{local_peer_id}" ("" "") [%last_error%.$.{non_exists_field_name}])
)
"#);
"#
);
let result = call_vm!(fallible_vm, <_>::default(), &script, "", "");
@ -276,7 +288,8 @@ fn last_error_with_par_one_subgraph_failed() {
let args = Rc::new(RefCell::new(None));
let tetraplets = Rc::new(RefCell::new(None));
let mut vm = create_avm(create_check_service_closure(args.clone(), tetraplets), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(par
(call "{fallible_peer_id}" ("{fallible_call_service_name}" "") [""])
@ -284,7 +297,8 @@ fn last_error_with_par_one_subgraph_failed() {
)
(call "{vm_peer_id}" ("" "") [%last_error%])
)
"#);
"#
);
let result = checked_call_vm!(fallible_vm, <_>::default(), &script, "", "");
let _ = checked_call_vm!(vm, <_>::default(), script, "", result.data);
@ -304,7 +318,8 @@ fn fail_with_scalar_rebubble_error() {
let fallible_peer_id = "fallible_peer_id";
let mut fallible_vm = create_avm(fallible_call_service("fallible_call_service"), fallible_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(call "{fallible_peer_id}" ("fallible_call_service" "") [""])
(seq
@ -312,7 +327,8 @@ fn fail_with_scalar_rebubble_error() {
(fail scalar)
)
)
"#);
"#
);
let result = call_vm!(fallible_vm, <_>::default(), &script, "", "");
@ -335,12 +351,14 @@ fn fail_with_scalar_from_call() {
let service_result = json!({"error_code": error_code, "message": error_message});
let mut vm = create_avm(set_variable_call_service(service_result), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [""] scalar)
(fail scalar)
)
"#);
"#
);
let result = call_vm!(vm, <_>::default(), &script, "", "");
@ -361,12 +379,14 @@ fn fail_with_scalar_with_lambda_from_call() {
let service_result = json!({"error": {"error_code": error_code, "message": error_message}});
let mut vm = create_avm(set_variable_call_service(service_result), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [""] scalar)
(fail scalar.$.error)
)
"#);
"#
);
let result = call_vm!(vm, <_>::default(), &script, "", "");
@ -386,12 +406,14 @@ fn fail_with_scalar_from_call_not_enough_fields() {
let service_result = json!({ "error_code": error_code });
let mut vm = create_avm(set_variable_call_service(service_result.clone()), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [""] scalar)
(fail scalar)
)
"#);
"#
);
let result = call_vm!(vm, <_>::default(), &script, "", "");
@ -408,12 +430,14 @@ fn fail_with_scalar_from_call_not_right_type() {
let service_result = json!([]);
let mut vm = create_avm(set_variable_call_service(service_result.clone()), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [""] scalar)
(fail scalar)
)
"#);
"#
);
let result = call_vm!(vm, <_>::default(), &script, "", "");
@ -428,12 +452,14 @@ fn fail_with_scalar_from_call_field_not_right_type() {
let service_result = json!({"error_code": "error_code", "message": "error message"});
let mut vm = create_avm(set_variable_call_service(service_result.clone()), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [""] scalar)
(fail scalar)
)
"#);
"#
);
let result = call_vm!(vm, <_>::default(), &script, "", "");
@ -450,14 +476,16 @@ fn last_error_with_match() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(fallible_call_service("fallible_call_service"), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(call "{vm_peer_id}" ("fallible_call_service" "") [""])
(match %last_error%.$.error_code 10000
(call "{vm_peer_id}" ("" "") [%last_error%])
)
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");

View File

@ -41,7 +41,8 @@ fn dont_wait_on_json_path() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(unit_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["msg"] msg)
@ -55,7 +56,8 @@ fn dont_wait_on_json_path() {
)
)
)
"#);
"#
);
let test_params = TestRunParameters::default();
let result = checked_call_vm!(set_variable_vm, test_params.clone(), &script, "", "");
@ -90,12 +92,14 @@ fn dont_wait_on_json_path_on_scalars() {
let object_consumer_peer_id = "object_consumer_peer_id";
let mut object_consumer = create_avm(unit_call_service(), object_consumer_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") ["array"] array)
(call "{array_consumer_peer_id}" ("" "") [array.$.[5]!] auth_result)
)
"#);
"#
);
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let array_result = call_vm!(array_consumer, <_>::default(), &script, "", result.data);
@ -104,12 +108,14 @@ fn dont_wait_on_json_path_on_scalars() {
CatchableError::LambdaApplierError(LambdaError::ValueNotContainSuchArrayIdx { value: array, idx: 5 });
assert!(check_error(&array_result, expected_error));
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") ["object"] object)
(call "{object_consumer_peer_id}" ("" "") [object.$.non_exist_path])
)
"#);
"#
);
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let object_result = call_vm!(object_consumer, <_>::default(), script, "", result.data);
@ -129,7 +135,8 @@ fn ap_scalar_with_join_behaviour() {
let mut peer_1 = create_avm(unit_call_service(), peer_1_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "{peer_2_id}" ("" "") [] join_var)
(xor
@ -137,7 +144,8 @@ fn ap_scalar_with_join_behaviour() {
(call "{peer_1_id}" ("" "") []) ;; this call shouldn't be called
)
)
"#);
"#
);
let result = checked_call_vm!(peer_1, <_>::default(), script, "", "");
let trace = trace_from_result(&result);
@ -151,7 +159,8 @@ fn ap_stream_with_join_behaviour() {
let mut peer_1 = create_avm(unit_call_service(), peer_1_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "{peer_2_id}" ("" "") [] join_var)
(xor
@ -159,7 +168,8 @@ fn ap_stream_with_join_behaviour() {
(call "{peer_1_id}" ("" "") []) ;; this call shouldn't be called
)
)
"#);
"#
);
let result = checked_call_vm!(peer_1, <_>::default(), script, "", "");
let trace = trace_from_result(&result);
@ -173,7 +183,8 @@ fn match_with_join_behaviour() {
let mut peer_1 = create_avm(unit_call_service(), peer_1_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "{peer_2_id}" ("" "") [] join_var)
(xor
@ -183,7 +194,8 @@ fn match_with_join_behaviour() {
(call "{peer_1_id}" ("" "") []) ;; this call shouldn't be called
)
)
"#);
"#
);
let result = checked_call_vm!(peer_1, <_>::default(), script, "", "");
let trace = trace_from_result(&result);
@ -197,7 +209,8 @@ fn mismatch_with_join_behaviour() {
let mut peer_1 = create_avm(unit_call_service(), peer_1_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "{peer_2_id}" ("" "") [] join_var)
(xor
@ -207,7 +220,8 @@ fn mismatch_with_join_behaviour() {
(call "{peer_1_id}" ("" "") []) ;; this call shouldn't be called
)
)
"#);
"#
);
let result = checked_call_vm!(peer_1, <_>::default(), script, "", "");
let trace = trace_from_result(&result);
@ -221,7 +235,8 @@ fn fold_with_join_behaviour() {
let mut peer_1 = create_avm(unit_call_service(), peer_1_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "{peer_2_id}" ("" "") [] join_var)
(xor
@ -231,7 +246,8 @@ fn fold_with_join_behaviour() {
(call "{peer_1_id}" ("" "") []) ;; this call shouldn't be called
)
)
"#);
"#
);
let result = checked_call_vm!(peer_1, <_>::default(), script, "", "");
let trace = trace_from_result(&result);
@ -244,9 +260,11 @@ fn canon_with_empty_behaviour() {
let mut peer_2 = create_avm(unit_call_service(), peer_id);
let script = f!(r#"
let script = format!(
r#"
(canon "{peer_id}" $stream #canon_stream)
"#);
"#
);
let result = checked_call_vm!(peer_2, <_>::default(), script, "", "");
let actual_trace = trace_from_result(&result);

View File

@ -58,7 +58,8 @@ fn flattening_scalar_arrays() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(create_check_service_closure(closure_call_args.clone()), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") [] scalar_array)
(fold scalar_array.$.iterable! v
@ -68,7 +69,8 @@ fn flattening_scalar_arrays() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), script.clone(), "", "");
let result = call_vm!(local_vm, <_>::default(), script, "", result.data);
@ -99,7 +101,8 @@ fn flattening_streams() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(create_check_service_closure(closure_call_args.clone()), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -115,7 +118,8 @@ fn flattening_streams() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), script.clone(), "", "");
let result = call_vm!(local_vm, <_>::default(), script, "", result.data);
@ -146,7 +150,8 @@ fn test_handling_non_flattening_values() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(create_check_service_closure(closure_call_args), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -162,7 +167,8 @@ fn test_handling_non_flattening_values() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = call_vm!(local_vm, <_>::default(), &script, "", result.data);

View File

@ -47,12 +47,14 @@ fn length_functor_for_array_scalar() {
#[test]
fn length_functor_for_non_array_scalar() {
let result_jvalue = "string_jvalue";
let script = f!(r#"
let script = format!(
r#"
(seq
(call %init_peer_id% ("" "") [] variable) ; ok = "{result_jvalue}"
(call %init_peer_id% ("" "") [variable.length]) ; behaviour = echo
)
"#);
"#
);
let init_peer_id = "init_peer_id";
let executor = AirScriptExecutor::from_annotated(TestRunParameters::from_init_peer_id(init_peer_id), &script)
@ -212,7 +214,8 @@ fn functor_dont_influence_tetraplet() {
let (call_service, actual_tetraplet) = tetraplet_host_function(echo_call_service());
let mut tetraplet_catcher_vm = create_avm(call_service, tetraplet_catcher_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") [] scalar)
(seq
@ -223,7 +226,8 @@ fn functor_dont_influence_tetraplet() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(tetraplet_catcher_vm, <_>::default(), &script, "", result.data);

View File

@ -26,12 +26,14 @@ fn lambda_not_allowed_for_non_objects_and_arrays() {
let local_peer_id = "local_peer_id";
let some_string = "some_string";
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") ["{some_string}"] string_variable)
(call "{local_peer_id}" ("" "") [string_variable.$.some_lambda])
)
"#);
"#
);
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
@ -57,7 +59,8 @@ fn lambda_with_string_scalar() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "string_accessor") [] string_accessor)
@ -65,7 +68,8 @@ fn lambda_with_string_scalar() {
)
(call "{local_peer_id}" ("" "") [value.$.[string_accessor]])
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
@ -89,7 +93,8 @@ fn lambda_with_number_scalar() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "number_accessor") [] number_accessor)
@ -97,7 +102,8 @@ fn lambda_with_number_scalar() {
)
(call "{local_peer_id}" ("" "") [value.$.[number_accessor]])
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
@ -121,7 +127,8 @@ fn lambda_with_number_stream() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "number_accessor") [] number_accessor)
@ -140,7 +147,8 @@ fn lambda_with_number_stream() {
(call "{local_peer_id}" ("" "") [#canon_stream.$.[number_accessor]])
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
@ -169,7 +177,8 @@ fn lambda_with_number_stream_and_followed_scalar() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -191,7 +200,8 @@ fn lambda_with_number_stream_and_followed_scalar() {
(call "{local_peer_id}" ("" "") [#canon_stream.$.[number_accessor].field_1]) ;; get the 2nd value and then access its field
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
@ -218,7 +228,8 @@ fn lambda_with_scalar_join() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(par
(call "non_exist_peer_id" ("" "string_accessor") [] string_accessor)
@ -226,7 +237,8 @@ fn lambda_with_scalar_join() {
)
(call "{local_peer_id}" ("" "") [value.$.[string_accessor]])
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
@ -253,7 +265,8 @@ fn lambda_with_canon_stream_join() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(par
(call "non_exist_peer_id" ("" "number_accessor") [] number_accessor)
@ -272,7 +285,8 @@ fn lambda_with_canon_stream_join() {
(call "{local_peer_id}" ("" "") [#stream.$.[number_accessor]])
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);

View File

@ -21,11 +21,13 @@ fn empty_array() {
let vm_peer_id = "some_peer_id";
let mut vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [[]] result)
(call "{vm_peer_id}" ("" "") [result])
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
let actual_trace = trace_from_result(&result);

View File

@ -33,7 +33,8 @@ fn ap_with_fold() {
let local_vm_peer_id = "local_peer_id";
let mut local_vm = create_avm(unit_call_service(), local_vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_id}" ("" "") [] permutations)
(seq
@ -54,7 +55,8 @@ fn ap_with_fold() {
(seq
(canon "{local_vm_peer_id}" $inner #canon_stream)
(call "{local_vm_peer_id}" ("return" "") [#canon_stream])))))
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
assert_eq!(result.next_peer_pks, vec![local_vm_peer_id.to_string()]);

View File

@ -31,7 +31,8 @@ fn recursive_stream_with_early_exit() {
vm_peer_id,
);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_peer_id}" ("" "stream_value") [] $stream)
@ -51,7 +52,8 @@ fn recursive_stream_with_early_exit() {
)
)
)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
let actual_trace = trace_from_result(&result);
@ -94,7 +96,8 @@ fn recursive_stream_many_iterations() {
let mut vm_2 = create_avm(echo_call_service(), vm_peer_id_2);
let result_value = "result_value";
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -117,7 +120,8 @@ fn recursive_stream_many_iterations() {
)
)
(call "{vm_peer_id_2}" ("" "") ["{result_value}"])
)"#);
)"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -188,7 +192,8 @@ fn recursive_stream_join() {
let mut vm_3 = create_avm(echo_call_service(), vm_peer_id_3);
let result_value = "result_value";
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(par
@ -211,7 +216,8 @@ fn recursive_stream_join() {
)
)
(call "{vm_peer_id_2}" ("" "") ["{result_value}"])
)"#);
)"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm_3, <_>::default(), &script, "", result.data);
@ -266,7 +272,8 @@ fn recursive_stream_error_handling() {
let result_value = "result_value";
let vm_peer_id_2 = "vm_peer_id_2";
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(seq
@ -287,7 +294,8 @@ fn recursive_stream_error_handling() {
)
)
(call "{vm_peer_id_2}" ("" "") ["{result_value}"]))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -340,7 +348,8 @@ fn recursive_stream_inner_fold() {
let mut vm_2 = create_avm(echo_call_service(), vm_peer_id_2);
let result_value = "result_value";
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -366,7 +375,8 @@ fn recursive_stream_inner_fold() {
(next iterator_2))))))
(next iterator_1))))))
(call "{vm_peer_id_2}" ("" "") ["{result_value}"]))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm_2, <_>::default(), script, "", result.data);
@ -398,7 +408,8 @@ fn recursive_stream_fold_with_n_service_call() {
let mut vm = create_avm(give_n_results_and_then_stop, vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(seq
@ -441,7 +452,8 @@ fn recursive_stream_fold_with_n_service_call() {
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id(vm_peer_id);
let result = checked_call_vm!(vm, test_params, &script, "", "");

View File

@ -38,7 +38,8 @@ fn empty_stream() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(arg_type_check_closure(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(par
(call "unknown_peer" ("" "") [] $stream) ; to make validator happy
@ -48,7 +49,8 @@ fn empty_stream() {
)
)
(null)
)"#);
)"#
);
let _ = checked_call_vm!(vm, <_>::default(), script, "", "");
}

View File

@ -55,7 +55,8 @@ fn fold_with_inner_call() {
let service_id = String::from("some_service_id");
let function_name = String::from("some_function_name");
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_vm_peer_id}" ("{service_id}" "{function_name}") [] IterableResultPeer1)
(fold IterableResultPeer1 i
@ -65,7 +66,8 @@ fn fold_with_inner_call() {
)
)
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id("init_peer_id");
let result = checked_call_vm!(set_variable_vm, test_params.clone(), script.clone(), "", "");
@ -200,7 +202,8 @@ fn fold_json_path() {
let service_id = String::from("some_service_id");
let function_name = String::from("some_function_name");
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_vm_peer_id}" ("{service_id}" "{function_name}") [] IterableResultPeer1)
(fold IterableResultPeer1.$.args i
@ -215,7 +218,8 @@ fn fold_json_path() {
)
)
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id("some_init_peer_id");
let result = checked_call_vm!(set_variable_vm, test_params.clone(), script.clone(), "", "");
@ -255,14 +259,16 @@ fn check_tetraplet_works_correctly() {
let service_id = String::from("some_service_id");
let function_name = String::from("some_function_name");
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_vm_peer_id}" ("{service_id}" "{function_name}") [] value)
(seq
(call "{client_peer_id}" ("local_service_id" "local_fn_name") [value.$.args value.$.args.[0]])
(call "{client_peer_id}" ("local_service_id" "local_fn_name") [value.$.args value.$.args.[0]])
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), script.clone(), "", "");
@ -361,12 +367,14 @@ fn tetraplet_with_wasm_modules() {
});
let local_peer_id = "local_peer_id";
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{local_peer_id}" ("auth" "is_authorized") [] auth_result)
(call "{local_peer_id}" ("log_storage" "delete") [auth_result.$.is_authorized "1"])
)
"#);
"#
);
let mut vm = create_avm(host_func, local_peer_id);

View File

@ -25,9 +25,11 @@ fn call_generates_hop() {
let test_peer_id = "test_peer_id";
let script = f!(r#"
let script = format!(
r#"
(call "{test_peer_id}" ("" "") [])
"#);
"#
);
let client_result = checked_call_vm!(client_vm, <_>::default(), script, "", "");
assert_next_pks!(&client_result.next_peer_pks, &[test_peer_id]);
@ -45,7 +47,8 @@ fn call_with_join_behaviour() {
let friend_relay_peer_id = "friend_relay";
let mut friend_relay_vm = create_avm(unit_call_service(), friend_relay_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(seq
@ -98,7 +101,8 @@ fn call_with_join_behaviour() {
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
"#);
"#
);
let keypair = KeyPair::generate(KeyFormat::Ed25519);
let run_parameters = TestRunParameters::new(client_peer_id.to_string(), 0, 0, "".to_string());

View File

@ -25,9 +25,11 @@ fn canon_generates_hop() {
let test_peer_id = "test_peer_id";
let script = f!(r#"
let script = format!(
r#"
(canon "{test_peer_id}" $empty_stream #canon_stream)
"#);
"#
);
let client_result = checked_call_vm!(client_vm, <_>::default(), script, "", "");
assert_next_pks!(&client_result.next_peer_pks, &[test_peer_id]);
@ -45,7 +47,8 @@ fn canon_with_join_behaviour() {
let friend_relay_peer_id = "friend_relay";
let mut friend_relay_vm = create_avm(unit_call_service(), friend_relay_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(seq
@ -122,7 +125,8 @@ fn canon_with_join_behaviour() {
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
"#);
"#
);
let keypair = KeyPair::generate(KeyFormat::Ed25519);
let run_parameters = TestRunParameters::new(client_peer_id.to_string(), 0, 0, "".to_string());

View File

@ -29,7 +29,8 @@ fn ap_with_scalars() {
let vm_2_peer_id = "vm_2_peer_id";
let mut vm_2 = create_avm(echo_call_service(), vm_2_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_1_peer_id}" ("" "") ["scalar_1_result"] scalar_1)
@ -37,7 +38,8 @@ fn ap_with_scalars() {
)
(call "{vm_2_peer_id}" ("" "") [scalar_2])
)
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm_2, <_>::default(), script, "", result.data);
@ -62,13 +64,15 @@ fn ap_with_string_literal() {
let mut vm_1 = create_avm(echo_call_service(), vm_1_peer_id);
let some_string = "some_string";
let script = f!(r#"
let script = format!(
r#"
(seq
(ap "{some_string}" $stream)
(seq
(canon "{vm_1_peer_id}" $stream #canon_stream)
(call "{vm_1_peer_id}" ("" "") [#canon_stream])))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), script, "", "");
@ -99,13 +103,15 @@ fn ap_with_bool_literal() {
let vm_1_peer_id = "vm_1_peer_id";
let mut vm_1 = create_avm(echo_call_service(), vm_1_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(ap true $stream)
(seq
(canon "{vm_1_peer_id}" $stream #canon_stream)
(call "{vm_1_peer_id}" ("" "") [#canon_stream])))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), script, "", "");
@ -134,13 +140,15 @@ fn ap_with_number_literal() {
let vm_1_peer_id = "vm_1_peer_id";
let mut vm_1 = create_avm(echo_call_service(), vm_1_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(ap 100 $stream)
(seq
(canon "{vm_1_peer_id}" $stream #canon_stream)
(call "{vm_1_peer_id}" ("" "") [#canon_stream])))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), script, "", "");
@ -169,13 +177,15 @@ fn ap_with_last_error() {
let vm_1_peer_id = "vm_1_peer_id";
let mut vm_1 = create_avm(echo_call_service(), vm_1_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(ap %last_error% $stream)
(seq
(canon "{vm_1_peer_id}" $stream #canon_stream)
(call "{vm_1_peer_id}" ("" "") [#canon_stream])))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), script, "", "");
@ -204,12 +214,14 @@ fn ap_with_timestamp() {
let vm_1_peer_id = "vm_1_peer_id";
let mut vm_1 = create_avm(echo_call_service(), vm_1_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(ap %timestamp% scalar)
(call "{vm_1_peer_id}" ("" "") [scalar])
)
"#);
"#
);
let test_params = TestRunParameters::from_timestamp(1337);
let result = checked_call_vm!(vm_1, test_params.clone(), script, "", "");
@ -229,12 +241,14 @@ fn ap_with_ttl() {
let vm_1_peer_id = "vm_1_peer_id";
let mut vm_1 = create_avm(echo_call_service(), vm_1_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(ap %ttl% scalar)
(call "{vm_1_peer_id}" ("" "") [scalar])
)
"#);
"#
);
let test_params = TestRunParameters::from_ttl(1337);
let result = checked_call_vm!(vm_1, test_params.clone(), script, "", "");
@ -254,7 +268,8 @@ fn ap_with_dst_stream() {
let vm_2_peer_id = "vm_2_peer_id";
let mut vm_2 = create_avm(echo_call_service(), vm_2_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_1_peer_id}" ("" "") ["scalar_1_result"] scalar_1)
@ -262,7 +277,8 @@ fn ap_with_dst_stream() {
(seq
(canon "{vm_2_peer_id}" $stream #canon_stream)
(call "{vm_2_peer_id}" ("" "") [#canon_stream])))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm_2, <_>::default(), script, "", result.data);
@ -305,7 +321,8 @@ fn ap_canon_stream_with_lambda() {
let service_name = "some_service_name";
let function_name = "some_function_name";
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_1_peer_id}" ("" "") [0] $stream)
@ -317,7 +334,8 @@ fn ap_canon_stream_with_lambda() {
(seq
(canon "{vm_1_peer_id}" $stream_2 #canon_stream_2)
(call "{vm_1_peer_id}" ("" "") [#canon_stream_2])))))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
@ -398,7 +416,8 @@ fn ap_canon_stream() {
let service_name = "some_service_name";
let function_name = "some_function_name";
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_1_peer_id}" ("" "") [0] $stream)
@ -410,7 +429,8 @@ fn ap_canon_stream() {
(seq
(canon "{vm_1_peer_id}" $stream_2 #canon_stream_2)
(call "{vm_1_peer_id}" ("" "") [#canon_stream_2])))))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
print_trace(&result, "");
@ -474,7 +494,8 @@ fn ap_stream_map() {
let service_name1 = "serv1";
let service_name2 = "serv2";
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(ap ("{vm_1_peer_id}" "{service_name1}") %map)
@ -487,7 +508,8 @@ fn ap_stream_map() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);

View File

@ -26,9 +26,11 @@ fn current_peer_id_call() {
let service_id = "local_service_id";
let function_name = "local_fn_name";
let script = f!(r#"
let script = format!(
r#"
(call %init_peer_id% ("{service_id}" "{function_name}") [] result_name)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id(vm_peer_id);
let result = checked_call_vm!(vm, test_params, script, "", "");
@ -44,9 +46,11 @@ fn current_peer_id_call() {
assert_eq!(actual_trace, expected_trace);
assert!(result.next_peer_pks.is_empty());
let script = f!(r#"
let script = format!(
r#"
(call "{vm_peer_id}" ("{service_id}" "{function_name}") [] result_name)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), script.clone(), "", "");
@ -80,7 +84,7 @@ fn call_with_ttl() {
let vm_peer_id = "test_peer_id";
let mut vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"(call "{vm_peer_id}" ("" "") [%ttl%] result_name)"#);
let script = format!(r#"(call "{vm_peer_id}" ("" "") [%ttl%] result_name)"#);
let test_params = TestRunParameters::from_ttl(1337);
let result = checked_call_vm!(vm, test_params.clone(), script, "", "");
@ -98,7 +102,7 @@ fn remote_peer_id_call() {
let mut vm = create_avm(echo_call_service(), &some_local_peer_id);
let remote_peer_id = String::from("some_remote_peer_id");
let script = f!(r#"(call "{remote_peer_id}" ("local_service_id" "local_fn_name") ["arg"] result_name)"#);
let script = format!(r#"(call "{remote_peer_id}" ("local_service_id" "local_fn_name") ["arg"] result_name)"#);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
@ -136,12 +140,14 @@ fn duplicate_variables() {
let mut vm = create_avm(unit_call_service(), peer_id);
let variable_name = "modules";
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{peer_id}" ("some_service_id" "local_fn_name") [] {variable_name})
(call "{peer_id}" ("some_service_id" "local_fn_name") [] {variable_name})
)
"#);
"#
);
let result = call_vm!(vm, <_>::default(), script, "", "");
@ -164,12 +170,14 @@ fn string_parameters() {
let service_id = "some_service_id";
let function_name = "local_fn_name";
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_vm_peer_id}" ("{service_id}" "{function_name}") [] arg3)
(call "{vm_peer_id}" ("{service_id}" "{function_name}") ["arg1" "arg2" arg3] result)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);

View File

@ -16,8 +16,6 @@
use air::ExecutionCidState;
use air_test_utils::prelude::*;
use fstrings::f;
use fstrings::format_args_f;
use pretty_assertions::assert_eq;
use std::ops::Deref;
@ -28,11 +26,13 @@ fn canon_moves_execution_flow() {
let peer_id_1 = "peer_id_1";
let peer_id_2 = "peer_id_2";
let script = f!(r#"
let script = format!(
r#"
(par
(call "{peer_id_1}" ("" "") [] $stream)
(canon "{peer_id_2}" $stream #canon_stream)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
@ -105,7 +105,8 @@ fn canon_fixes_stream_correct() {
let peer_id_4 = "peer_id_4";
let mut vm_4 = create_avm(echo_call_service(), peer_id_4);
let script = f!(r#"
let script = format!(
r#"
(seq
(par
(call "{peer_id_1}" ("" "") [1] $stream)
@ -119,7 +120,8 @@ fn canon_fixes_stream_correct() {
(par
(call "{peer_id_3}" ("" "") [#canon_stream])
(call "{peer_id_1}" ("" "") [#canon_stream])))))
"#);
"#
);
let vm_1_result_1 = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let vm_2_result = checked_call_vm!(vm_2, <_>::default(), &script, "", "");
@ -193,7 +195,8 @@ fn canon_stream_can_be_created_from_aps() {
let vm_2_peer_id = "vm_2_peer_id";
let mut vm_2 = create_avm(echo_call_service(), vm_2_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(ap 0 $stream)
@ -205,7 +208,8 @@ fn canon_stream_can_be_created_from_aps() {
(seq
(canon "{vm_2_peer_id}" $stream_2 #canon_stream_2)
(call "{vm_2_peer_id}" ("" "") [#canon_stream_2])))))
"#);
"#
);
let result_1 = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let result_2 = checked_call_vm!(vm_2, <_>::default(), &script, "", result_1.data.clone());
@ -233,7 +237,8 @@ fn canon_gates() {
});
let mut vm_3 = create_avm(vm_3_call_service, peer_id_3);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{peer_id_1}" ("" "") [] iterable)
@ -253,7 +258,8 @@ fn canon_gates() {
(match x true
(call "{peer_id_3}" ("" "") [#t]))))
(next s)))))
"#);
"#
);
let vm_1_result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let vm_2_result = checked_call_vm!(vm_2, <_>::default(), &script, "", vm_1_result.data);
@ -276,12 +282,14 @@ fn canon_empty_stream() {
let peer_id_2 = "peer_id_2";
let mut vm_2 = create_avm(echo_call_service(), peer_id_2);
let script = f!(r#"
let script = format!(
r#"
(new $stream
(seq
(canon "{peer_id_1}" $stream #canon_stream)
(call "{peer_id_1}" ("" "") [#canon_stream])))
"#);
"#
);
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -309,12 +317,14 @@ fn canon_empty_not_writable_stream() {
let peer_id = "peer_id";
let mut vm = create_avm(echo_call_service(), peer_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "unwkown_peer_id" ("" "") [] $stream)
(canon "{peer_id}" $stream #canon_stream)
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -339,7 +349,8 @@ fn canon_over_later_defined_stream() {
let vm_peer_id_3 = "vm_peer_id_3";
let mut peer_vm_3 = create_avm(echo_call_service(), vm_peer_id_3);
let script = f!(r#"
let script = format!(
r#"
(par
(call "{vm_peer_id_2}" ("" "") [1] $stream)
(seq
@ -347,7 +358,8 @@ fn canon_over_later_defined_stream() {
(call "{vm_peer_id_3}" ("" "") [#canon_stream])
)
)
"#);
"#
);
let result = checked_call_vm!(peer_vm_1, <_>::default(), &script, "", "");
let result = checked_call_vm!(peer_vm_2, <_>::default(), &script, "", result.data);
@ -370,7 +382,8 @@ fn canon_map_scalar() {
let vm_peer_id_1 = "vm_peer_id_1";
let mut peer_vm_1 = create_avm(echo_call_service(), vm_peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -393,7 +406,8 @@ fn canon_map_scalar() {
(call "{vm_peer_id_1}" ("m1" "f1") [scalar] output)
)
)
"#);
"#
);
let result = checked_call_vm!(peer_vm_1, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -459,7 +473,8 @@ fn canon_map_scalar_with_par() {
let mut peer_vm_1 = create_avm(echo_call_service(), vm_peer_id_1);
let mut peer_vm_2 = create_avm(echo_call_service(), vm_peer_id_2);
let script = f!(r#"
let script = format!(
r#"
(par
(seq
(seq
@ -482,7 +497,8 @@ fn canon_map_scalar_with_par() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(peer_vm_1, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);

View File

@ -23,11 +23,13 @@ fn fail_with_last_error() {
let fallible_service_id = "service_id_1";
let mut vm = create_avm(fallible_call_service(fallible_service_id), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(call "{local_peer_id}" ("service_id_1" "local_fn_name") [] result_1)
(fail %last_error%)
)"#);
)"#
);
let result = call_vm!(vm, <_>::default(), script, "", "");
@ -75,7 +77,8 @@ fn fail_with_last_error_tetraplets() {
let mut vm = create_avm(host_closure, local_peer_id);
let local_fn_name = "local_fn_name";
let script = f!(r#"
let script = format!(
r#"
(xor
(xor
(call "{local_peer_id}" ("{fallible_service_id}" "{local_fn_name}") [] result_1)
@ -83,7 +86,8 @@ fn fail_with_last_error_tetraplets() {
)
(call "{local_peer_id}" ("" "") [%last_error%])
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id(local_peer_id);
let _ = checked_call_vm!(vm, test_params, script, "", "");
@ -99,14 +103,16 @@ fn fail_with_literals_tetraplets() {
let (host_closure, tetraplet_anchor) = tetraplet_host_function(echo_call_service());
let mut vm = create_avm(host_closure, local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(xor
(fail 1337 "error message")
(fail %last_error%)
)
(call "{local_peer_id}" ("" "") [%last_error%])
)"#);
)"#
);
let test_params = TestRunParameters::from_init_peer_id(local_peer_id);
let _ = checked_call_vm!(vm, test_params, script, "", "");
@ -126,14 +132,16 @@ fn fail_with_canon_stream() {
vm_peer_id,
);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_peer_id}" ("" "") [] $stream)
(canon "{vm_peer_id}" $stream #canon_stream)
)
(fail #canon_stream.$.[0])
)"#);
)"#
);
let test_params = TestRunParameters::from_init_peer_id("init_peer_id");
let result = call_vm!(vm, test_params, script, "", "");

View File

@ -438,14 +438,16 @@ fn fold_waits_on_empty_stream() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "" ("" "") [] $stream)
(fold $stream iterator
(seq
(call "{vm_peer_id}" ("" "") [iterator] $new_stream)
(next iterator))))
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -459,7 +461,8 @@ fn fold_stream_seq_next_never_completes() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(set_variable_call_service(json!(1)), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [] $stream)
(seq
@ -468,7 +471,8 @@ fn fold_stream_seq_next_never_completes() {
(call "{vm_peer_id}" ("" "") [iterator] $new_stream)
(next iterator)))
(call "{vm_peer_id}" ("" "") [])))
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -490,7 +494,8 @@ fn fold_stream_seq_next_never_completes_with_never() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(set_variable_call_service(json!(1)), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [] $stream)
(seq
@ -504,7 +509,8 @@ fn fold_stream_seq_next_never_completes_with_never() {
(call "{vm_peer_id}" ("" "") [])
)
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -526,7 +532,8 @@ fn fold_stream_seq_next_completes_with_null() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(set_variable_call_service(json!(1)), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [] $stream)
(seq
@ -540,7 +547,8 @@ fn fold_stream_seq_next_completes_with_null() {
(call "{vm_peer_id}" ("" "") [])
)
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -564,7 +572,8 @@ fn fold_scalar_seq_next_completes_with_null() {
let service_result = json!([1, 2]);
let mut vm = create_avm(set_variable_call_service(service_result.clone()), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [] iterable)
(seq
@ -581,7 +590,8 @@ fn fold_scalar_seq_next_completes_with_null() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -606,7 +616,8 @@ fn fold_scalar_seq_next_not_completes_with_never() {
let service_result = json!([1, 2]);
let mut vm = create_avm(set_variable_call_service(service_result.clone()), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [] iterable)
(seq
@ -623,7 +634,8 @@ fn fold_scalar_seq_next_not_completes_with_never() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -643,7 +655,8 @@ fn fold_stream_seq_next_saves_call_result() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(ap 1 $stream)
@ -660,7 +673,8 @@ fn fold_stream_seq_next_saves_call_result() {
(call "{vm_peer_id}" ("" "") [0])
)
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -694,7 +708,8 @@ fn fold_par_next_completes() {
let vm_4_peer_id = "vm_4_peer_id";
let mut vm_4 = create_avm(set_variable_call_service(json!(1)), vm_4_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -709,7 +724,8 @@ fn fold_par_next_completes() {
(call "{vm_1_peer_id}" ("" "") []) ; this call should be executed if any of these three peers is reached
)
)
"#);
"#
);
let result_1 = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
@ -792,7 +808,8 @@ fn fold_stream_map() {
let mut vm_1 = create_avm(set_variable_call_service, vm_1_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -817,7 +834,8 @@ fn fold_stream_map() {
)
)
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id(vm_1_peer_id);
let result = checked_call_vm!(vm_1, test_params, &script, "", "");

View File

@ -25,7 +25,8 @@ fn match_equal() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["value_1"] value_1)
@ -37,7 +38,8 @@ fn match_equal() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
@ -63,7 +65,8 @@ fn match_not_equal() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["value_1"] value_1)
@ -75,7 +78,8 @@ fn match_not_equal() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
@ -101,7 +105,8 @@ fn match_with_string() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") ["value_1"] value_1)
(xor
@ -110,7 +115,8 @@ fn match_with_string() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
@ -136,7 +142,8 @@ fn match_with_init_peer_id() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") ["{local_peer_id}"] value_1)
(xor
@ -145,7 +152,8 @@ fn match_with_init_peer_id() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let test_params = TestRunParameters::from_init_peer_id(local_peer_id);
let result = checked_call_vm!(set_variable_vm, test_params.clone(), &script, "", "");
@ -173,7 +181,8 @@ fn match_with_timestamp() {
let mut vm = create_avm(echo_call_service(), local_peer_id);
let timestamp = 1337;
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") [{timestamp}] value_1)
(xor
@ -182,7 +191,8 @@ fn match_with_timestamp() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let test_params = TestRunParameters::from_timestamp(timestamp);
let result = checked_call_vm!(set_variable_vm, test_params.clone(), &script, "", "");
@ -210,7 +220,8 @@ fn match_with_ttl() {
let mut vm = create_avm(echo_call_service(), local_peer_id);
let ttl = 1337;
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") [{ttl}] value_1)
(xor
@ -219,7 +230,8 @@ fn match_with_ttl() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let test_params = TestRunParameters::from_ttl(ttl);
let result = checked_call_vm!(set_variable_vm, test_params.clone(), &script, "", "");
@ -264,7 +276,8 @@ fn match_without_xor() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["value_1"] value_1)
@ -273,7 +286,8 @@ fn match_without_xor() {
(match value_1 value_2
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1)
)
)"#);
)"#
);
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = call_vm!(vm, <_>::default(), &script, "", result.data);
@ -294,7 +308,8 @@ fn match_with_two_xors() {
let local_peer_id_2 = "local_peer_id_2";
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(seq
@ -310,7 +325,8 @@ fn match_with_two_xors() {
)
(call "{local_peer_id}" ("errorHandlingSrv" "error") [%last_error%])
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
@ -332,7 +348,8 @@ fn issue_165() {
let echo_peer_id = "echo_peer_id";
let mut echo_peer = create_avm(echo_call_service(), echo_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{result_setter_peer_id}" ("" "") ["set_result"] result)
(seq
@ -348,7 +365,8 @@ fn issue_165() {
)
)
)
"#);
"#
);
let setter_result = checked_call_vm!(result_setter, <_>::default(), &script, "", "");
let echo_result = checked_call_vm!(echo_peer, <_>::default(), &script, "", setter_result.data);

View File

@ -25,7 +25,8 @@ fn mismatch_equal() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["value_1"] value_1)
@ -37,7 +38,8 @@ fn mismatch_equal() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
@ -63,7 +65,8 @@ fn mismatch_not_equal() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["value_1"] value_1)
@ -75,7 +78,8 @@ fn mismatch_not_equal() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
@ -101,7 +105,8 @@ fn mismatch_with_string() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") ["value_1"] value_1)
(xor
@ -110,7 +115,8 @@ fn mismatch_with_string() {
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
@ -136,7 +142,8 @@ fn mismatch_without_xor() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["value_1"] value_1)
@ -145,7 +152,8 @@ fn mismatch_without_xor() {
(mismatch value_1 value_2
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1)
)
)"#);
)"#
);
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = call_vm!(vm, <_>::default(), &script, "", result.data);
@ -166,7 +174,8 @@ fn mismatch_with_two_xors() {
let local_peer_id_2 = "local_peer_id_2";
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(seq
@ -182,7 +191,8 @@ fn mismatch_with_two_xors() {
)
(call "{local_peer_id}" ("errorHandlingSrv" "error") [%last_error%])
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");

View File

@ -21,12 +21,14 @@ fn never_not_complete_subgraph() {
let vm_peer_id = "test_peer_id";
let mut vm = create_avm(unit_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(never)
(call "{vm_peer_id}" ("" "") [])
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
let actual_trace = trace_from_result(&result);

View File

@ -39,7 +39,8 @@ fn new_with_global_streams_seq() {
set_variable_peer_id,
);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["1"] $stream)
@ -59,7 +60,8 @@ fn new_with_global_streams_seq() {
(call "{local_vm_peer_id_2}" ("" "") [$stream])
)
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let vm_1_result = checked_call_vm!(local_vm_1, <_>::default(), &script, "", result.data);
@ -106,7 +108,8 @@ fn several_restrictions() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(new $stream
(seq
(new $stream
@ -117,7 +120,8 @@ fn several_restrictions() {
(call "{vm_peer_id}" ("" "") [#canon_stream])
)
)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
@ -140,7 +144,8 @@ fn check_influence_to_not_restricted() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(new $a
(seq
@ -177,7 +182,8 @@ fn check_influence_to_not_restricted() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
@ -272,7 +278,8 @@ fn new_in_fold_with_ap() {
let mut set_variable_vm = create_avm(set_variable_call_service(json!([1, 2, 3, 4, 5])), set_variable_peer_id);
let mut vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variable_peer_id}" ("" "") [] iterable)
(fold iterable x
@ -290,7 +297,8 @@ fn new_in_fold_with_ap() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
@ -379,7 +387,8 @@ fn new_with_streams_with_errors() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{local_peer_id}" ("" "") [1] $global_stream) ;; this stream should precense in a data
(new $restricted_stream_1
@ -393,7 +402,8 @@ fn new_with_streams_with_errors() {
(call "{local_peer_id}" ("" "") [2] restricted_stream_1) ;; should have generation 0 in a data
)
)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let result = call_vm!(fallible_vm, <_>::default(), script, "", result.data);
@ -451,7 +461,8 @@ fn new_with_scalars_with_errors() {
let fallible_service_id = "fallible_service_id";
let mut fallible_peer_vm = create_avm(fallible_call_service(fallible_service_id), fallible_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["global"] scalar)
@ -469,7 +480,8 @@ fn new_with_scalars_with_errors() {
)
)
(call "{variable_receiver_peer_id}" ("" "") [scalar])
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(variable_receiver_vm, <_>::default(), &script, "", result.data);
@ -504,7 +516,8 @@ fn new_with_global_scalars() {
let variable_receiver_peer_id = "variable_receiver_peer_id";
let mut variable_receiver = create_avm(echo_call_service(), variable_receiver_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["global"] scalar)
@ -516,7 +529,8 @@ fn new_with_global_scalars() {
)
)
(call "{variable_receiver_peer_id}" ("" "") [scalar])
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(variable_receiver, <_>::default(), &script, "", result.data);
@ -574,7 +588,8 @@ fn new_with_scalars_in_lfold_with_outside_next() {
let test_call_service = prepare_new_test_call_service();
let mut test_vm = create_avm(test_call_service, test_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{test_peer_id}" ("" "") ["{GET_ITERABLE_ACTION_NAME}"] iterable)
(fold iterable iterator
@ -598,7 +613,8 @@ fn new_with_scalars_in_lfold_with_outside_next() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(test_vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -631,7 +647,8 @@ fn new_with_scalars_in_rfold_with_outside_next() {
let test_call_service = prepare_new_test_call_service();
let mut test_vm = create_avm(test_call_service, test_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{test_peer_id}" ("" "") ["{GET_ITERABLE_ACTION_NAME}"] iterable)
(fold iterable iterator
@ -655,7 +672,8 @@ fn new_with_scalars_in_rfold_with_outside_next() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(test_vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -688,7 +706,8 @@ fn new_with_scalars_in_fold_with_inside_next() {
let test_call_service = prepare_new_test_call_service();
let mut test_vm = create_avm(test_call_service, test_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{test_peer_id}" ("" "") ["{GET_ITERABLE_ACTION_NAME}"] iterable)
(fold iterable iterator
@ -715,7 +734,8 @@ fn new_with_scalars_in_fold_with_inside_next() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(test_vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);

View File

@ -42,11 +42,13 @@ fn par_local_remote() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(unit_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_name)
(call "remote_peer_id_2" ("service_id" "fn_name") [] g)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");

View File

@ -51,11 +51,13 @@ fn seq_local_remote() {
let remote_peer_id = String::from("remote_peer_id");
let mut vm = create_avm(unit_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_name)
(call "{remote_peer_id}" ("service_id" "fn_name") [] g)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
assert_eq!(result.next_peer_pks, vec![remote_peer_id]);

View File

@ -23,11 +23,13 @@ fn xor() {
let fallible_service_id = "service_id_1";
let mut vm = create_avm(fallible_call_service(fallible_service_id), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(call "{local_peer_id}" ("service_id_1" "local_fn_name") [] result_1)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") [] result_2)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
@ -52,11 +54,13 @@ fn xor() {
);
assert_eq!(actual_trace[1.into()], expected_call_result);
let script = f!(r#"
let script = format!(
r#"
(xor
(call "{local_peer_id}" ("service_id_2" "local_fn_name") [] result_1)
(call "{local_peer_id}" ("service_id_1" "local_fn_name") [] result_2)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
@ -70,14 +74,16 @@ fn xor_var_not_found() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(par
(call "unknown_peer" ("service_id_1" "local_fn_name") [] lazy_defined_variable)
(call "{local_peer_id}" ("service_id_1" "local_fn_name") [lazy_defined_variable] result)
)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["expected"] result)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
@ -95,14 +101,16 @@ fn xor_multiple_variables_found() {
let some_string = "some_string";
let expected_string = "expected_string";
let variable_name = "result_1";
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_variables_peer_id}" ("service_id_1" "local_fn_name") ["{some_string}"] {variable_name})
(xor
(call "{local_peer_id}" ("service_id_1" "local_fn_name") [""] {variable_name})
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["{expected_string}"] result_2)
)
)"#);
)"#
);
let result = call_vm!(set_variables_vm, <_>::default(), &script, "", "");
@ -118,7 +126,8 @@ fn xor_par() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(fallible_call_service(fallible_service_id), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(par
(par
@ -134,7 +143,8 @@ fn xor_par() {
(call "{local_peer_id}" ("service_id_2" "local_fn_name") [] result_4)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") [] result_5)
)
)"#);
)"#
);
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
let actual_trace = trace_from_result(&result);
@ -202,11 +212,13 @@ fn last_error_with_xor() {
let local_peer_id = "local_peer_id";
let mut vm = create_avm(echo_call_service(), local_peer_id);
let script = f!(r#"
let script = format!(
r#"
(xor
(call "{faillible_peer_id}" ("service_id_1" "local_fn_name") [] result)
(call "{local_peer_id}" ("service_id_2" "local_fn_name") [%last_error%.$.message] result)
)"#);
)"#
);
let result = checked_call_vm!(faillible_vm, <_>::default(), script.clone(), "", "");
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);

View File

@ -41,7 +41,8 @@ fn join_chat_1() {
Box::new(move |_| -> CallServiceResult { CallServiceResult::ok(members.clone()) });
let mut remote = create_avm(members_call_service, remote_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{relay_1_peer_id}" ("identity" "") [] $void1)
(seq
@ -60,7 +61,8 @@ fn join_chat_1() {
)
)
)
"#);
"#
);
let client_1_result = checked_call_vm!(client_1, <_>::default(), &script, "", "");
@ -307,7 +309,8 @@ fn join_chat_2() {
let client_peer_id = "client_peer_id";
let mut client_1 = create_avm(unit_call_service(), client_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{relay_1_peer_id}" ("identity" "") [] $void1)
(seq
@ -323,7 +326,8 @@ fn join_chat_2() {
)
)
)
"#);
"#
);
let client_1_result = checked_call_vm!(client_1, <_>::default(), &script, "", "");
let relay_1_result = checked_call_vm!(relay_1, <_>::default(), &script, client_1_result.data, "");
@ -399,7 +403,8 @@ fn init_peer_id() {
Box::new(move |_| -> CallServiceResult { CallServiceResult::ok(members.clone()) });
let mut remote = create_avm(members_call_service, remote_peer_id);
let script = f!(r#"(seq
let script = format!(
r#"(seq
(seq
(call "{relay_1_peer_id}" ("identity" "") [])
(seq
@ -417,7 +422,8 @@ fn init_peer_id() {
)
(call %init_peer_id% ("identity" "") [])
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id(initiator_peer_id);
let initiator_1_result = checked_call_vm!(initiator, test_params.clone(), &script, "", "");

View File

@ -124,10 +124,10 @@ fn peer_host_function(
#[rustfmt::skip]
fn create_peer_host_function(peer_id: String, known_peer_ids: Vec<String>) -> CallServiceClosure {
let relay_blueprints = (0..=2).map(|id| f!("{peer_id}_blueprint_{id}")).collect::<Vec<_>>();
let relay_modules = (0..=2).map(|id| f!("{peer_id}_module_{id}")).collect::<Vec<_>>();
let relay_interfaces = (0..=2).map(|id| f!("{peer_id}_interface_{id}")).collect::<Vec<_>>();
let relay_ident = f!("{peer_id}_ident");
let relay_blueprints = (0..=2).map(|id| format!("{peer_id}_blueprint_{id}")).collect::<Vec<_>>();
let relay_modules = (0..=2).map(|id| format!("{peer_id}_module_{id}")).collect::<Vec<_>>();
let relay_interfaces = (0..=2).map(|id| format!("{peer_id}_interface_{id}")).collect::<Vec<_>>();
let relay_ident = format!("{peer_id}_ident");
peer_host_function(
known_peer_ids,

View File

@ -29,7 +29,8 @@ fn issue_137() {
let node_4_id = "node_4_id";
let mut node_4 = create_avm(unit_call_service(), node_4_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{initiator_id}" ("" "") []) ;; initiator
(par
@ -52,7 +53,8 @@ fn issue_137() {
)
)
)
"#);
"#
);
let initiator_result = checked_call_vm!(initiator, <_>::default(), &script, "", "");
let node_1_result = checked_call_vm!(node_1, <_>::default(), &script, "", initiator_result.data.clone());

View File

@ -37,7 +37,8 @@ fn issue_173() {
set_variable_peer_id,
);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{set_variable_peer_id}" ("" "") ["1"] $stream)
@ -57,7 +58,8 @@ fn issue_173() {
(call "{local_vm_peer_id_2}" ("" "") [$stream])
)
)
)"#);
)"#
);
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
let vm_1_result = checked_call_vm!(local_vm_1, <_>::default(), &script, "", result.data);

View File

@ -24,7 +24,8 @@ fn par_ap_behaviour() {
let variable_setter_id = "variable_setter_id";
// ap doesn't affect the subgraph_complete flag
let script = f!(r#"
let script = format!(
r#"
(par
(call "{variable_setter_id}" ("peer" "timeout") [] join_it) ; behaviour=unit
(seq
@ -38,7 +39,8 @@ fn par_ap_behaviour() {
)
)
)
"#);
"#
);
let engine =
air_test_framework::AirScriptExecutor::from_annotated(TestRunParameters::new("client_id", 0, 1, ""), &script)

View File

@ -23,7 +23,8 @@ fn issue_180() {
let peer_2_id = "peer_2_id";
let mut peer_1 = create_avm(unit_call_service(), peer_1_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "{peer_2_id}" ("" "") [] join_var)
(seq
@ -36,7 +37,8 @@ fn issue_180() {
(call "{peer_1_id}" ("" "") []) ;; this should be called only when join_var is set
)
)
"#);
"#
);
let peer_1_result = checked_call_vm!(peer_1, <_>::default(), &script, "", "");
let trace = trace_from_result(&peer_1_result);

View File

@ -23,7 +23,8 @@ fn issue_206() {
let peer_1_id = "peer_1_id";
let mut peer_1 = create_avm(echo_call_service(), peer_1_id);
let script = f!(r#"
let script = format!(
r#"
(new $result
(seq
(xor
@ -38,7 +39,8 @@ fn issue_206() {
(call %init_peer_id% ("op" "identity") [$result] result-fix)
)
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id(peer_1_id);
let result = checked_call_vm!(peer_1, test_params, &script, "", "");

View File

@ -25,7 +25,8 @@ use pretty_assertions::assert_eq;
fn issue_211() {
let peer_1_id = "peer_1_id";
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(seq
@ -64,7 +65,8 @@ fn issue_211() {
)
(call %init_peer_id% ("errorhandlingsrv" "error") [%last_error% 2]) ; ok="error"
)
"#);
"#
);
let run_params = TestRunParameters::from_init_peer_id(peer_1_id);

View File

@ -37,7 +37,8 @@ fn issue_214() {
client_id,
);
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(seq
@ -57,7 +58,8 @@ fn issue_214() {
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id(client_id);
let result = checked_call_vm!(client, test_params, &script, "", "");

View File

@ -33,7 +33,8 @@ fn issue_216() {
let mut client = create_avm(echo_call_service(), client_id);
let error_message = "error message";
let script = f!(r#"
let script = format!(
r#"
(xor
(seq
(call "{some_peer_id}" ("" "value") [] value)
@ -41,7 +42,8 @@ fn issue_216() {
)
(call %init_peer_id% ("" "") ["{error_message}"]) ;; (2)
)
"#);
"#
);
let test_params = TestRunParameters::from_init_peer_id(client_id);
let result = checked_call_vm!(some_peer, test_params.clone(), &script, "", "");

View File

@ -31,7 +31,8 @@ fn issue_221() {
let peer_1_value = "peer_1_value";
let peer_2_value = "peer_2_value";
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(seq
@ -66,7 +67,8 @@ fn issue_221() {
)
(call "some_peer_id" ("" "") []) ;; (1)
)
"#);
"#
);
let executor = <AirScriptExecutor>::new(
TestRunParameters::from_init_peer_id("set_variable_id"),

View File

@ -24,7 +24,8 @@ fn issue_222() {
let other_1_id = "other_1";
let other_2_id = "other_2";
let air_script = f!(r#"
let air_script = format!(
r#"
(new $stream
(par
(par
@ -34,7 +35,8 @@ fn issue_222() {
(seq
(call "{other_id}" ("" "") [j])
(next j)))))
"#);
"#
);
let mut other_id_vm = create_avm(echo_call_service(), "other_id");
let mut other_1_vm = create_avm(set_variable_call_service(json!([1])), "other_1");

View File

@ -34,7 +34,8 @@ fn issue_241() {
let peers = json!([peer_1_id, peer_2_id]);
let mut set_array_0_vm = create_avm(set_variable_call_service(peers.clone()), set_array_0_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{set_array_0_peer_id}" ("" "") [] array-0)
(fold array-0 array-0-iterator
@ -52,7 +53,8 @@ fn issue_241() {
)
)
)
"#);
"#
);
let result = checked_call_vm!(set_array_0_vm, <_>::default(), &script, "", "");
let result = checked_call_vm!(peer_1_vm, <_>::default(), &script, "", result.data);

View File

@ -25,12 +25,14 @@ fn issue_295() {
let vm_peer_id = "vm_peer_id";
let mut vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id}" ("" "") [] scalar)
(ap scalar $stream)
)
"#);
"#
);
let mut cid_state = ExecutionCidState::new();

View File

@ -24,14 +24,16 @@ fn issue_300() {
let peer_id_2 = "peer_id_2";
let mut peer_vm_2 = create_avm(echo_call_service(), peer_id_2);
let script = f!(r#"
let script = format!(
r#"
(new $stream
(par
(call "{peer_id_1}" ("" "") [2] $stream)
(call "{peer_id_2}" ("" "") [1] $stream)
)
)
"#);
"#
);
let result_1 = checked_call_vm!(peer_vm_2, <_>::default(), &script, "", "");
let result_2 = checked_call_vm!(peer_vm_1, <_>::default(), &script, "", result_1.data);

View File

@ -30,7 +30,8 @@ fn issue_302() {
let peer_id_3 = "peer_id_3";
let mut peer_vm_3 = create_avm(echo_call_service(), peer_id_3);
let script = f!(r#"
let script = format!(
r#"
(new $stream
(par
(call "{peer_id_1}" ("" "") [2] $stream)
@ -46,7 +47,8 @@ fn issue_302() {
)
)
)
"#);
"#
);
let result_1 = checked_call_vm!(peer_vm_2, <_>::default(), &script, "", "");
let result_2 = checked_call_vm!(peer_vm_1, <_>::default(), &script, "", result_1.data.clone());

View File

@ -23,13 +23,15 @@ fn issue_306() {
let peer_id_1 = "peer_id_1";
let mut peer_vm_1 = create_avm(echo_call_service(), peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(new $stream
(seq
(canon "{peer_id_1}" $stream #canon_stream)
(fold #canon_stream iterator
(ap iterator $stream))))
"#);
"#
);
let result = call_vm!(peer_vm_1, <_>::default(), &script, "", "");
assert_eq!(result.ret_code, INTERPRETER_SUCCESS)

View File

@ -23,7 +23,8 @@ fn issue_331() {
let peer_id_1 = "peer_id_1";
let mut peer_vm_1 = create_avm(set_variable_call_service(json!("")), peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(new $array-inline
(seq
(seq
@ -47,7 +48,8 @@ fn issue_331() {
(canon %init_peer_id% $array-inline #array-inline-0)
)
)
"#);
"#
);
let parameters = TestRunParameters::new(peer_id_1, 1, 1, "");
let result = call_vm!(peer_vm_1, parameters, &script, "", "");

View File

@ -23,7 +23,8 @@ fn issue_346() {
let vm_peer_id = "peer_id_1";
let mut peer_vm = create_avm(echo_call_service(), vm_peer_id);
let script = f!(r#"
let script = format!(
r#"
(par
(call "unknown_peer" ("" "") [] $stream) ; to make validator happy
(xor
@ -31,7 +32,8 @@ fn issue_346() {
(call "{vm_peer_id}" ("" "") [""])
)
)
"#);
"#
);
let result = call_vm!(peer_vm, <_>::default(), &script, "", "");
assert_eq!(result.ret_code, INTERPRETER_SUCCESS);

View File

@ -26,7 +26,8 @@ fn issue_348() {
let vm_peer_id_3 = "vm_peer_id_3";
let mut peer_vm_3 = create_avm(echo_call_service(), vm_peer_id_3);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(ap 1 $inner)
@ -43,7 +44,8 @@ fn issue_348() {
)
)
)
"#);
"#
);
let result11 = checked_call_vm!(peer_vm_1, <_>::default(), &script, "", "");
let result21 = checked_call_vm!(peer_vm_2, <_>::default(), &script, "", result11.data);

View File

@ -23,9 +23,11 @@ use air_test_utils::prelude::*;
#[test]
fn local_service_error() {
let client_peer_id = "some_peer_id";
let script = f!(r#"
let script = format!(
r#"
(call "{client_peer_id}" ("m" "f") ["arg1"] other)
"#);
"#
);
let mut client_vm = create_avm(echo_call_service(), client_peer_id);
let result = client_vm
@ -51,7 +53,7 @@ fn local_service_error() {
)
.unwrap();
let err_msg = std::rc::Rc::new(f!("\"{err_msg}\""));
let err_msg = std::rc::Rc::new(format!("\"{err_msg}\""));
let expected_error = CatchableError::LocalServiceError(10000, err_msg);
assert!(check_error(&result, expected_error));
}
@ -60,7 +62,8 @@ fn local_service_error() {
fn fold_iterates_over_non_array_scalar_iterable() {
let vm_2_peer_id = "vm_2_peer_id";
let var_name = "outcome".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_2_peer_id}" ("m" "f") [] {var_name})
(fold {var_name} i
@ -70,7 +73,8 @@ fn fold_iterates_over_non_array_scalar_iterable() {
)
)
)
"#);
"#
);
let unsupported_jvalue = json!({"attr": 42, });
let mut vm_2 = create_avm(set_variable_call_service(unsupported_jvalue.clone()), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
@ -83,7 +87,8 @@ fn fold_iterates_over_non_array_scalar_lambda_iterable() {
let vm_2_peer_id = "vm_2_peer_id";
let var_name = "outcome".to_string();
let scalar_int = 42;
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_2_peer_id}" ("m" "f") [] {var_name})
(fold {var_name}.$.int i
@ -93,7 +98,8 @@ fn fold_iterates_over_non_array_scalar_lambda_iterable() {
)
)
)
"#);
"#
);
let unsupported_jvalue = json!({"int": scalar_int, });
let mut vm_2 = create_avm(set_variable_call_service(unsupported_jvalue.clone()), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
@ -106,12 +112,14 @@ fn non_string_value_in_triplet_resolution() {
let vm_2_peer_id = "vm_2_peer_id";
let scalar_int = 42;
let var_name = "var_name".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(ap {scalar_int} {var_name})
(call {var_name} ("" "") [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(unit_call_service(), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -120,7 +128,8 @@ fn non_string_value_in_triplet_resolution() {
};
assert!(check_error(&result, expected_error));
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_2_peer_id}" ("m" "f") [] {var_name})
@ -128,7 +137,8 @@ fn non_string_value_in_triplet_resolution() {
)
(call {var_name}.$.int ("" "") [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(set_variable_call_service(json!({"int": scalar_int, })), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -138,7 +148,8 @@ fn non_string_value_in_triplet_resolution() {
assert!(check_error(&result, expected_error));
let var_name = "#canon".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(ap {scalar_int} $stream)
@ -146,7 +157,8 @@ fn non_string_value_in_triplet_resolution() {
)
(call #canon.$.[0] ("" "") [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(echo_call_service(), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -161,12 +173,14 @@ fn non_string_value_in_triplet_resolution_module_name() {
let vm_2_peer_id = "vm_2_peer_id";
let scalar_int = 42;
let var_name = "var_name".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(ap {scalar_int} {var_name})
(call "{vm_2_peer_id}" ({var_name} "") [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(unit_call_service(), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -175,7 +189,8 @@ fn non_string_value_in_triplet_resolution_module_name() {
};
assert!(check_error(&result, expected_error));
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_2_peer_id}" ("m" "f") [] {var_name})
@ -183,7 +198,8 @@ fn non_string_value_in_triplet_resolution_module_name() {
)
(call "{vm_2_peer_id}" ({var_name}.$.int "") [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(set_variable_call_service(json!({"int": scalar_int, })), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -193,7 +209,8 @@ fn non_string_value_in_triplet_resolution_module_name() {
assert!(check_error(&result, expected_error));
let var_name = "#canon".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(ap {scalar_int} $stream)
@ -201,7 +218,8 @@ fn non_string_value_in_triplet_resolution_module_name() {
)
(call "{vm_2_peer_id}" (#canon.$.[0] "") [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(echo_call_service(), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -216,12 +234,14 @@ fn non_string_value_in_triplet_resolution_function_name() {
let vm_2_peer_id = "vm_2_peer_id";
let scalar_int = 42;
let var_name = "var_name".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(ap {scalar_int} {var_name})
(call "{vm_2_peer_id}" ("" {var_name}) [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(unit_call_service(), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -230,7 +250,8 @@ fn non_string_value_in_triplet_resolution_function_name() {
};
assert!(check_error(&result, expected_error));
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "{vm_2_peer_id}" ("m" "f") [] {var_name})
@ -238,7 +259,8 @@ fn non_string_value_in_triplet_resolution_function_name() {
)
(call "{vm_2_peer_id}" ("" {var_name}.$.int) [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(set_variable_call_service(json!({"int": scalar_int, })), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -248,7 +270,8 @@ fn non_string_value_in_triplet_resolution_function_name() {
assert!(check_error(&result, expected_error));
let var_name = "#canon".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(ap {scalar_int} $stream)
@ -256,7 +279,8 @@ fn non_string_value_in_triplet_resolution_function_name() {
)
(call "{vm_2_peer_id}" ("" #canon.$.[0]) [] outcome)
)
"#);
"#
);
let mut vm_2 = create_avm(echo_call_service(), vm_2_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::NonStringValueInTripletResolution {
@ -270,12 +294,14 @@ fn non_string_value_in_triplet_resolution_function_name() {
fn value_not_contain_such_array_idx_ap() {
let vm_1_peer_id = "vm_1_peer_id";
let idx = 42;
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_1_peer_id}" ("m" "f") [] result)
(ap result.$.[{idx}].atrib outcome)
)
"#);
"#
);
let wrong_jvalue = json!(["a", "b"]);
let mut vm_2 = create_avm(set_variable_call_service(wrong_jvalue.clone()), vm_1_peer_id);
let result = vm_2.call(&script, "", "", <_>::default()).unwrap();
@ -294,12 +320,14 @@ fn field_accessor_applied_to_stream() {
let arg = json!({"a": 1,});
let mut peer_vm_1 = create_avm(set_variable_call_service(arg), vm_peer_id_1);
let field_name = "int".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(canon "{vm_peer_id_1}" $stream #canon_stream)
(call "{vm_peer_id_1}" ("m" "f") [#canon_stream.$.{field_name}] output)
)
"#);
"#
);
let result = peer_vm_1.call(script.clone(), "", "", <_>::default()).unwrap();
let expected_error =
@ -314,12 +342,14 @@ fn array_accessor_not_match_value() {
let arg = json!({"a": 1,});
let mut peer_vm_1 = create_avm(set_variable_call_service(arg.clone()), vm_peer_id_1);
let idx = 42;
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id_1}" ("m" "f") [] nonarray)
(call "{vm_peer_id_1}" ("m" "f") [nonarray.$.[{idx}]] result)
)
"#);
"#
);
let result = peer_vm_1.call(script.clone(), "", "", <_>::default()).unwrap();
let expected_error =
@ -333,12 +363,14 @@ fn value_not_contain_such_array_idx_call_arg_lambda() {
let arg = json!([0, 1]);
let mut peer_vm_1 = create_avm(set_variable_call_service(arg.clone()), vm_peer_id_1);
let idx = 42;
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id_1}" ("m" "f") [] array)
(call "{vm_peer_id_1}" ("m" "f") [array.$.[{idx}]] result)
)
"#);
"#
);
let result = peer_vm_1.call(script.clone(), "", "", <_>::default()).unwrap();
let expected_error =
@ -352,12 +384,14 @@ fn value_not_contain_such_field_call_arg_lambda() {
let arg = json!({"a": 1,});
let mut peer_vm_1 = create_avm(set_variable_call_service(arg.clone()), vm_peer_id_1);
let field_name = "b".to_string();
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id_1}" ("m" "f") [] obj)
(call "{vm_peer_id_1}" ("m" "f") [obj.$.{field_name}] output)
)
"#);
"#
);
let result = peer_vm_1.call(script.clone(), "", "", <_>::default()).unwrap();
let expected_error =
@ -371,12 +405,14 @@ fn field_accesssor_not_match_value_call_arg_lambda() {
let arg = json!([0, 1]);
let mut peer_vm_1 = create_avm(set_variable_call_service(arg.clone()), vm_peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id_1}" ("m" "f") [] obj)
(call "{vm_peer_id_1}" ("m" "f") [obj.$.b] output)
)
"#);
"#
);
let result = peer_vm_1.call(script.clone(), "", "", <_>::default()).unwrap();
let expected_error = air::CatchableError::LambdaApplierError(air::LambdaError::FieldAccessorNotMatchValue {
value: arg,
@ -395,7 +431,8 @@ fn index_access_not_u32_i64() {
let arg = json!([0, 1]);
let mut peer_vm_2 = create_avm(set_variable_call_service(arg.clone()), vm_peer_id_2);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id_1}" ("m" "f") [] idx)
(seq
@ -403,7 +440,8 @@ fn index_access_not_u32_i64() {
(call "{vm_peer_id_2}" ("m" "f") [array.$.[idx]] result)
)
)
"#);
"#
);
let result = peer_vm_1.call(script.clone(), "", "", <_>::default()).unwrap();
let result = peer_vm_2.call(script.clone(), "", result.data, <_>::default()).unwrap();
@ -418,7 +456,8 @@ fn scalar_accessor_has_invalid_type_ap() {
let obj_arg = json!({"a": 1,});
let mut peer_vm_1 = create_avm(set_variable_call_service(obj_arg.clone()), vm_peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id_1}" ("m" "f") [] array_obj)
(seq
@ -426,7 +465,8 @@ fn scalar_accessor_has_invalid_type_ap() {
(ap array.$.[array_obj] outcome)
)
)
"#);
"#
);
let result = peer_vm_1.call(script.clone(), "", "", <_>::default()).unwrap();
let expected_error = air::CatchableError::LambdaApplierError(air::LambdaError::ScalarAccessorHasInvalidType {
@ -449,7 +489,8 @@ fn stream_accessor_has_invalid_type() {
let obj_arg = json!({"a": 1,});
let mut peer_vm_1 = create_avm(set_variable_call_service(obj_arg.clone()), vm_peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "{vm_peer_id_1}" ("m" "f") [] array_obj)
(seq
@ -460,7 +501,8 @@ fn stream_accessor_has_invalid_type() {
)
)
)
"#);
"#
);
let result = peer_vm_1.call(script.clone(), "", "", <_>::default()).unwrap();
let expected_error = air::CatchableError::LambdaApplierError(air::LambdaError::StreamAccessorHasInvalidType {
@ -482,7 +524,8 @@ fn canon_stream_not_have_enough_values_call_arg() {
let local_peer_id = "local_peer_id";
let mut local_vm = create_avm(echo_call_service(), local_peer_id);
let join_stream_script = f!(r#"
let join_stream_script = format!(
r#"
(seq
(seq
(call "{local_peer_id}" ("" "") [[]] nodes)
@ -497,7 +540,8 @@ fn canon_stream_not_have_enough_values_call_arg() {
(canon "{local_peer_id}" $ns #ns)
(call "{local_peer_id}" ("" "") [#ns.$.[0] #ns.$.[1] #ns])
)
)"#);
)"#
);
let result = local_vm.call(&join_stream_script, "", "", <_>::default()).unwrap();
let actual_trace = trace_from_result(&result);
@ -512,9 +556,11 @@ fn unsupported_map_keytype_float() {
let mut local_vm = create_avm(unit_call_service(), "local_peer_id");
let map_name = "%map";
let join_stream_script = f!(r#"
let join_stream_script = format!(
r#"
(ap (0.5 "serv1") %map)
"#);
"#
);
let result = local_vm.call(&join_stream_script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::StreamMapError(unsupported_map_key_type(map_name));
@ -528,12 +574,14 @@ fn unsupported_map_keytype() {
let mut local_vm = create_avm(set_variable_call_service(obj_arg), local_peer_id);
let map_name = "%map";
let join_stream_script = f!(r#"
let join_stream_script = format!(
r#"
(seq
(call "{local_peer_id}" ("" "") [] scalar)
(ap (scalar.$.a "serv1") %map)
)
"#);
"#
);
let result = local_vm.call(&join_stream_script, "", "", <_>::default()).unwrap();
let expected_error = CatchableError::StreamMapError(unsupported_map_key_type(map_name));

View File

@ -27,7 +27,8 @@ fn fold_state_not_found() {
let arg = json!([1, 2,]);
let mut peer_vm_1 = create_avm(set_variable_call_service(arg), vm_peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(seq
(seq
(call "vm_peer_id_1" ("" "") [] some)
@ -37,7 +38,8 @@ fn fold_state_not_found() {
)
(next i)
)
"#);
"#
);
let result = peer_vm_1.call(script, "", "", <_>::default()).unwrap();
let expected_error = FoldStateNotFound(String::from("i"));
@ -50,14 +52,16 @@ fn iterable_shadowing() {
let arg = json!([1, 2,]);
let mut peer_vm_1 = create_avm(set_variable_call_service(arg), vm_peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(seq
(call "vm_peer_id_1" ("" "") [] some)
(fold some i
(call "vm_peer_id_1" ("" "") [] i)
)
)
"#);
"#
);
let result = peer_vm_1.call(script, "", "", <_>::default()).unwrap();
let expected_error = IterableShadowing(String::from("i"));
@ -70,9 +74,11 @@ fn call_result_not_correspond_to_instr() {
let arg = json!([1, 2,]);
let mut peer_vm_1 = create_avm(set_variable_call_service(arg.clone()), vm_peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(call "vm_peer_id_1" ("" "") [] $some)
"#);
"#
);
let scalar_value = 42;
let wrong_trace = vec![scalar!(scalar_value)];
@ -89,12 +95,14 @@ fn shadowing_is_not_allowed() {
let vm_peer_id_1 = "vm_peer_id_1";
let mut peer_vm_1 = create_avm(unit_call_service(), vm_peer_id_1);
let var_name = String::from("some");
let script = f!(r#"
let script = format!(
r#"
(seq
(ap 42 {var_name})
(ap 42 {var_name})
)
"#);
"#
);
let result = peer_vm_1.call(script, "", "", <_>::default()).unwrap();
let expected_error = ShadowingIsNotAllowed(var_name);
@ -107,9 +115,11 @@ fn value_for_cid_not_found() {
let arg = json!([1, 2,]);
let mut peer_vm_1 = create_avm(set_variable_call_service(arg), vm_peer_id_1);
let script = f!(r#"
let script = format!(
r#"
(call "vm_peer_id_1" ("" "") [] some)
"#);
"#
);
let wrong_trace = vec![scalar!(42)];
let data = raw_data_from_trace(wrong_trace, <_>::default());

View File

@ -36,7 +36,6 @@ thiserror = "1.0.40"
tracing = "0.1.37"
[dev-dependencies]
fstrings = "0.2.3"
criterion = "0.4.0"
non-empty-vec = { version = "0.2.3" }

View File

@ -55,7 +55,7 @@ mod gen {
use crate::SOURCE_CODE_GOOD;
pub fn seq(left: &str, right: &str) -> String {
f!(r"(seq {left} {right})")
format!(r"(seq {left} {right})")
}
pub fn deep_seq(mut depth: usize) -> String {

View File

@ -34,9 +34,5 @@ pub use parser::AIRLexer;
pub use parser::AIRParser;
pub use parser::VariableValidator;
#[cfg(test)]
#[macro_use]
extern crate fstrings;
use air_lambda_parser::parse as parse_lambda;
use air_lambda_parser::LambdaAST;

View File

@ -25,8 +25,6 @@ use air_lambda_parser::LambdaAST;
use air_lambda_parser::ValueAccessor;
use air_lambda_ast::Functor;
use fstrings::f;
use fstrings::format_args_f;
fn run_lexer(input: &str) -> Vec<Spanned<Token<'_>, AirPos, LexerError>> {
let lexer = AIRLexer::new(input);
@ -235,7 +233,7 @@ fn canon_stream() {
#[test]
fn canon_stream_with_functor() {
let canon_stream_name = "#canon_stream";
let canon_stream_with_functor: String = f!("{canon_stream_name}.length");
let canon_stream_with_functor: String = format!("{canon_stream_name}.length");
lexer_test(
&canon_stream_with_functor,
@ -254,7 +252,7 @@ fn canon_stream_with_functor() {
#[test]
fn scalar_with_functor() {
let scalar_name = "scalar";
let scalar_with_functor: String = f!("{scalar_name}.length");
let scalar_with_functor: String = format!("{scalar_name}.length");
lexer_test(
&scalar_with_functor,
@ -287,7 +285,7 @@ fn string_literal() {
#[test]
fn integer_numbers() {
let test_integer = 123;
let number_with_plus_sign = f!("+{test_integer}");
let number_with_plus_sign = format!("+{test_integer}");
lexer_test(
&number_with_plus_sign,
@ -298,7 +296,7 @@ fn integer_numbers() {
))),
);
let number = f!("{test_integer}");
let number = format!("{test_integer}");
lexer_test(
&number,
@ -309,7 +307,7 @@ fn integer_numbers() {
))),
);
let number_with_minus_sign = f!("-{test_integer}");
let number_with_minus_sign = format!("-{test_integer}");
lexer_test(
&number_with_minus_sign,
@ -324,7 +322,7 @@ fn integer_numbers() {
#[test]
fn float_number() {
let test_float = 123.123;
let float_number_with_plus_sign = f!("+{test_float}");
let float_number_with_plus_sign = format!("+{test_float}");
lexer_test(
&float_number_with_plus_sign,
@ -335,7 +333,7 @@ fn float_number() {
))),
);
let float_number = f!("{test_float}");
let float_number = format!("{test_float}");
lexer_test(
&float_number,
@ -346,7 +344,7 @@ fn float_number() {
))),
);
let float_number_with_minus_sign = f!("-{test_float}");
let float_number_with_minus_sign = format!("-{test_float}");
lexer_test(
&float_number_with_minus_sign,

View File

@ -19,8 +19,6 @@ use super::parse;
use crate::ast::*;
use air_lambda_ast::{LambdaAST, ValueAccessor};
use fstrings::f;
use fstrings::format_args_f;
#[test]
fn ap_with_literal() {
@ -151,9 +149,11 @@ fn ap_with_ttl() {
fn ap_with_canon_stream() {
let canon_stream = "#canon_stream";
let scalar = "scalar";
let source_code = f!(r#"
let source_code = format!(
r#"
(ap {canon_stream} {scalar})
"#);
"#
);
let actual = parse(&source_code);
let expected = ap(
@ -168,9 +168,11 @@ fn ap_with_canon_stream() {
fn ap_with_canon_stream_with_lambda() {
let canon_stream = "#canon_stream";
let scalar = "scalar";
let source_code = f!(r#"
let source_code = format!(
r#"
(ap {canon_stream}.$.[0] {scalar})
"#);
"#
);
let actual = parse(&source_code);
let expected = ap(

View File

@ -20,8 +20,6 @@ use crate::ast::*;
use crate::parser::ParserError;
use air_lambda_ast::{LambdaAST, ValueAccessor};
use fstrings::f;
use fstrings::format_args_f;
use lalrpop_util::ParseError;
use std::rc::Rc;
@ -385,9 +383,11 @@ fn canon_stream_in_args() {
let service_id = "service_id";
let function_name = "function_name";
let canon_stream = "#canon_stream";
let source_code = f!(r#"
let source_code = format!(
r#"
(call %init_peer_id% ("{service_id}" "{function_name}") [{canon_stream}])
"#);
"#
);
let instruction = parse(&source_code);
let expected = call(
@ -408,9 +408,11 @@ fn canon_stream_in_triplet() {
let service_id = "service_id";
let function_name = "function_name";
let canon_stream = "#canon_stream";
let source_code = f!(r#"
let source_code = format!(
r#"
(call {canon_stream} ("{service_id}" "{function_name}") [])
"#);
"#
);
let lexer = crate::AIRLexer::new(&source_code);
@ -434,9 +436,11 @@ fn canon_stream_with_lambda_in_triplet() {
let function_name = "function_name";
let canon_stream = "#canon_stream";
let canon_stream_lambda = ".$.[0].path!";
let source_code = f!(r#"
let source_code = format!(
r#"
(call {canon_stream}{canon_stream_lambda} ("{service_id}" "{function_name}") [])
"#);
"#
);
let instruction = parse(&source_code);
let expected = call(
@ -461,14 +465,16 @@ fn canon_stream_with_lambda_in_triplet() {
#[test]
fn seq_par_call() {
let peer_id = "some_peer_id";
let source_code = f!(r#"
let source_code = format!(
r#"
(seq
(par
(call "{peer_id}" ("local_service_id" "local_fn_name") [] result_1)
(call "{peer_id}" ("service_id" "fn_name") [] g)
)
(call "{peer_id}" ("local_service_id" "local_fn_name") [] result_2)
)"#);
)"#
);
let instruction = parse(&source_code);
let expected = seq(

View File

@ -18,17 +18,16 @@ use super::dsl::*;
use super::parse;
use crate::ast::*;
use fstrings::f;
use fstrings::format_args_f;
#[test]
fn canon_with_literal_peer_id() {
let peer_id = "peer_id";
let stream = "$stream";
let canon_stream = "#canon_stream";
let source_code = f!(r#"
let source_code = format!(
r#"
(canon "{peer_id}" {stream} {canon_stream})
"#);
"#
);
let actual = parse(&source_code);
let expected = canon(
@ -45,9 +44,11 @@ fn canon_with_variable_peer_id() {
let peer_id = "peer_id";
let stream = "$stream";
let canon_stream = "#canon_stream";
let source_code = f!(r#"
let source_code = format!(
r#"
(canon {peer_id} {stream} {canon_stream})
"#);
"#
);
let actual = parse(&source_code);
let expected = canon(
@ -64,9 +65,11 @@ fn canon_with_stream_map() {
let peer_id = "peer_id";
let stream_map = "%stream_map";
let scalar = "scalar";
let source_code = f!(r#"
let source_code = format!(
r#"
(canon {peer_id} {stream_map} {scalar})
"#);
"#
);
let actual = parse(&source_code);
let expected = canon_stream_map_scalar(

View File

@ -20,8 +20,6 @@ use crate::ast::*;
use crate::parser::ParserError;
use air_lambda_ast::ValueAccessor;
use fstrings::f;
use fstrings::format_args_f;
use lalrpop_util::ParseError;
#[test]
@ -382,9 +380,11 @@ fn fold_on_stream_with_last_null() {
fn fold_on_canon_stream() {
let canon_stream = "#canon_stream";
let iterator = "iterator";
let source_code = f!(r#"
let source_code = format!(
r#"
(fold {canon_stream} {iterator} (null))
"#);
"#
);
let instruction = parse(&source_code);
let expected = fold_scalar_canon_stream(
@ -425,9 +425,11 @@ fn comments() {
}
fn source_fold_with(name: &str) -> String {
f!(r#"(fold iterable i
format!(
r#"(fold iterable i
({name} (null) (null))
)"#)
)"#
)
}
#[test]
fn parse_fold_with_xor_par_seq() {

View File

@ -19,8 +19,6 @@ use super::parse;
use crate::ast::*;
use air_lambda_ast::{LambdaAST, ValueAccessor};
use fstrings::f;
use fstrings::format_args_f;
#[test]
fn parse_match() {
@ -42,11 +40,13 @@ fn parse_match() {
fn parse_match_with_canon_stream() {
let canon_stream = "#canon_stream";
let canon_stream_lambda = ".$.[0]";
let source_code = f!(r#"
let source_code = format!(
r#"
(match {canon_stream}{canon_stream_lambda} v2
(null)
)
"#);
"#
);
let instruction = parse(&source_code);
let expected = match_(

View File

@ -97,7 +97,8 @@ fn parse_seq_seq() {
}
fn source_seq_with(name: &'static str) -> String {
f!(r#"
format!(
r#"
(seq
({name}
(seq (null) (null))
@ -105,7 +106,8 @@ fn source_seq_with(name: &'static str) -> String {
)
({name} (null) (seq (null) (null)) )
)
"#)
"#
)
}
#[test]

View File

@ -23,7 +23,6 @@ avm-interface = { version = "0.28.4", path = "../../../avm/interface" }
avm-server = { version = "0.32.0", path = "../../../avm/server" }
marine-rs-sdk = "0.7.1"
fstrings = "0.2.3"
object-pool = "0.5.4"
once_cell = "1.17.1"
semver = "1.0.17"

View File

@ -48,9 +48,6 @@ pub mod prelude {
pub use air::interpreter_data::*;
pub use avm_server::*;
pub use fstrings::f;
pub use fstrings::format_args_f;
pub use serde_json::json;
}

View File

@ -570,7 +570,7 @@ mod tests {
let network = Network::<NativeAirRunner>::new(std::iter::empty::<PeerId>(), vec![]);
let transformed1 = TransformedAirScript::new(
&f!(r#"(call "{}" ("service" "function") []) ; ok = 42"#, peer),
&format!(r#"(call "{}" ("service" "function") []) ; ok = 42"#, peer),
network.clone(),
)
.unwrap();
@ -581,7 +581,7 @@ mod tests {
.unwrap();
let transformed2 = TransformedAirScript::new(
&f!(r#"(call "{}" ("service" "function") []) ; ok = 24"#, peer),
&format!(r#"(call "{}" ("service" "function") []) ; ok = 24"#, peer),
network,
)
.unwrap();
@ -635,7 +635,7 @@ mod tests {
);
let peer = "peer1";
let air_script = f!(r#"(call "{}" ("service" "function") [])"#, peer);
let air_script = format!(r#"(call "{}" ("service" "function") [])"#, peer);
let transformed1 = TransformedAirScript::new(&air_script, network.clone()).unwrap();
let exectution1 = AirScriptExecutor::from_transformed_air_script(
TestRunParameters::from_init_peer_id(peer),

View File

@ -124,10 +124,10 @@ fn peer_host_function(
#[rustfmt::skip]
fn create_peer_host_function(peer_id: String, known_peer_ids: Vec<String>) -> CallServiceClosure {
let relay_blueprints = (0..=2).map(|id| f!("{peer_id}_blueprint_{id}")).collect::<Vec<_>>();
let relay_modules = (0..=2).map(|id| f!("{peer_id}_module_{id}")).collect::<Vec<_>>();
let relay_interfaces = (0..=2).map(|id| f!("{peer_id}_interface_{id}")).collect::<Vec<_>>();
let relay_ident = f!("{peer_id}_ident");
let relay_blueprints = (0..=2).map(|id| format!("{peer_id}_blueprint_{id}")).collect::<Vec<_>>();
let relay_modules = (0..=2).map(|id| format!("{peer_id}_module_{id}")).collect::<Vec<_>>();
let relay_interfaces = (0..=2).map(|id| format!("{peer_id}_interface_{id}")).collect::<Vec<_>>();
let relay_ident = format!("{peer_id}_ident");
peer_host_function(
known_peer_ids,