diff --git a/.circleci/config.yml b/.circleci/config.yml index ab02c0d6..a32b16bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,7 +26,7 @@ jobs: (cd air-interpreter; marine build --features marine) # build Wasm binaries for tests - (cd air/tests/test_module/integration; ./build_test_binaries.sh) + (cd air/tests/test_module; ./build_test_binaries.sh) cargo fmt --all -- --check --color always cargo check diff --git a/Cargo.lock b/Cargo.lock index d3264073..cb9a1878 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -139,6 +139,7 @@ dependencies = [ "air", "air-interpreter-interface", "avm-server", + "fstrings", "marine-rs-sdk", "serde_json", ] diff --git a/air/Cargo.toml b/air/Cargo.toml index fc96c3ea..aacf1ea3 100644 --- a/air/Cargo.toml +++ b/air/Cargo.toml @@ -33,8 +33,8 @@ boolinator = "2.4.0" concat-idents = "1.1.3" maplit = "1.0.2" log = "0.4.11" -thiserror = "1.0.23" fstrings = "0.2.3" +thiserror = "1.0.23" strum = "0.21" strum_macros = "0.21" diff --git a/air/src/execution_step/air/call/prev_result_handler.rs b/air/src/execution_step/air/call/prev_result_handler.rs index 5b24cc4e..a2b5920c 100644 --- a/air/src/execution_step/air/call/prev_result_handler.rs +++ b/air/src/execution_step/air/call/prev_result_handler.rs @@ -25,6 +25,9 @@ use air_interpreter_interface::CallServiceResult; use air_parser::ast::CallOutputValue; 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, @@ -142,10 +145,8 @@ fn try_to_service_result( match serde_json::from_str(&service_result.result) { Ok(result) => Ok(Rc::new(result)), Err(e) => { - let error_msg = format!( - "call_service result '{0}' can't be serialized or deserialized with an error: {1}", - service_result.result, e - ); + let error_msg = + f!("call_service result '{service_result}' can't be serialized or deserialized with an error: {e}"); let error_msg = Rc::new(error_msg); let error = CallServiceFailed(i32::MAX, error_msg.clone()); diff --git a/air/tests/test_module/integration/build_test_binaries.sh b/air/tests/test_module/build_test_binaries.sh similarity index 70% rename from air/tests/test_module/integration/build_test_binaries.sh rename to air/tests/test_module/build_test_binaries.sh index 9f104d89..87f89df8 100755 --- a/air/tests/test_module/integration/build_test_binaries.sh +++ b/air/tests/test_module/build_test_binaries.sh @@ -2,7 +2,7 @@ set -euo pipefail -for dir in ./security_tetraplets/*; do +for dir in ./features/tetraplets/security_tetraplets/*; do # skip non-directory entries [ -d "$dir" ] || continue diff --git a/air/tests/test_module/features/data_merging/air_basic.rs b/air/tests/test_module/features/data_merging/air_basic.rs new file mode 100644 index 00000000..ef021e0d --- /dev/null +++ b/air/tests/test_module/features/data_merging/air_basic.rs @@ -0,0 +1,76 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +use air_test_utils::prelude::*; + +#[test] +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#" + (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, "asd", script, "", ""); + let actual_trace = trace_from_result(&result); + + let unit_call_service_result = "result from unit_call_service"; + let expected_trace = vec![ + executed_state::par(1, 1), + executed_state::scalar_string(unit_call_service_result), + executed_state::request_sent_by(vm_peer_id), + executed_state::scalar_string(unit_call_service_result), + ]; + + assert_eq!(actual_trace, expected_trace); + assert_eq!(result.next_peer_pks, vec![String::from("remote_peer_id")]); +} + +#[test] +fn par_par_call() { + let vm_peer_id = "some_peer_id"; + let mut vm = create_avm(unit_call_service(), vm_peer_id); + + let script = f!(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, "asd", script, "", ""); + let actual_trace = trace_from_result(&result); + + let unit_call_service_result = "result from unit_call_service"; + let expected_trace = vec![ + executed_state::par(3, 1), + executed_state::par(1, 1), + executed_state::scalar_string(unit_call_service_result), + executed_state::request_sent_by(vm_peer_id), + executed_state::scalar_string(unit_call_service_result), + ]; + + assert_eq!(actual_trace, expected_trace); + assert_eq!(result.next_peer_pks, vec![String::from("remote_peer_id")]); +} diff --git a/air/tests/test_module/integration/data_merge.rs b/air/tests/test_module/features/data_merging/data_merge.rs similarity index 75% rename from air/tests/test_module/integration/data_merge.rs rename to air/tests/test_module/features/data_merging/data_merge.rs index e1cced9f..1de7bad1 100644 --- a/air/tests/test_module/integration/data_merge.rs +++ b/air/tests/test_module/features/data_merging/data_merge.rs @@ -15,23 +15,27 @@ */ use air_test_utils::prelude::*; + use std::collections::HashMap; #[test] -fn data_merge() { +fn merge_streams_in_two_fold() { use executed_state::*; - let set_variable_id = "set_variable"; - let vm_1_id = "A"; - let vm_2_id = "B"; + let set_variable_peer_id = "set_variable_peer_id"; + let vm_1_peer_id = "vm_1_peer_id"; + let vm_2_peer_id = "vm_2_peer_id"; - let mut set_variable = create_avm(set_variable_call_service(json!([vm_1_id, vm_2_id])), set_variable_id); - let mut vm1 = create_avm(return_string_call_service(vm_1_id), vm_1_id); - let mut vm2 = create_avm(return_string_call_service(vm_2_id), vm_2_id); + let mut set_variable = create_avm( + set_variable_call_service(json!([vm_1_peer_id, vm_2_peer_id])), + set_variable_peer_id, + ); + 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 = r#" + let script = f!(r#" (seq - (call "set_variable" ("neighborhood" "") [] neighborhood) + (call "{set_variable_peer_id}" ("neighborhood" "") [] neighborhood) (seq (seq (fold neighborhood i @@ -48,70 +52,70 @@ fn data_merge() { ) ) (seq - (call "A" ("identity" "") [] $void) - (call "B" ("" "") [] none) + (call "{vm_1_peer_id}" ("identity" "") [] $void) + (call "{vm_2_peer_id}" ("" "") [] none) ) ) ) - "#; + "#); - let result_0 = checked_call_vm!(set_variable, "", script, "", ""); - let result_1 = checked_call_vm!(vm1, "", script, "", result_0.data.clone()); - let result_2 = checked_call_vm!(vm2, "", script, "", result_0.data); - let result_3 = checked_call_vm!(vm1, "", script, result_1.data.clone(), result_2.data.clone()); + let result_0 = checked_call_vm!(set_variable, "", &script, "", ""); + let result_1 = checked_call_vm!(vm1, "", &script, "", result_0.data.clone()); + let result_2 = checked_call_vm!(vm2, "", &script, "", result_0.data); + let result_3 = checked_call_vm!(vm1, "", &script, result_1.data.clone(), result_2.data.clone()); let result_4 = checked_call_vm!(vm2, "", script, result_1.data.clone(), result_2.data.clone()); let actual_trace_1 = trace_from_result(&result_1); let expected_trace_1 = vec![ - scalar_string_array(vec!["A", "B"]), + scalar_string_array(vec![vm_1_peer_id, vm_2_peer_id]), par(1, 2), - stream_string(vm_1_id, 0), + stream_string(vm_1_peer_id, 0), par(1, 0), - request_sent_by(set_variable_id), + request_sent_by(set_variable_peer_id), par(1, 2), - stream_string(vm_1_id, 0), + stream_string(vm_1_peer_id, 0), par(1, 0), - request_sent_by(vm_1_id), - stream_string(vm_1_id, 1), - request_sent_by(vm_1_id), + request_sent_by(vm_1_peer_id), + stream_string(vm_1_peer_id, 1), + request_sent_by(vm_1_peer_id), ]; assert_eq!(actual_trace_1, expected_trace_1); - assert_eq!(result_1.next_peer_pks, vec![String::from("B")]); + assert_eq!(result_1.next_peer_pks, vec![vm_2_peer_id.to_string()]); let actual_trace_2 = trace_from_result(&result_2); let expected_trace_2 = vec![ - scalar_string_array(vec!["A", "B"]), + scalar_string_array(vec![vm_1_peer_id, vm_2_peer_id]), par(1, 2), - request_sent_by(set_variable_id), + request_sent_by(set_variable_peer_id), par(1, 0), - stream_string(vm_2_id, 0), + stream_string(vm_2_peer_id, 0), par(1, 2), - request_sent_by(vm_2_id), + request_sent_by(vm_2_peer_id), par(1, 0), - stream_string(vm_2_id, 0), - request_sent_by(vm_2_id), + stream_string(vm_2_peer_id, 0), + request_sent_by(vm_2_peer_id), ]; assert_eq!(actual_trace_2, expected_trace_2); - assert_eq!(result_2.next_peer_pks, vec![String::from("A")]); + assert_eq!(result_2.next_peer_pks, vec![vm_1_peer_id.to_string()]); let actual_trace_3 = trace_from_result(&result_3); let expected_trace_3 = vec![ - scalar_string_array(vec!["A", "B"]), + scalar_string_array(vec![vm_1_peer_id, vm_2_peer_id]), par(1, 2), - stream_string(vm_1_id, 0), + stream_string(vm_1_peer_id, 0), par(1, 0), - stream_string(vm_2_id, 2), + stream_string(vm_2_peer_id, 2), par(1, 2), - stream_string(vm_1_id, 0), + stream_string(vm_1_peer_id, 0), par(1, 0), - stream_string(vm_2_id, 1), - stream_string(vm_1_id, 1), - request_sent_by(vm_1_id), + stream_string(vm_2_peer_id, 1), + stream_string(vm_1_peer_id, 1), + request_sent_by(vm_1_peer_id), ]; assert_eq!(actual_trace_3, expected_trace_3); @@ -120,17 +124,17 @@ fn data_merge() { let actual_trace_4 = trace_from_result(&result_4); let expected_trace_4 = vec![ - scalar_string_array(vec!["A", "B"]), + scalar_string_array(vec![vm_1_peer_id, vm_2_peer_id]), par(1, 2), - stream_string(vm_1_id, 0), + stream_string(vm_1_peer_id, 0), par(1, 0), - stream_string(vm_2_id, 2), + stream_string(vm_2_peer_id, 2), par(1, 2), - stream_string(vm_1_id, 0), + stream_string(vm_1_peer_id, 0), par(1, 0), - stream_string(vm_2_id, 1), - stream_string(vm_1_id, 1), - scalar_string(vm_2_id), + stream_string(vm_2_peer_id, 1), + stream_string(vm_1_peer_id, 1), + scalar_string(vm_2_peer_id), ]; assert_eq!(actual_trace_4, expected_trace_4); @@ -138,7 +142,7 @@ fn data_merge() { } #[test] -fn acc_merge() { +fn stream_merge() { let neighborhood_call_service: CallServiceClosure = Box::new(|params| -> CallServiceResult { let args_count = (params.function_name.as_bytes()[0] - b'0') as usize; let args: Vec> = serde_json::from_value(JValue::Array(params.arguments)).expect("valid json"); @@ -150,8 +154,7 @@ fn acc_merge() { let mut vm1 = create_avm(set_variable_call_service(json!("peer_id")), "A"); let mut vm2 = create_avm(neighborhood_call_service, "B"); - let script = String::from( - r#" + let script = r#" (seq (call "A" ("add_provider" "") [] $void) (seq @@ -168,10 +171,9 @@ fn acc_merge() { ) ) ) - "#, - ); + "#; - let result = checked_call_vm!(vm1, "asd", script.clone(), "", ""); + let result = checked_call_vm!(vm1, "asd", script, "", ""); checked_call_vm!(vm2, "asd", script, "", result.data); } @@ -201,7 +203,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 = format!("peer_{}", vm_id); + let peer_id = f!("peer_{vm_id}"); let mut vm = create_avm(echo_call_service(), peer_id); let result = checked_call_vm!( vm, diff --git a/air/tests/test_module/integration/call_evidence_basic.rs b/air/tests/test_module/features/data_merging/executed_trace_basic.rs similarity index 86% rename from air/tests/test_module/integration/call_evidence_basic.rs rename to air/tests/test_module/features/data_merging/executed_trace_basic.rs index 9b7123a0..b94695cb 100644 --- a/air/tests/test_module/integration/call_evidence_basic.rs +++ b/air/tests/test_module/features/data_merging/executed_trace_basic.rs @@ -21,17 +21,14 @@ fn executed_trace_seq_par_call() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(unit_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq (par - (call "{0}" ("local_service_id" "local_fn_name") [] result_1) + (call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_1) (call "remote_peer_id" ("service_id" "fn_name") [] g) ) - (call "{0}" ("local_service_id" "local_fn_name") [] result_2) - )"#, - local_peer_id - ); + (call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_2) + )"#); let unit_call_service_result = "result from unit_call_service"; let initial_trace = vec![ @@ -60,17 +57,14 @@ fn executed_trace_par_par_call() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(unit_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (par (par - (call "{0}" ("local_service_id" "local_fn_name") [] result_1) + (call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_1) (call "remote_peer_id" ("service_id" "fn_name") [] g) ) - (call "{0}" ("local_service_id" "local_fn_name") [] result_2) - )"#, - local_peer_id, - ); + (call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_2) + )"#); let unit_call_service_result = "result from unit_call_service"; let initial_state = vec![ @@ -118,34 +112,31 @@ 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 = format!( - r#" + let script = f!(r#" (seq - (call "{}" ("identity" "") [] void0) + (call "{peer_id_1}" ("identity" "") [] void0) (seq - (call "{}" ("add_blueprint" "") [] blueprint_id) - (call "{}" ("addBlueprint-14d8488e-d10d-474d-96b2-878f6a7d74c8" "") [] void1) + (call "{peer_id_1}" ("add_blueprint" "") [] blueprint_id) + (call "{peer_id_2}" ("addBlueprint-14d8488e-d10d-474d-96b2-878f6a7d74c8" "") [] void1) ) ) - "#, - peer_id_1, peer_id_1, peer_id_2 - ); + "#); - let result = checked_call_vm!(vm2, "asd", script.clone(), "", ""); + let result = checked_call_vm!(vm2, "asd", &script, "", ""); assert_eq!(result.next_peer_pks, vec![peer_id_1.clone()]); - let result = checked_call_vm!(vm1, "asd", script.clone(), "", result.data); + let result = checked_call_vm!(vm1, "asd", &script, "", result.data); assert_eq!(result.next_peer_pks, vec![peer_id_2.clone()]); let result = checked_call_vm!(vm2, "asd", script, "", result.data); let actual_trace = trace_from_result(&result); - let call_serivce_result = "result from unit_call_service"; + let call_service_result = "result from unit_call_service"; let expected_trace = vec![ - scalar_string(call_serivce_result), - scalar_string(call_serivce_result), - scalar_string(call_serivce_result), + scalar_string(call_service_result), + scalar_string(call_service_result), + scalar_string(call_service_result), ]; assert_eq!(actual_trace, expected_trace); @@ -220,8 +211,7 @@ fn executed_trace_par_seq_fold_call() { let mut vm2 = create_avm(echo_call_service(), "some_peer_id_2"); let mut vm3 = create_avm(unit_call_service(), "some_peer_id_3"); - let script = String::from( - r#" + let script = r#" (par (seq (call "some_peer_id_1" ("local_service_id" "local_fn_name") [] IterableResultPeer1) @@ -233,15 +223,14 @@ fn executed_trace_par_seq_fold_call() { ) ) (call "some_peer_id_3" ("local_service_id" "local_fn_name") [] result_2) - )"#, - ); + )"#; - let result = checked_call_vm!(vm2, "asd", script.clone(), "", ""); - let result = checked_call_vm!(vm1, "asd", script.clone(), "", result.data); + let result = checked_call_vm!(vm2, "asd", script, "", ""); + let result = checked_call_vm!(vm1, "asd", script, "", result.data); let mut data = result.data; for _ in 0..100 { - let result = checked_call_vm!(vm2, "asd", script.clone(), "", data); + let result = checked_call_vm!(vm2, "asd", script, "", data); data = result.data; } @@ -351,24 +340,21 @@ 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 = format!( - r#" + let script = f!(r#" (seq (par (seq - (call "{}" ("" "") [] result_1) - (call "{}" ("" "") [] result_2) + (call "{peer_id_1}" ("" "") [] result_1) + (call "{peer_id_2}" ("" "") [] result_2) ) (seq - (call "{}" ("" "") [] result_3) - (call "{}" ("" "") [] result_4) + (call "{peer_id_2}" ("" "") [] result_3) + (call "{peer_id_1}" ("" "") [] result_4) ) ) - (call "{}" ("" "") [] result_5) + (call "{peer_id_2}" ("" "") [] result_5) ) - "#, - peer_id_1, peer_id_2, peer_id_2, peer_id_1, peer_id_2 - ); + "#); let result = checked_call_vm!(vm2, "asd", &script, "", ""); assert_eq!(result.next_peer_pks, vec![peer_id_1.to_string()]); diff --git a/air/tests/test_module/features/data_merging/mod.rs b/air/tests/test_module/features/data_merging/mod.rs new file mode 100644 index 00000000..c0bbc4de --- /dev/null +++ b/air/tests/test_module/features/data_merging/mod.rs @@ -0,0 +1,19 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mod air_basic; +mod data_merge; +mod executed_trace_basic; diff --git a/air/tests/test_module/features/data_merging/scripts/create_service.clj b/air/tests/test_module/features/data_merging/scripts/create_service.clj new file mode 100644 index 00000000..d549c141 --- /dev/null +++ b/air/tests/test_module/features/data_merging/scripts/create_service.clj @@ -0,0 +1,19 @@ +(seq + (seq + (seq + (call "set_variables" ("add_module" "") ["module_bytes"] module_bytes) + (call "set_variables" ("add_module" "") ["module_config"] module_config) + ) + (call "set_variables" ("add_module" "") ["blueprint"] blueprint) + ) + (seq + (call "A" ("add_module" "") [module_bytes module_config] module) + (seq + (call "A" ("add_blueprint" "") [blueprint] blueprint_id) + (seq + (call "A" ("create" "") [blueprint_id] service_id) + (call "remote_peer_id" ("" "") [service_id] client_result) + ) + ) + ) + ) diff --git a/air/tests/test_module/integration/scripts/inner_folds_v1.clj b/air/tests/test_module/features/data_merging/scripts/inner_folds_v1.clj similarity index 100% rename from air/tests/test_module/integration/scripts/inner_folds_v1.clj rename to air/tests/test_module/features/data_merging/scripts/inner_folds_v1.clj diff --git a/air/tests/test_module/features/errors/invalid_air.rs b/air/tests/test_module/features/errors/invalid_air.rs new file mode 100644 index 00000000..bbee7558 --- /dev/null +++ b/air/tests/test_module/features/errors/invalid_air.rs @@ -0,0 +1,32 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +use air::PreparationError; +use air_test_utils::prelude::*; + +#[test] +fn invalid_air() { + let vm_peer_id = "some_peer_id"; + let mut vm = create_avm(unit_call_service(), vm_peer_id); + + let script = r#"(seq )"#; + + let result = call_vm!(vm, "", script, "", ""); + + let error_message = air_parser::parse(script).expect_err("air parser should fail on this script"); + let expected_error = PreparationError::AIRParseError(error_message); + assert!(check_error(&result, expected_error)); +} diff --git a/air/tests/test_module/integration/last_error.rs b/air/tests/test_module/features/errors/last_error.rs similarity index 94% rename from air/tests/test_module/integration/last_error.rs rename to air/tests/test_module/features/errors/last_error.rs index 83988800..c25aa67a 100644 --- a/air/tests/test_module/integration/last_error.rs +++ b/air/tests/test_module/features/errors/last_error.rs @@ -21,9 +21,6 @@ use air::LastErrorObjectError; use air::SecurityTetraplet; use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - use std::cell::RefCell; use std::rc::Rc; @@ -67,8 +64,8 @@ fn last_error_tetraplets() { set_variable_peer_id, fallible_peer_id, local_peer_id ); - let result = checked_call_vm!(set_variable_vm, "asd", script.clone(), "", ""); - let result = checked_call_vm!(fallible_vm, "asd", script.clone(), "", result.data); + let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); + let result = checked_call_vm!(fallible_vm, "asd", &script, "", result.data); let _ = checked_call_vm!(local_vm, "asd", script, "", result.data); let actual_value = (*args.borrow()).as_ref().unwrap().clone(); @@ -104,23 +101,20 @@ fn not_clear_last_error_in_match() { local_peer_id, ); - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") [] relayVariableName) + (call "{set_variable_peer_id}" ("" "") [] relayVariableName) (xor (match relayVariableName "" (call "unknown_peer" ("" "") [%last_error%]) ) (seq - (call "{1}" ("" "") [%last_error%]) + (call "{local_peer_id}" ("" "") [%last_error%]) (null) ) ) ) - "#, - set_variable_peer_id, local_peer_id - ); + "#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let _ = checked_call_vm!(local_vm, "asd", &script, "", result.data); @@ -143,23 +137,20 @@ fn not_clear_last_error_in_mismatch() { local_peer_id, ); - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") [] relayVariableName) + (call "{set_variable_peer_id}" ("" "") [] relayVariableName) (xor (mismatch relayVariableName "result from unit_call_service" (call "unknown_peer" ("" "") [%last_error%]) ) (seq (null) - (call "{1}" ("" "") [%last_error%]) + (call "{local_peer_id}" ("" "") [%last_error%]) ) ) ) - "#, - set_variable_peer_id, local_peer_id - ); + "#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let _ = checked_call_vm!(local_vm, "asd", &script, "", result.data); @@ -182,15 +173,12 @@ fn track_current_peer_id() { local_peer_id, ); - let script = format!( - r#" + let script = f!(r#" (xor - (call "{0}" ("fallible_call_service" "") [""]) - (call "{1}" ("" "") [%last_error%]) + (call "{fallible_peer_id}" ("fallible_call_service" "") [""]) + (call "{local_peer_id}" ("" "") [%last_error%]) ) - "#, - fallible_peer_id, local_peer_id - ); + "#); let result = checked_call_vm!(fallible_vm, "asd", &script, "", ""); let _ = checked_call_vm!(local_vm, "asd", script, "", result.data); diff --git a/air/tests/test_module/features/errors/mod.rs b/air/tests/test_module/features/errors/mod.rs new file mode 100644 index 00000000..a0e4d7da --- /dev/null +++ b/air/tests/test_module/features/errors/mod.rs @@ -0,0 +1,18 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mod invalid_air; +mod last_error; diff --git a/air/tests/test_module/integration/scripts/create_service_with_xor.clj b/air/tests/test_module/features/errors/scripts/create_service_with_xor.clj similarity index 100% rename from air/tests/test_module/integration/scripts/create_service_with_xor.clj rename to air/tests/test_module/features/errors/scripts/create_service_with_xor.clj diff --git a/air/tests/test_module/integration/join_behaviour.rs b/air/tests/test_module/features/join_behaviour/join_behaviour.rs similarity index 82% rename from air/tests/test_module/integration/join_behaviour.rs rename to air/tests/test_module/features/join_behaviour/join_behaviour.rs index 518abcca..23407993 100644 --- a/air/tests/test_module/integration/join_behaviour.rs +++ b/air/tests/test_module/features/join_behaviour/join_behaviour.rs @@ -18,9 +18,6 @@ use air::CatchableError; use air::LambdaError; use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] fn dont_wait_on_json_path() { let status = json!({ @@ -44,24 +41,21 @@ 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 = format!( - r#" + let script = f!(r#" (seq (seq - (call "{0}" ("" "") ["msg"] msg) - (call "{0}" ("" "") ["status"] status) + (call "{set_variable_peer_id}" ("" "") ["msg"] msg) + (call "{set_variable_peer_id}" ("" "") ["status"] status) ) (seq - (call "{1}" ("op" "identity") []) + (call "{local_peer_id}" ("op" "identity") []) (seq - (call "{1}" ("history" "add") [msg status.$.is_authenticated!] auth_result) + (call "{local_peer_id}" ("history" "add") [msg status.$.is_authenticated!] auth_result) (call %init_peer_id% ("returnService" "run") [auth_result]) ) ) ) - "#, - set_variable_peer_id, local_peer_id - ); + "#); let init_peer_id = "asd"; let result = checked_call_vm!(set_variable_vm, init_peer_id, &script, "", ""); @@ -75,28 +69,22 @@ fn wait_on_stream_json_path_by_id() { let local_peer_id = "local_peer_id"; let mut local_vm = create_avm(unit_call_service(), local_peer_id); - let non_join_stream_script = format!( - r#" + let non_join_stream_script = f!(r#" (par - (call "{0}" ("" "") [] $status) - (call "{0}" ("history" "add") [$status.$[0]!]) - )"#, - local_peer_id - ); + (call "{local_peer_id}" ("" "") [] $status) + (call "{local_peer_id}" ("history" "add") [$status.$[0]!]) + )"#); let result = checked_call_vm!(local_vm, "", non_join_stream_script, "", ""); let actual_trace = trace_from_result(&result); assert_eq!(actual_trace.len(), 3); - let join_stream_script = format!( - r#" + let join_stream_script = f!(r#" (par - (call "{0}" ("" "") [] $status) - (call "{0}" ("history" "add") [$status.$[1]!]) ; $status stream here has only one value - )"#, - local_peer_id - ); + (call "{local_peer_id}" ("" "") [] $status) + (call "{local_peer_id}" ("history" "add") [$status.$[1]!]) ; $status stream here has only one value + )"#); let result = checked_call_vm!(local_vm, "", join_stream_script, "", ""); let actual_trace = trace_from_result(&result); @@ -109,12 +97,10 @@ fn wait_on_empty_stream_json_path() { let local_peer_id = "local_peer_id"; let mut local_vm = create_avm(echo_call_service(), local_peer_id); - let join_stream_script = format!( - r#" - + let join_stream_script = f!(r#" (seq (seq - (call "{0}" ("" "") [[]] nodes) + (call "{local_peer_id}" ("" "") [[]] nodes) (fold nodes n (par (call n ("" "") [n] $ns) @@ -122,10 +108,8 @@ fn wait_on_empty_stream_json_path() { ) ) ) - (call "{0}" ("" "") [$ns.$.[0] $ns.$.[1] $ns]) - )"#, - local_peer_id - ); + (call "{local_peer_id}" ("" "") [$ns.$.[0] $ns.$.[1] $ns]) + )"#); let result = checked_call_vm!(local_vm, "", join_stream_script, "", ""); let actual_trace = trace_from_result(&result); @@ -159,15 +143,12 @@ 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 = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") ["array"] array) - (call "{1}" ("" "") [array.$.[5]!] auth_result) + (call "{set_variable_peer_id}" ("" "") ["array"] array) + (call "{array_consumer_peer_id}" ("" "") [array.$.[5]!] auth_result) ) - "#, - set_variable_peer_id, array_consumer_peer_id, - ); + "#); let init_peer_id = "asd"; let result = call_vm!(set_variable_vm, init_peer_id, &script, "", ""); @@ -177,15 +158,12 @@ 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 = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") ["object"] object) - (call "{1}" ("" "") [object.$.non_exist_path]) + (call "{set_variable_peer_id}" ("" "") ["object"] object) + (call "{object_consumer_peer_id}" ("" "") [object.$.non_exist_path]) ) - "#, - set_variable_peer_id, object_consumer_peer_id, - ); + "#); let init_peer_id = "asd"; let result = call_vm!(set_variable_vm, init_peer_id, &script, "", ""); diff --git a/air/tests/test_module/features/join_behaviour/mod.rs b/air/tests/test_module/features/join_behaviour/mod.rs new file mode 100644 index 00000000..659a0c4b --- /dev/null +++ b/air/tests/test_module/features/join_behaviour/mod.rs @@ -0,0 +1,17 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mod join_behaviour; diff --git a/air/tests/test_module/integration/flattening.rs b/air/tests/test_module/features/lambda/flattening.rs similarity index 89% rename from air/tests/test_module/integration/flattening.rs rename to air/tests/test_module/features/lambda/flattening.rs index 2f67ca46..6269e0b6 100644 --- a/air/tests/test_module/integration/flattening.rs +++ b/air/tests/test_module/features/lambda/flattening.rs @@ -58,10 +58,9 @@ 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 = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") [] scalar_array) + (call "{set_variable_peer_id}" ("" "") [] scalar_array) (fold scalar_array.$.iterable! v (seq (call v.$.peer_id! (v.$.service_id! v.$.function_name!) [v.$.args.[0]! v.$.args.[1]!]) @@ -69,9 +68,7 @@ fn flattening_scalar_arrays() { ) ) ) - "#, - set_variable_peer_id - ); + "#); let result = checked_call_vm!(set_variable_vm, "asd", script.clone(), "", ""); let result = call_vm!(local_vm, "asd", script.clone(), "", result.data); @@ -102,15 +99,14 @@ 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 = format!( - r#" + let script = f!(r#" (seq (seq (seq - (call "{0}" ("" "") [] $stream) - (call "{0}" ("" "") [] $stream) + (call "{set_variable_peer_id}" ("" "") [] $stream) + (call "{set_variable_peer_id}" ("" "") [] $stream) ) - (call "{0}" ("" "") [] $stream) + (call "{set_variable_peer_id}" ("" "") [] $stream) ) (fold $stream.$.[0,1,2] v (seq @@ -119,9 +115,7 @@ fn flattening_streams() { ) ) ) - "#, - set_variable_peer_id - ); + "#); let result = checked_call_vm!(set_variable_vm, "asd", script.clone(), "", ""); let result = call_vm!(local_vm, "asd", script.clone(), "", result.data); @@ -151,15 +145,12 @@ fn flattening_empty_values() { 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 = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") [] $stream) - (call "{1}" ("" "") [$stream.$.[1]!]) ; here $stream.$.[1] returns an empty array + (call "{set_variable_peer_id}" ("" "") [] $stream) + (call "{local_peer_id}" ("" "") [$stream.$.[1]!]) ; here $stream.$.[1] returns an empty array ) - "#, - set_variable_peer_id, local_peer_id - ); + "#); let result = checked_call_vm!(set_variable_vm, "asd", script.clone(), "", ""); let result = checked_call_vm!(local_vm, "asd", script.clone(), "", result.data); @@ -182,15 +173,14 @@ 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.clone()), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq (seq (seq - (call "{0}" ("" "") [] $stream) - (call "{0}" ("" "") [] $stream) + (call "{set_variable_peer_id}" ("" "") [] $stream) + (call "{set_variable_peer_id}" ("" "") [] $stream) ) - (call "{0}" ("" "") [] $stream) + (call "{set_variable_peer_id}" ("" "") [] $stream) ) (fold $stream.$.[0,1,2]! v (seq @@ -199,9 +189,7 @@ fn test_handling_non_flattening_values() { ) ) ) - "#, - set_variable_peer_id - ); + "#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let result = call_vm!(local_vm, "asd", &script, "", result.data); diff --git a/air/tests/test_module/integration/lambda.rs b/air/tests/test_module/features/lambda/lambda.rs similarity index 99% rename from air/tests/test_module/integration/lambda.rs rename to air/tests/test_module/features/lambda/lambda.rs index f58314e9..4e54ff1b 100644 --- a/air/tests/test_module/integration/lambda.rs +++ b/air/tests/test_module/features/lambda/lambda.rs @@ -18,9 +18,6 @@ use air::CatchableError; use air::LambdaError; use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] fn lambda_not_allowed_for_non_objects_and_arrays() { let set_variable_peer_id = "set_variable"; diff --git a/air/tests/test_module/features/lambda/mod.rs b/air/tests/test_module/features/lambda/mod.rs new file mode 100644 index 00000000..8f877f34 --- /dev/null +++ b/air/tests/test_module/features/lambda/mod.rs @@ -0,0 +1,18 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mod flattening; +mod lambda; diff --git a/air/tests/test_module/integration/empty_array.rs b/air/tests/test_module/features/misc/empty_array.rs similarity index 87% rename from air/tests/test_module/integration/empty_array.rs rename to air/tests/test_module/features/misc/empty_array.rs index 8d6d2a6c..64a2471b 100644 --- a/air/tests/test_module/integration/empty_array.rs +++ b/air/tests/test_module/features/misc/empty_array.rs @@ -21,14 +21,11 @@ fn empty_array() { let vm_peer_id = "some_peer_id"; let mut vm = create_avm(echo_call_service(), vm_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") [[]] result) - (call "{0}" ("" "") [result]) - )"#, - vm_peer_id - ); + (call "{vm_peer_id}" ("" "") [[]] result) + (call "{vm_peer_id}" ("" "") [result]) + )"#); let result = checked_call_vm!(vm, "", script, "", ""); let actual_trace = trace_from_result(&result); diff --git a/air/tests/test_module/features/misc/mod.rs b/air/tests/test_module/features/misc/mod.rs new file mode 100644 index 00000000..f601f5d6 --- /dev/null +++ b/air/tests/test_module/features/misc/mod.rs @@ -0,0 +1,17 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mod empty_array; diff --git a/air/tests/test_module/features/mod.rs b/air/tests/test_module/features/mod.rs new file mode 100644 index 00000000..261a5e1f --- /dev/null +++ b/air/tests/test_module/features/mod.rs @@ -0,0 +1,23 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mod data_merging; +mod errors; +mod join_behaviour; +mod lambda; +mod misc; +mod streams; +mod tetraplets; diff --git a/air/tests/test_module/integration/ap_with_fold.rs b/air/tests/test_module/features/streams/ap_with_fold.rs similarity index 88% rename from air/tests/test_module/integration/ap_with_fold.rs rename to air/tests/test_module/features/streams/ap_with_fold.rs index 9d64de6a..b975e862 100644 --- a/air/tests/test_module/integration/ap_with_fold.rs +++ b/air/tests/test_module/features/streams/ap_with_fold.rs @@ -1,5 +1,5 @@ /* - * Copyright 2020 Fluence Labs Limited + * Copyright 2022 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,9 @@ 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 = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") [] permutations) + (call "{set_variable_id}" ("" "") [] permutations) (seq (seq (fold permutations pair @@ -55,14 +54,12 @@ fn ap_with_fold() { ) ) (seq - (call "{1}" ("op" "noop") []) - (call "{1}" ("return" "") [$inner]) + (call "{local_vm_peer_id}" ("op" "noop") []) + (call "{local_vm_peer_id}" ("return" "") [$inner]) ) ) ) - "#, - set_variable_id, local_vm_peer_id, - ); + "#); let result = checked_call_vm!(set_variable_vm, "", &script, "", ""); assert_eq!(result.next_peer_pks, vec![local_vm_peer_id.to_string()]); diff --git a/air/tests/test_module/features/streams/mod.rs b/air/tests/test_module/features/streams/mod.rs new file mode 100644 index 00000000..582dbd56 --- /dev/null +++ b/air/tests/test_module/features/streams/mod.rs @@ -0,0 +1,20 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mod ap_with_fold; +mod recursive_streams; +mod streams; +mod streams_early_exit; diff --git a/air/tests/test_module/integration/recursive_streams.rs b/air/tests/test_module/features/streams/recursive_streams.rs similarity index 99% rename from air/tests/test_module/integration/recursive_streams.rs rename to air/tests/test_module/features/streams/recursive_streams.rs index c2125d14..e198ebee 100644 --- a/air/tests/test_module/integration/recursive_streams.rs +++ b/air/tests/test_module/features/streams/recursive_streams.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - use pretty_assertions::assert_eq; #[test] diff --git a/air/tests/test_module/integration/scripts/fold_early_exit.clj b/air/tests/test_module/features/streams/scripts/fold_early_exit.clj similarity index 100% rename from air/tests/test_module/integration/scripts/fold_early_exit.clj rename to air/tests/test_module/features/streams/scripts/fold_early_exit.clj diff --git a/air/tests/test_module/integration/scripts/fold_par_early_exit.clj b/air/tests/test_module/features/streams/scripts/fold_par_early_exit.clj similarity index 100% rename from air/tests/test_module/integration/scripts/fold_par_early_exit.clj rename to air/tests/test_module/features/streams/scripts/fold_par_early_exit.clj diff --git a/air/tests/test_module/integration/scripts/par_early_exit.clj b/air/tests/test_module/features/streams/scripts/par_early_exit.clj similarity index 100% rename from air/tests/test_module/integration/scripts/par_early_exit.clj rename to air/tests/test_module/features/streams/scripts/par_early_exit.clj diff --git a/air/tests/test_module/integration/scripts/stream_fold_merging_v0.clj b/air/tests/test_module/features/streams/scripts/stream_fold_merging_v0.clj similarity index 100% rename from air/tests/test_module/integration/scripts/stream_fold_merging_v0.clj rename to air/tests/test_module/features/streams/scripts/stream_fold_merging_v0.clj diff --git a/air/tests/test_module/integration/scripts/stream_fold_merging_v1.clj b/air/tests/test_module/features/streams/scripts/stream_fold_merging_v1.clj similarity index 100% rename from air/tests/test_module/integration/scripts/stream_fold_merging_v1.clj rename to air/tests/test_module/features/streams/scripts/stream_fold_merging_v1.clj diff --git a/air/tests/test_module/integration/scripts/stream_fold_merging_v2.clj b/air/tests/test_module/features/streams/scripts/stream_fold_merging_v2.clj similarity index 100% rename from air/tests/test_module/integration/scripts/stream_fold_merging_v2.clj rename to air/tests/test_module/features/streams/scripts/stream_fold_merging_v2.clj diff --git a/air/tests/test_module/integration/streams.rs b/air/tests/test_module/features/streams/streams.rs similarity index 100% rename from air/tests/test_module/integration/streams.rs rename to air/tests/test_module/features/streams/streams.rs diff --git a/air/tests/test_module/integration/streams_early_exit.rs b/air/tests/test_module/features/streams/streams_early_exit.rs similarity index 100% rename from air/tests/test_module/integration/streams_early_exit.rs rename to air/tests/test_module/features/streams/streams_early_exit.rs diff --git a/air/tests/test_module/features/tetraplets/mod.rs b/air/tests/test_module/features/tetraplets/mod.rs new file mode 100644 index 00000000..1b3605ca --- /dev/null +++ b/air/tests/test_module/features/tetraplets/mod.rs @@ -0,0 +1,17 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mod security_tetraplets; diff --git a/air/tests/test_module/integration/security_tetraplets.rs b/air/tests/test_module/features/tetraplets/security_tetraplets.rs similarity index 97% rename from air/tests/test_module/integration/security_tetraplets.rs rename to air/tests/test_module/features/tetraplets/security_tetraplets.rs index f7b2a12b..cb9ac60a 100644 --- a/air/tests/test_module/integration/security_tetraplets.rs +++ b/air/tests/test_module/features/tetraplets/security_tetraplets.rs @@ -17,9 +17,6 @@ use air::SecurityTetraplet; use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - use std::cell::RefCell; use std::rc::Rc; @@ -275,15 +272,12 @@ fn tetraplet_with_wasm_modules() { }); let local_peer_id = "local_peer_id"; - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("auth" "is_authorized") [] auth_result) - (call "{0}" ("log_storage" "delete") [auth_result.$.is_authorized "1"]) + (call "{local_peer_id}" ("auth" "is_authorized") [] auth_result) + (call "{local_peer_id}" ("log_storage" "delete") [auth_result.$.is_authorized "1"]) ) - "#, - local_peer_id, - ); + "#); let mut vm = create_avm(host_func, local_peer_id); diff --git a/air/tests/test_module/integration/security_tetraplets/auth_module/Cargo.lock b/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.lock similarity index 80% rename from air/tests/test_module/integration/security_tetraplets/auth_module/Cargo.lock rename to air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.lock index 6d48596f..1fb5d73a 100644 --- a/air/tests/test_module/integration/security_tetraplets/auth_module/Cargo.lock +++ b/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.lock @@ -13,25 +13,37 @@ dependencies = [ [[package]] name = "air" -version = "0.10.0" +version = "0.21.0" dependencies = [ + "air-execution-info-collector", "air-interpreter-data", "air-interpreter-interface", + "air-lambda-ast", + "air-lambda-parser", + "air-log-targets", "air-parser", + "air-trace-handler", "boolinator", - "fluence", - "jsonpath_lib-fl", + "concat-idents", "log", - "polyplets", + "maplit", + "marine-rs-sdk", + "polyplets 0.2.0", "serde", "serde_json", + "strum", + "strum_macros", "thiserror", "wasm-bindgen", ] [[package]] -name = "air-interpreter-data" +name = "air-execution-info-collector" version = "0.1.0" + +[[package]] +name = "air-interpreter-data" +version = "0.2.2" dependencies = [ "once_cell", "semver", @@ -41,17 +53,28 @@ dependencies = [ [[package]] name = "air-interpreter-interface" -version = "0.5.1" +version = "0.8.0" dependencies = [ - "fluence", "fluence-it-types", + "marine-rs-sdk", "serde", + "serde_json", ] [[package]] -name = "air-parser" -version = "0.7.0" +name = "air-lambda-ast" +version = "0.1.0" dependencies = [ + "non-empty-vec", + "serde", + "serde_json", +] + +[[package]] +name = "air-lambda-parser" +version = "0.1.0" +dependencies = [ + "air-lambda-ast", "codespan", "codespan-reporting", "itertools", @@ -65,28 +88,44 @@ dependencies = [ ] [[package]] -name = "array_tool" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271" +name = "air-log-targets" +version = "0.1.0" [[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +name = "air-parser" +version = "0.7.1" +dependencies = [ + "air-lambda-ast", + "air-lambda-parser", + "codespan", + "codespan-reporting", + "itertools", + "lalrpop", + "lalrpop-util", + "multimap", + "regex", + "serde", + "serde_json", + "thiserror", +] [[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +name = "air-trace-handler" +version = "0.1.0" +dependencies = [ + "air-interpreter-data", + "air-log-targets", + "air-parser", + "log", + "serde_json", + "thiserror", +] [[package]] name = "ascii-canvas" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8eb72df928aafb99fe5d37b383f2fe25bd2a765e3e5f7c365916b6f2463a29" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" dependencies = [ "term", ] @@ -107,7 +146,7 @@ name = "auth_module" version = "0.1.0" dependencies = [ "air", - "fluence", + "marine-rs-sdk", ] [[package]] @@ -116,12 +155,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - [[package]] name = "bit-set" version = "0.5.2" @@ -138,15 +171,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] -name = "blake2b_simd" -version = "0.5.11" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "boolinator" @@ -160,12 +188,6 @@ version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - [[package]] name = "cfg-if" version = "0.1.10" @@ -193,38 +215,31 @@ dependencies = [ [[package]] name = "codespan" -version = "0.9.5" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ebaf6bb6a863ad6aa3a18729e9710c53d75df03306714d9cc1f7357a00cd789" +checksum = "3362992a0d9f1dd7c3d0e89e0ab2bb540b7a95fea8cd798090e758fda2899b5e" dependencies = [ "codespan-reporting", ] [[package]] name = "codespan-reporting" -version = "0.9.5" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0762455306b1ed42bc651ef6a2197aabda5e1d4a43c34d5eab5c1a3634e81d" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ "termcolor", "unicode-width", ] [[package]] -name = "constant_time_eq" -version = "0.1.5" +name = "concat-idents" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "crossbeam-utils" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" +checksum = "4b6f90860248d75014b7b103db8fee4f291c07bfb41306cdf77a0a5ab7a10d2f" dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "lazy_static", + "quote", + "syn", ] [[package]] @@ -240,10 +255,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" [[package]] -name = "dirs" -version = "1.0.5" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", @@ -265,37 +290,12 @@ dependencies = [ "log", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "fixedbitset" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" -[[package]] -name = "fluence" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b09e1cd11a51ba4d169db347d009fe41ece2714eef4d5df720343733a1d5a6" -dependencies = [ - "fluence-sdk-main", - "marine-macro", - "marine-timestamp-macro", - "serde", -] - [[package]] name = "fluence-it-types" version = "0.3.0" @@ -306,28 +306,6 @@ dependencies = [ "serde", ] -[[package]] -name = "fluence-sdk-main" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68d93cde99e1494e11755a39b93863333397245c9959c774fe3bebd9e4143879" -dependencies = [ - "log", - "marine-macro", - "serde", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.2" @@ -336,7 +314,7 @@ checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -345,6 +323,15 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "hermit-abi" version = "0.1.18" @@ -354,15 +341,6 @@ dependencies = [ "libc", ] -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "indexmap" version = "1.6.2" @@ -390,28 +368,15 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" - -[[package]] -name = "jsonpath_lib-fl" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33dcf980221b25366e8f0df601cf0df6ffcc97242cbbe4d139a79a7f0de5107f" -dependencies = [ - "array_tool", - "env_logger", - "log", - "serde", - "serde_json", -] +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "lalrpop" -version = "0.19.5" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46962a8c71b91c3524b117dfdd70844d4265a173c4c9109f98171aebdcf1195f" +checksum = "852b75a095da6b69da8c5557731c3afd06525d4f655a4fc1c799e2ec8bc4dce4" dependencies = [ "ascii-canvas", "atty", @@ -432,9 +397,9 @@ dependencies = [ [[package]] name = "lalrpop-util" -version = "0.19.5" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a708007b751af124d09e9c5d97515257902bc6b486a56b40bcafd939e8ff467" +checksum = "d6d265705249fe209280676d8f68887859fa42e1d34f342fc05bd47726a5e188" dependencies = [ "regex", ] @@ -461,19 +426,26 @@ dependencies = [ ] [[package]] -name = "marine-macro" -version = "0.6.9" +name = "maplit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63d927851847cc3dd9e3bd0f10bdeb313859d4822d5b5f650d9d34d461ed419" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "marine-macro" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc907943772cf966ebe2a2d462d09bc79e898ef102ed065ba3d3abcc93fbb71" dependencies = [ "marine-macro-impl", + "marine-rs-sdk-main", ] [[package]] name = "marine-macro-impl" -version = "0.6.9" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb504be4a90e229ab453c7369cc8a9063acec819f3397802eea719cd0a232be1" +checksum = "bfdbed3a10ae9b22df06bee8cd0023255358935aae8e8daf9d1a006cfaeeb11e" dependencies = [ "proc-macro2", "quote", @@ -484,10 +456,33 @@ dependencies = [ ] [[package]] -name = "marine-timestamp-macro" -version = "0.6.9" +name = "marine-rs-sdk" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5994c7db5567d21609f2a2e5a40d9d4564f86c17ca35b2d77007152619b9d7fc" +checksum = "4d17d44016675abdf18caf3ac1bdd4437cc17ec0db019da141bb06a9ea991726" +dependencies = [ + "marine-macro", + "marine-rs-sdk-main", + "marine-timestamp-macro", + "polyplets 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", +] + +[[package]] +name = "marine-rs-sdk-main" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ff262801664ce22f9d274504d6e8088c217034aba0ca431eca8d0258f3699c6" +dependencies = [ + "log", + "serde", +] + +[[package]] +name = "marine-timestamp-macro" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85a9f5b1adeff98ac5a14cfc5fa814185a807ba4a0d3849c9f9e9fd868b27d1f" dependencies = [ "chrono", "quote", @@ -514,6 +509,15 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "non-empty-vec" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceeba69aa8d4c53cdceeac8f17eb2656bb88b468bbe6c0889d34edfdea26ec8b" +dependencies = [ + "serde", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -566,9 +570,21 @@ checksum = "7d7afeb98c5a10e0bffcc7fc16e105b04d06729fac5fd6384aebf7ff5cb5a67d" [[package]] name = "polyplets" -version = "0.1.1" +version = "0.2.0" dependencies = [ - "fluence", + "marine-macro", + "marine-rs-sdk-main", + "serde", +] + +[[package]] +name = "polyplets" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cc56e7803860fa903c27675a17215e1cfb39fb26e111c0b93f6c049f9cf8d8e" +dependencies = [ + "marine-macro", + "marine-rs-sdk-main", "serde", ] @@ -587,12 +603,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" version = "1.0.9" @@ -604,19 +614,21 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" +dependencies = [ + "bitflags", +] [[package]] name = "redox_users" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.1.16", + "getrandom", "redox_syscall", - "rust-argon2", ] [[package]] @@ -637,16 +649,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] -name = "rust-argon2" -version = "0.8.3" +name = "rustversion" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" -dependencies = [ - "base64", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils", -] +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" [[package]] name = "ryu" @@ -685,11 +691,10 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.61" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ - "indexmap", "itoa", "ryu", "serde", @@ -714,10 +719,28 @@ dependencies = [ ] [[package]] -name = "syn" -version = "1.0.72" +name = "strum" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "aaf86bbcfd1fa9670b7a129f64fc0c9fcbbfe4f1bc4210e9e98fe71ffc12cde2" + +[[package]] +name = "strum_macros" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" dependencies = [ "proc-macro2", "quote", @@ -726,12 +749,12 @@ dependencies = [ [[package]] name = "term" -version = "0.5.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" dependencies = [ - "byteorder", - "dirs", + "dirs-next", + "rustversion", "winapi", ] @@ -746,18 +769,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.24" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.24" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -771,7 +794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi", "winapi", ] @@ -784,6 +807,12 @@ dependencies = [ "crunchy", ] +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + [[package]] name = "unicode-width" version = "0.1.8" @@ -802,15 +831,9 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.2", + "getrandom", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" diff --git a/air/tests/test_module/integration/security_tetraplets/auth_module/Cargo.toml b/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.toml similarity index 81% rename from air/tests/test_module/integration/security_tetraplets/auth_module/Cargo.toml rename to air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.toml index 3213e98c..2a6cae86 100644 --- a/air/tests/test_module/integration/security_tetraplets/auth_module/Cargo.toml +++ b/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.toml @@ -9,7 +9,7 @@ name = "auth_module" path = "src/main.rs" [dependencies] -air = { path = "../../../../../../air" } +air = { path = "../../../../../../../air" } marine-rs-sdk = "0.6.15" [workspace] diff --git a/air/tests/test_module/integration/security_tetraplets/auth_module/src/main.rs b/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/src/main.rs similarity index 100% rename from air/tests/test_module/integration/security_tetraplets/auth_module/src/main.rs rename to air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/src/main.rs diff --git a/air/tests/test_module/integration/security_tetraplets/log_storage/Cargo.lock b/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.lock similarity index 80% rename from air/tests/test_module/integration/security_tetraplets/log_storage/Cargo.lock rename to air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.lock index a5f65aca..e5e6d3c6 100644 --- a/air/tests/test_module/integration/security_tetraplets/log_storage/Cargo.lock +++ b/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.lock @@ -13,25 +13,37 @@ dependencies = [ [[package]] name = "air" -version = "0.10.0" +version = "0.21.0" dependencies = [ + "air-execution-info-collector", "air-interpreter-data", "air-interpreter-interface", + "air-lambda-ast", + "air-lambda-parser", + "air-log-targets", "air-parser", + "air-trace-handler", "boolinator", - "fluence", - "jsonpath_lib-fl", + "concat-idents", "log", - "polyplets", + "maplit", + "marine-rs-sdk", + "polyplets 0.2.0", "serde", "serde_json", + "strum", + "strum_macros", "thiserror", "wasm-bindgen", ] [[package]] -name = "air-interpreter-data" +name = "air-execution-info-collector" version = "0.1.0" + +[[package]] +name = "air-interpreter-data" +version = "0.2.2" dependencies = [ "once_cell", "semver", @@ -41,17 +53,28 @@ dependencies = [ [[package]] name = "air-interpreter-interface" -version = "0.5.1" +version = "0.8.0" dependencies = [ - "fluence", "fluence-it-types", + "marine-rs-sdk", "serde", + "serde_json", ] [[package]] -name = "air-parser" -version = "0.7.0" +name = "air-lambda-ast" +version = "0.1.0" dependencies = [ + "non-empty-vec", + "serde", + "serde_json", +] + +[[package]] +name = "air-lambda-parser" +version = "0.1.0" +dependencies = [ + "air-lambda-ast", "codespan", "codespan-reporting", "itertools", @@ -65,28 +88,44 @@ dependencies = [ ] [[package]] -name = "array_tool" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271" +name = "air-log-targets" +version = "0.1.0" [[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +name = "air-parser" +version = "0.7.1" +dependencies = [ + "air-lambda-ast", + "air-lambda-parser", + "codespan", + "codespan-reporting", + "itertools", + "lalrpop", + "lalrpop-util", + "multimap", + "regex", + "serde", + "serde_json", + "thiserror", +] [[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +name = "air-trace-handler" +version = "0.1.0" +dependencies = [ + "air-interpreter-data", + "air-log-targets", + "air-parser", + "log", + "serde_json", + "thiserror", +] [[package]] name = "ascii-canvas" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8eb72df928aafb99fe5d37b383f2fe25bd2a765e3e5f7c365916b6f2463a29" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" dependencies = [ "term", ] @@ -108,12 +147,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - [[package]] name = "bit-set" version = "0.5.2" @@ -130,15 +163,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] -name = "blake2b_simd" -version = "0.5.11" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "boolinator" @@ -152,12 +180,6 @@ version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - [[package]] name = "cfg-if" version = "0.1.10" @@ -185,38 +207,31 @@ dependencies = [ [[package]] name = "codespan" -version = "0.9.5" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ebaf6bb6a863ad6aa3a18729e9710c53d75df03306714d9cc1f7357a00cd789" +checksum = "3362992a0d9f1dd7c3d0e89e0ab2bb540b7a95fea8cd798090e758fda2899b5e" dependencies = [ "codespan-reporting", ] [[package]] name = "codespan-reporting" -version = "0.9.5" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0762455306b1ed42bc651ef6a2197aabda5e1d4a43c34d5eab5c1a3634e81d" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ "termcolor", "unicode-width", ] [[package]] -name = "constant_time_eq" -version = "0.1.5" +name = "concat-idents" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "crossbeam-utils" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" +checksum = "4b6f90860248d75014b7b103db8fee4f291c07bfb41306cdf77a0a5ab7a10d2f" dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "lazy_static", + "quote", + "syn", ] [[package]] @@ -232,10 +247,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" [[package]] -name = "dirs" -version = "1.0.5" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", @@ -257,37 +282,12 @@ dependencies = [ "log", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "fixedbitset" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" -[[package]] -name = "fluence" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b09e1cd11a51ba4d169db347d009fe41ece2714eef4d5df720343733a1d5a6" -dependencies = [ - "fluence-sdk-main", - "marine-macro", - "marine-timestamp-macro", - "serde", -] - [[package]] name = "fluence-it-types" version = "0.3.0" @@ -298,28 +298,6 @@ dependencies = [ "serde", ] -[[package]] -name = "fluence-sdk-main" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68d93cde99e1494e11755a39b93863333397245c9959c774fe3bebd9e4143879" -dependencies = [ - "log", - "marine-macro", - "serde", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.2" @@ -328,7 +306,7 @@ checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -337,6 +315,15 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "hermit-abi" version = "0.1.18" @@ -346,15 +333,6 @@ dependencies = [ "libc", ] -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "indexmap" version = "1.6.2" @@ -382,28 +360,15 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" - -[[package]] -name = "jsonpath_lib-fl" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33dcf980221b25366e8f0df601cf0df6ffcc97242cbbe4d139a79a7f0de5107f" -dependencies = [ - "array_tool", - "env_logger", - "log", - "serde", - "serde_json", -] +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "lalrpop" -version = "0.19.5" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46962a8c71b91c3524b117dfdd70844d4265a173c4c9109f98171aebdcf1195f" +checksum = "852b75a095da6b69da8c5557731c3afd06525d4f655a4fc1c799e2ec8bc4dce4" dependencies = [ "ascii-canvas", "atty", @@ -424,9 +389,9 @@ dependencies = [ [[package]] name = "lalrpop-util" -version = "0.19.5" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a708007b751af124d09e9c5d97515257902bc6b486a56b40bcafd939e8ff467" +checksum = "d6d265705249fe209280676d8f68887859fa42e1d34f342fc05bd47726a5e188" dependencies = [ "regex", ] @@ -457,23 +422,30 @@ name = "log_storage" version = "0.1.0" dependencies = [ "air", - "fluence", + "marine-rs-sdk", ] [[package]] -name = "marine-macro" -version = "0.6.9" +name = "maplit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63d927851847cc3dd9e3bd0f10bdeb313859d4822d5b5f650d9d34d461ed419" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "marine-macro" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc907943772cf966ebe2a2d462d09bc79e898ef102ed065ba3d3abcc93fbb71" dependencies = [ "marine-macro-impl", + "marine-rs-sdk-main", ] [[package]] name = "marine-macro-impl" -version = "0.6.9" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb504be4a90e229ab453c7369cc8a9063acec819f3397802eea719cd0a232be1" +checksum = "bfdbed3a10ae9b22df06bee8cd0023255358935aae8e8daf9d1a006cfaeeb11e" dependencies = [ "proc-macro2", "quote", @@ -484,10 +456,33 @@ dependencies = [ ] [[package]] -name = "marine-timestamp-macro" -version = "0.6.9" +name = "marine-rs-sdk" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5994c7db5567d21609f2a2e5a40d9d4564f86c17ca35b2d77007152619b9d7fc" +checksum = "4d17d44016675abdf18caf3ac1bdd4437cc17ec0db019da141bb06a9ea991726" +dependencies = [ + "marine-macro", + "marine-rs-sdk-main", + "marine-timestamp-macro", + "polyplets 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", +] + +[[package]] +name = "marine-rs-sdk-main" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ff262801664ce22f9d274504d6e8088c217034aba0ca431eca8d0258f3699c6" +dependencies = [ + "log", + "serde", +] + +[[package]] +name = "marine-timestamp-macro" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85a9f5b1adeff98ac5a14cfc5fa814185a807ba4a0d3849c9f9e9fd868b27d1f" dependencies = [ "chrono", "quote", @@ -514,6 +509,15 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "non-empty-vec" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceeba69aa8d4c53cdceeac8f17eb2656bb88b468bbe6c0889d34edfdea26ec8b" +dependencies = [ + "serde", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -566,9 +570,21 @@ checksum = "7d7afeb98c5a10e0bffcc7fc16e105b04d06729fac5fd6384aebf7ff5cb5a67d" [[package]] name = "polyplets" -version = "0.1.1" +version = "0.2.0" dependencies = [ - "fluence", + "marine-macro", + "marine-rs-sdk-main", + "serde", +] + +[[package]] +name = "polyplets" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cc56e7803860fa903c27675a17215e1cfb39fb26e111c0b93f6c049f9cf8d8e" +dependencies = [ + "marine-macro", + "marine-rs-sdk-main", "serde", ] @@ -587,12 +603,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" version = "1.0.9" @@ -604,19 +614,21 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" +dependencies = [ + "bitflags", +] [[package]] name = "redox_users" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.1.16", + "getrandom", "redox_syscall", - "rust-argon2", ] [[package]] @@ -637,16 +649,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] -name = "rust-argon2" -version = "0.8.3" +name = "rustversion" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" -dependencies = [ - "base64", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils", -] +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" [[package]] name = "ryu" @@ -685,11 +691,10 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.61" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ - "indexmap", "itoa", "ryu", "serde", @@ -714,10 +719,28 @@ dependencies = [ ] [[package]] -name = "syn" -version = "1.0.72" +name = "strum" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "aaf86bbcfd1fa9670b7a129f64fc0c9fcbbfe4f1bc4210e9e98fe71ffc12cde2" + +[[package]] +name = "strum_macros" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" dependencies = [ "proc-macro2", "quote", @@ -726,12 +749,12 @@ dependencies = [ [[package]] name = "term" -version = "0.5.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" dependencies = [ - "byteorder", - "dirs", + "dirs-next", + "rustversion", "winapi", ] @@ -746,18 +769,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.24" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.24" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -771,7 +794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi", "winapi", ] @@ -784,6 +807,12 @@ dependencies = [ "crunchy", ] +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + [[package]] name = "unicode-width" version = "0.1.8" @@ -802,15 +831,9 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.2", + "getrandom", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" diff --git a/air/tests/test_module/integration/security_tetraplets/log_storage/Cargo.toml b/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.toml similarity index 81% rename from air/tests/test_module/integration/security_tetraplets/log_storage/Cargo.toml rename to air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.toml index 12a00565..76c853df 100644 --- a/air/tests/test_module/integration/security_tetraplets/log_storage/Cargo.toml +++ b/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.toml @@ -9,7 +9,7 @@ name = "log_storage" path = "src/main.rs" [dependencies] -air = { path = "../../../../../../air" } +air = { path = "../../../../../../../air" } marine-rs-sdk = "0.6.15" [workspace] diff --git a/air/tests/test_module/integration/security_tetraplets/log_storage/src/main.rs b/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/src/main.rs similarity index 100% rename from air/tests/test_module/integration/security_tetraplets/log_storage/src/main.rs rename to air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/src/main.rs diff --git a/air/tests/test_module/instructions/ap.rs b/air/tests/test_module/instructions/ap.rs index 69c557f1..b5f88b14 100644 --- a/air/tests/test_module/instructions/ap.rs +++ b/air/tests/test_module/instructions/ap.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] fn ap_with_scalars() { let vm_1_peer_id = "vm_1_peer_id"; @@ -28,18 +25,15 @@ 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 = format!( - r#" + let script = f!(r#" (seq (seq - (call "{}" ("" "") ["scalar_1_result"] scalar_1) + (call "{vm_1_peer_id}" ("" "") ["scalar_1_result"] scalar_1) (ap scalar_1.$.field! scalar_2) ) - (call "{}" ("" "") [scalar_2]) + (call "{vm_2_peer_id}" ("" "") [scalar_2]) ) - "#, - vm_1_peer_id, vm_2_peer_id - ); + "#); let result = checked_call_vm!(vm_1, "", &script, "", ""); let result = checked_call_vm!(vm_2, "", script, "", result.data); @@ -84,15 +78,12 @@ 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 = format!( - r#" + let script = f!(r#" (seq (ap true $stream) - (call "{}" ("" "") [$stream]) + (call "{vm_1_peer_id}" ("" "") [$stream]) ) - "#, - vm_1_peer_id - ); + "#); let result = checked_call_vm!(vm_1, "", script, "", ""); @@ -108,15 +99,12 @@ 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 = format!( - r#" + let script = f!(r#" (seq (ap 100 $stream) - (call "{}" ("" "") [$stream]) + (call "{vm_1_peer_id}" ("" "") [$stream]) ) - "#, - vm_1_peer_id - ); + "#); let result = checked_call_vm!(vm_1, "", script, "", ""); @@ -132,15 +120,12 @@ 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 = format!( - r#" + let script = f!(r#" (seq (ap %last_error% $stream) - (call "{}" ("" "") [$stream]) + (call "{vm_1_peer_id}" ("" "") [$stream]) ) - "#, - vm_1_peer_id - ); + "#); let result = checked_call_vm!(vm_1, "", script, "", ""); diff --git a/air/tests/test_module/instructions/call.rs b/air/tests/test_module/instructions/call.rs index e3360a74..5f34750d 100644 --- a/air/tests/test_module/instructions/call.rs +++ b/air/tests/test_module/instructions/call.rs @@ -17,9 +17,6 @@ use air::UncatchableError; use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - // Check that %init_peer_id% alias works correctly (by comparing result with it and explicit peer id). // Additionally, check that empty string for data does the same as empty call path. #[test] @@ -29,12 +26,9 @@ fn current_peer_id_call() { let service_id = "local_service_id"; let function_name = "local_fn_name"; - let script = format!( - r#" - (call %init_peer_id% ("{}" "{}") [] result_name) - "#, - service_id, function_name - ); + let script = f!(r#" + (call %init_peer_id% ("{service_id}" "{function_name}") [] result_name) + "#); let result = checked_call_vm!(vm, vm_peer_id, script, "", ""); @@ -44,12 +38,9 @@ fn current_peer_id_call() { assert_eq!(actual_trace, expected_trace); assert!(result.next_peer_pks.is_empty()); - let script = format!( - r#" - (call "{}" ("{}" "{}") [] result_name) - "#, - vm_peer_id, service_id, function_name - ); + let script = f!(r#" + (call "{vm_peer_id}" ("{service_id}" "{function_name}") [] result_name) + "#); let result = checked_call_vm!(vm, "asd", script.clone(), "", ""); @@ -65,10 +56,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 = format!( - r#"(call "{}" ("local_service_id" "local_fn_name") ["arg"] result_name)"#, - remote_peer_id - ); + let script = f!(r#"(call "{remote_peer_id}" ("local_service_id" "local_fn_name") ["arg"] result_name)"#); let result = checked_call_vm!(vm, "asd", script, "", ""); @@ -134,15 +122,12 @@ fn string_parameters() { let service_id = "some_service_id"; let function_name = "local_fn_name"; - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("{1}" "{2}") [] arg3) - (call "{3}" ("{1}" "{2}") ["arg1" "arg2" arg3] result) + (call "{set_variable_vm_peer_id}" ("{service_id}" "{function_name}") [] arg3) + (call "{vm_peer_id}" ("{service_id}" "{function_name}") ["arg1" "arg2" arg3] result) ) - "#, - set_variable_vm_peer_id, service_id, function_name, vm_peer_id - ); + "#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let result = checked_call_vm!(vm, "asd", script, "", result.data); diff --git a/air/tests/test_module/instructions/fail.rs b/air/tests/test_module/instructions/fail.rs index 7ff58e95..4ea744aa 100644 --- a/air/tests/test_module/instructions/fail.rs +++ b/air/tests/test_module/instructions/fail.rs @@ -17,9 +17,6 @@ use air::CatchableError; use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] fn fail_with_last_error() { let local_peer_id = "local_peer_id"; @@ -50,13 +47,11 @@ fn fail_with_literals() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = r#" (xor (fail 1337 "error message") (fail %last_error%) - )"#, - ); + )"#; let init_peer_id = "init_peer_id"; let result = call_vm!(vm, init_peer_id, script, "", ""); diff --git a/air/tests/test_module/instructions/fold.rs b/air/tests/test_module/instructions/fold.rs index c079f634..3ac4064b 100644 --- a/air/tests/test_module/instructions/fold.rs +++ b/air/tests/test_module/instructions/fold.rs @@ -14,7 +14,8 @@ * limitations under the License. */ -use air::{PreparationError, ToErrorCode}; +use air::PreparationError; +use air::ToErrorCode; use air_test_utils::prelude::*; #[test] diff --git a/air/tests/test_module/instructions/match_.rs b/air/tests/test_module/instructions/match_.rs index efe36276..afc5ffbf 100644 --- a/air/tests/test_module/instructions/match_.rs +++ b/air/tests/test_module/instructions/match_.rs @@ -25,22 +25,19 @@ fn match_equal() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq (seq - (call "{0}" ("" "") ["value_1"] value_1) - (call "{0}" ("" "") ["value_1"] value_2) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_1) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_2) ) (xor (match value_1 value_2 - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - (call "{1}" ("service_id_2" "local_fn_name") ["result_2"] result_2) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let result = checked_call_vm!(vm, "asd", script, "", result.data); @@ -60,22 +57,19 @@ fn match_not_equal() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq (seq - (call "{0}" ("" "") ["value_1"] value_1) - (call "{0}" ("" "") ["value_2"] value_2) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_1) + (call "{set_variable_peer_id}" ("" "") ["value_2"] value_2) ) (xor (match value_1 value_2 - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - (call "{1}" ("service_id_2" "local_fn_name") ["result_2"] result_2) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let result = checked_call_vm!(vm, "asd", script, "", result.data); @@ -95,19 +89,16 @@ fn match_with_string() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") ["value_1"] value_1) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_1) (xor (match value_1 "value_1" - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - (call "{1}" ("service_id_2" "local_fn_name") ["result_2"] result_2) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let result = checked_call_vm!(vm, "asd", script, "", result.data); @@ -127,19 +118,16 @@ 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 = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") ["{1}"] value_1) + (call "{set_variable_peer_id}" ("" "") ["{local_peer_id}"] value_1) (xor (match value_1 %init_peer_id% - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - (call "{1}" ("service_id_2" "local_fn_name") ["result_2"] result_2) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = checked_call_vm!(set_variable_vm, local_peer_id, &script, "", ""); let result = checked_call_vm!(vm, local_peer_id, script, "", result.data); @@ -177,19 +165,16 @@ fn match_without_xor() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq (seq - (call "{0}" ("" "") ["value_1"] value_1) - (call "{0}" ("" "") ["value_2"] value_2) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_1) + (call "{set_variable_peer_id}" ("" "") ["value_2"] value_2) ) (match value_1 value_2 - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = call_vm!(set_variable_vm, "", &script, "", ""); let result = call_vm!(vm, "", &script, "", result.data); @@ -210,26 +195,23 @@ fn match_with_two_xors() { let local_peer_id_2 = "local_peer_id_2"; - let script = format!( - r#" + let script = f!(r#" (xor (seq (seq - (call "{0}" ("getDataSrv" "condition") [] condition) - (call "{0}" ("getDataSrv" "relay") [] relay) + (call "{local_peer_id}" ("getDataSrv" "condition") [] condition) + (call "{local_peer_id}" ("getDataSrv" "relay") [] relay) ) (xor (match condition true - (call "{0}" ("println" "print") ["it is true"]) + (call "{local_peer_id}" ("println" "print") ["it is true"]) ) - (call "{1}" ("println" "print") ["it is false"]) + (call "{local_peer_id_2}" ("println" "print") ["it is false"]) ) ) - (call "{0}" ("errorHandlingSrv" "error") [%last_error%]) + (call "{local_peer_id}" ("errorHandlingSrv" "error") [%last_error%]) ) - "#, - local_peer_id, local_peer_id_2 - ); + "#); let result = checked_call_vm!(vm, "", script, "", ""); @@ -251,10 +233,9 @@ fn issue_165() { let echo_peer_id = "echo_peer_id"; let mut echo_peer = create_avm(echo_call_service(), echo_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") ["set_result"] result) + (call "{result_setter_peer_id}" ("" "") ["set_result"] result) (seq (xor (match result.$.success! true @@ -262,12 +243,10 @@ fn issue_165() { ) (ap 2 $results) ) - (call "{1}" ("callbackSrv" "response") [$results.$.[0]!]) + (call "{echo_peer_id}" ("callbackSrv" "response") [$results.$.[0]!]) ) ) - "#, - result_setter_peer_id, echo_peer_id - ); + "#); let setter_result = checked_call_vm!(result_setter, "", &script, "", ""); let echo_result = checked_call_vm!(echo_peer, "", &script, "", setter_result.data); diff --git a/air/tests/test_module/instructions/mismatch.rs b/air/tests/test_module/instructions/mismatch.rs index 3a1b266b..af59ae53 100644 --- a/air/tests/test_module/instructions/mismatch.rs +++ b/air/tests/test_module/instructions/mismatch.rs @@ -25,22 +25,19 @@ fn mismatch_equal() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq (seq - (call "{0}" ("" "") ["value_1"] value_1) - (call "{0}" ("" "") ["value_1"] value_2) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_1) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_2) ) (xor (mismatch value_1 value_2 - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - (call "{1}" ("service_id_2" "local_fn_name") ["result_2"] result_2) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let result = checked_call_vm!(vm, "asd", script, "", result.data); @@ -60,22 +57,19 @@ fn mismatch_not_equal() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq (seq - (call "{0}" ("" "") ["value_1"] value_1) - (call "{0}" ("" "") ["value_2"] value_2) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_1) + (call "{set_variable_peer_id}" ("" "") ["value_2"] value_2) ) (xor (mismatch value_1 value_2 - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - (call "{1}" ("service_id_2" "local_fn_name") ["result_2"] result_2) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let result = checked_call_vm!(vm, "asd", script, "", result.data); @@ -95,19 +89,16 @@ fn mismatch_with_string() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") ["value_1"] value_1) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_1) (xor (mismatch value_1 "value_1" - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - (call "{1}" ("service_id_2" "local_fn_name") ["result_2"] result_2) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = checked_call_vm!(set_variable_vm, "asd", &script, "", ""); let result = checked_call_vm!(vm, "asd", script, "", result.data); @@ -127,19 +118,16 @@ fn mismatch_without_xor() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq (seq - (call "{0}" ("" "") ["value_1"] value_1) - (call "{0}" ("" "") ["value_1"] value_2) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_1) + (call "{set_variable_peer_id}" ("" "") ["value_1"] value_2) ) (mismatch value_1 value_2 - (call "{1}" ("service_id_2" "local_fn_name") ["result_1"] result_1) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1) ) - )"#, - set_variable_peer_id, local_peer_id - ); + )"#); let result = call_vm!(set_variable_vm, "asd", &script, "", ""); let result = call_vm!(vm, "asd", &script, "", result.data); @@ -160,26 +148,23 @@ fn mismatch_with_two_xors() { let local_peer_id_2 = "local_peer_id_2"; - let script = format!( - r#" + let script = f!(r#" (xor (seq (seq - (call "{0}" ("getDataSrv" "condition") [] condition) - (call "{0}" ("getDataSrv" "relay") [] relay) + (call "{local_peer_id}" ("getDataSrv" "condition") [] condition) + (call "{local_peer_id}" ("getDataSrv" "relay") [] relay) ) (xor (mismatch condition true - (call "{1}" ("println" "print") ["it is false"]) + (call "{local_peer_id_2}" ("println" "print") ["it is false"]) ) - (call "{0}" ("println" "print") ["it is true"]) + (call "{local_peer_id}" ("println" "print") ["it is true"]) ) ) - (call "{0}" ("errorHandlingSrv" "error") [%last_error%]) + (call "{local_peer_id}" ("errorHandlingSrv" "error") [%last_error%]) ) - "#, - local_peer_id, local_peer_id_2 - ); + "#); let result = checked_call_vm!(vm, "", script, "", ""); diff --git a/air/tests/test_module/instructions/new.rs b/air/tests/test_module/instructions/new.rs index 6bb5ea2b..acec0714 100644 --- a/air/tests/test_module/instructions/new.rs +++ b/air/tests/test_module/instructions/new.rs @@ -34,30 +34,27 @@ fn new_with_global_streams_seq() { set_variable_peer_id, ); - let script = format!( - r#" + let script = f!(r#" (seq (seq - (call "{0}" ("" "") ["1"] $stream) - (call "{0}" ("" "") ["2"] $stream) + (call "{set_variable_peer_id}" ("" "") ["1"] $stream) + (call "{set_variable_peer_id}" ("" "") ["2"] $stream) ) (fold $stream i (seq (new $stream (seq (seq - (call "{1}" ("" "") [i] $stream) + (call "{local_vm_peer_id_1}" ("" "") [i] $stream) (next i) ) - (call "{1}" ("" "") [$stream]) + (call "{local_vm_peer_id_1}" ("" "") [$stream]) ) ) - (call "{2}" ("" "") [$stream]) + (call "{local_vm_peer_id_2}" ("" "") [$stream]) ) ) - )"#, - set_variable_peer_id, local_vm_peer_id_1, local_vm_peer_id_2 - ); + )"#); let result = checked_call_vm!(set_variable_vm, "", &script, "", ""); let vm_1_result = checked_call_vm!(local_vm_1, "", &script, "", result.data); @@ -98,18 +95,15 @@ fn several_restrictions() { let vm_peer_id = "vm_peer_id"; let mut vm = create_avm(echo_call_service(), vm_peer_id); - let script = format!( - r#" + let script = f!(r#" (new $stream (seq (new $stream - (call "{0}" ("" "") ["test"] $stream) + (call "{vm_peer_id}" ("" "") ["test"] $stream) ) - (call "{0}" ("" "") [$stream]) + (call "{vm_peer_id}" ("" "") [$stream]) ) - )"#, - vm_peer_id - ); + )"#); let result = checked_call_vm!(vm, "", script, "", ""); @@ -126,8 +120,7 @@ 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 = format!( - r#" + let script = f!(r#" (seq (new $a (seq @@ -138,23 +131,21 @@ fn check_influence_to_not_restricted() { ) (ap "more" $a) ) - (call "{0}" ("op" "identity") [$a] a-fix) + (call "{vm_peer_id}" ("op" "identity") [$a] a-fix) ) ) (seq (seq - (call "{0}" ("callbackSrv" "response") [$a0]) ;; should be non-empty - (call "{0}" ("callbackSrv" "response") [$a1]) ;; should be non-empty + (call "{vm_peer_id}" ("callbackSrv" "response") [$a0]) ;; should be non-empty + (call "{vm_peer_id}" ("callbackSrv" "response") [$a1]) ;; should be non-empty ) (seq - (call "{0}" ("callbackSrv" "response") [$a]) ;; should be empty - (call "{0}" ("callbackSrv" "response") [a-fix]) ;; should be empty + (call "{vm_peer_id}" ("callbackSrv" "response") [$a]) ;; should be empty + (call "{vm_peer_id}" ("callbackSrv" "response") [a-fix]) ;; should be empty ) ) ) - "#, - vm_peer_id - ); + "#); let result = checked_call_vm!(vm, "", script, "", ""); @@ -180,26 +171,22 @@ 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 = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") [] iterable) + (call "{set_variable_peer_id}" ("" "") [] iterable) (fold iterable x (seq (new $s1 (seq (ap "none" $s1) - (call "{1}" ("" "") [$s1] s-fix1) ;; should contains only "none" on each iteration + (call "{vm_peer_id}" ("" "") [$s1] s-fix1) ;; should contains only "none" on each iteration ) ) (next x) ) ) ) - - "#, - set_variable_peer_id, vm_peer_id - ); + "#); let result = checked_call_vm!(set_variable_vm, "", &script, "", ""); let result = checked_call_vm!(vm, "", script, "", result.data); @@ -238,24 +225,21 @@ fn new_with_errors() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(echo_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") [1] $global_stream) ;; this stream should precense in a data + (call "{local_peer_id}" ("" "") [1] $global_stream) ;; this stream should precense in a data (new $restricted_stream_1 (seq (new $restricted_stream_2 (seq - (call "{0}" ("" "") [2] $restricted_stream_2) ;; should have generation 1 in a data - (call "{1}" ("service_id_1" "local_fn_name") [] result) + (call "{local_peer_id}" ("" "") [2] $restricted_stream_2) ;; should have generation 1 in a data + (call "{faillible_peer_id}" ("service_id_1" "local_fn_name") [] result) ) ) - (call "{0}" ("" "") [2] restricted_stream_1) ;; should have generation 0 in a data + (call "{local_peer_id}" ("" "") [2] restricted_stream_1) ;; should have generation 0 in a data ) ) - )"#, - local_peer_id, faillible_peer_id - ); + )"#); let result = checked_call_vm!(vm, "", &script, "", ""); let result = call_vm!(faillible_vm, "", script, "", result.data); diff --git a/air/tests/test_module/instructions/par.rs b/air/tests/test_module/instructions/par.rs index 4adf1961..5f5466de 100644 --- a/air/tests/test_module/instructions/par.rs +++ b/air/tests/test_module/instructions/par.rs @@ -42,14 +42,11 @@ fn par_local_remote() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(unit_call_service(), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (par - (call "{}" ("local_service_id" "local_fn_name") [] result_name) + (call "{local_peer_id}" ("local_service_id" "local_fn_name") [] result_name) (call "remote_peer_id_2" ("service_id" "fn_name") [] g) - )"#, - local_peer_id - ); + )"#); let result = checked_call_vm!(vm, "", script, "", ""); diff --git a/air/tests/test_module/instructions/seq.rs b/air/tests/test_module/instructions/seq.rs index 416e4e23..1f56591f 100644 --- a/air/tests/test_module/instructions/seq.rs +++ b/air/tests/test_module/instructions/seq.rs @@ -43,14 +43,11 @@ 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 = format!( - r#" + let script = f!(r#" (seq - (call "{}" ("local_service_id" "local_fn_name") [] result_name) - (call "{}" ("service_id" "fn_name") [] g) - )"#, - local_peer_id, remote_peer_id - ); + (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, "asd", script, "", ""); assert_eq!(result.next_peer_pks, vec![remote_peer_id]); diff --git a/air/tests/test_module/instructions/xor.rs b/air/tests/test_module/instructions/xor.rs index 4defbcf2..586732d3 100644 --- a/air/tests/test_module/instructions/xor.rs +++ b/air/tests/test_module/instructions/xor.rs @@ -17,23 +17,17 @@ use air::UncatchableError; use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] fn xor() { let local_peer_id = "local_peer_id"; let fallible_service_id = "service_id_1"; let mut vm = create_avm(fallible_call_service(fallible_service_id), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (xor - (call "{0}" ("service_id_1" "local_fn_name") [] result_1) - (call "{0}" ("service_id_2" "local_fn_name") [] result_2) - )"#, - local_peer_id, - ); + (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, "asd", script, "", ""); @@ -47,14 +41,11 @@ fn xor() { ); assert_eq!(actual_trace[1], expected_call_result); - let script = format!( - r#" + let script = f!(r#" (xor - (call "{0}" ("service_id_2" "local_fn_name") [] result_1) - (call "{0}" ("service_id_1" "local_fn_name") [] result_2) - )"#, - local_peer_id - ); + (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, "asd", script, "", ""); @@ -68,17 +59,14 @@ 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 = format!( - r#" + let script = f!(r#" (xor (par (call "unknown_peer" ("service_id_1" "local_fn_name") [] lazy_defined_variable) - (call "{0}" ("service_id_1" "local_fn_name") [lazy_defined_variable] result) + (call "{local_peer_id}" ("service_id_1" "local_fn_name") [lazy_defined_variable] result) ) - (call "{0}" ("service_id_2" "local_fn_name") ["expected"] result) - )"#, - local_peer_id, - ); + (call "{local_peer_id}" ("service_id_2" "local_fn_name") ["expected"] result) + )"#); let result = checked_call_vm!(vm, "asd", script, "", ""); @@ -119,26 +107,23 @@ fn xor_par() { let local_peer_id = "local_peer_id"; let mut vm = create_avm(fallible_call_service(fallible_service_id.clone()), local_peer_id); - let script = format!( - r#" + let script = f!(r#" (xor (par (par - (call "{0}" ("service_id_1" "local_fn_name") [] result_1) - (call "{0}" ("service_id_1" "local_fn_name") [] result_2) + (call "{local_peer_id}" ("service_id_1" "local_fn_name") [] result_1) + (call "{local_peer_id}" ("service_id_1" "local_fn_name") [] result_2) ) (par - (call "{0}" ("service_id_1" "local_fn_name") [] result_3) - (call "{0}" ("service_id_1" "local_fn_name") [] result_4) + (call "{local_peer_id}" ("service_id_1" "local_fn_name") [] result_3) + (call "{local_peer_id}" ("service_id_1" "local_fn_name") [] result_4) ) ) (seq - (call "{0}" ("service_id_2" "local_fn_name") [] result_4) - (call "{0}" ("service_id_2" "local_fn_name") [] result_5) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") [] result_4) + (call "{local_peer_id}" ("service_id_2" "local_fn_name") [] result_5) ) - )"#, - local_peer_id - ); + )"#); let result = checked_call_vm!(vm, "asd", &script, "", ""); let actual_trace = trace_from_result(&result); @@ -172,14 +157,11 @@ 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 = format!( - r#" + let script = f!(r#" (xor - (call "{0}" ("service_id_1" "local_fn_name") [] result) - (call "{1}" ("service_id_2" "local_fn_name") [%last_error%.$.message] result) - )"#, - faillible_peer_id, local_peer_id, - ); + (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, "asd", script.clone(), "", ""); let result = checked_call_vm!(vm, "asd", script, "", result.data); diff --git a/air/tests/test_module/integration/chat_join.rs b/air/tests/test_module/integration/chat_join.rs new file mode 100644 index 00000000..206a5adc --- /dev/null +++ b/air/tests/test_module/integration/chat_join.rs @@ -0,0 +1,340 @@ +/* + * Copyright 2022 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +use air_test_utils::prelude::*; + +#[test] +fn join_chat_1() { + use std::collections::HashSet; + + let relay_1_peer_id = "relay_1_peer_id"; + let mut relay_1 = create_avm(unit_call_service(), relay_1_peer_id); + + let relay_2_peer_id = "relay_2_peer_id"; + let mut relay_2 = create_avm(unit_call_service(), relay_2_peer_id); + + let client_1_peer_id = "client_1_peer_id"; + let mut client_1 = create_avm(unit_call_service(), client_1_peer_id); + + let client_2_peer_id = "client_2_peer_id"; + let mut client_2 = create_avm(unit_call_service(), client_2_peer_id); + + let remote_peer_id = "remote_peer_id"; + let members = json!([[client_1_peer_id, relay_1_peer_id], [client_2_peer_id, relay_2_peer_id]]); + let members_call_service: CallServiceClosure = + Box::new(move |_| -> CallServiceResult { CallServiceResult::ok(members.clone()) }); + let mut remote = create_avm(members_call_service, remote_peer_id); + + let script = f!(r#" + (seq + (call "{relay_1_peer_id}" ("identity" "") [] $void1) + (seq + (call "{remote_peer_id}" ("552196ea-b9b2-4761-98d4-8e7dba77fac4" "add") [] $void2) + (seq + (call "{remote_peer_id}" ("920e3ba3-cbdf-4ae3-8972-0fa2f31fffd9" "get_users") [] members) + (fold members m + (par + (seq + (call m.$.[1]! ("identity" "") [] $void) + (call m.$.[0]! ("fgemb3" "add") [] $void3) + ) + (next m) + ) + ) + ) + ) + ) + "#); + + let client_1_result = checked_call_vm!(client_1, "asd", &script, "", ""); + + let client_1_actual_trace = trace_from_result(&client_1_result); + let client_1_expected_trace = vec![executed_state::request_sent_by(client_1_peer_id)]; + + assert_eq!(client_1_actual_trace, client_1_expected_trace); + assert_eq!(client_1_result.next_peer_pks, vec![String::from(relay_1_peer_id)]); + + let relay_1_result = checked_call_vm!(relay_1, "asd", &script, client_1_result.data, ""); + + let relay_1_actual_trace = trace_from_result(&relay_1_result); + let relay_1_expected_trace = vec![ + executed_state::stream_string("result from unit_call_service", 0), + executed_state::request_sent_by(relay_1_peer_id), + ]; + + assert_eq!(relay_1_actual_trace, relay_1_expected_trace); + assert_eq!(relay_1_result.next_peer_pks, vec![String::from(remote_peer_id)]); + + let remote_result = checked_call_vm!(remote, "asd", &script, relay_1_result.data, ""); + + let remote_actual_trace = trace_from_result(&remote_result); + let remote_expected_trace = vec![ + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream( + json!([[client_1_peer_id, relay_1_peer_id], [client_2_peer_id, relay_2_peer_id]]), + 0, + ), + executed_state::scalar(json!([ + [client_1_peer_id, relay_1_peer_id], + [client_2_peer_id, relay_2_peer_id] + ])), + executed_state::par(1, 2), + executed_state::request_sent_by(remote_peer_id), + executed_state::par(1, 0), + executed_state::request_sent_by(remote_peer_id), + ]; + + let actual_remote_next_peer_pks: HashSet<_> = remote_result.next_peer_pks.iter().map(|s| s.as_str()).collect(); + let expected_next_peer_pks = maplit::hashset! { + relay_1_peer_id, + relay_2_peer_id, + }; + + assert_eq!(remote_actual_trace, remote_expected_trace); + assert_eq!(actual_remote_next_peer_pks, expected_next_peer_pks); + + let relay_1_result = checked_call_vm!(relay_1, "asd", &script, remote_result.data.clone(), ""); + + let relay_1_actual_trace = trace_from_result(&relay_1_result); + + let relay_1_expected_trace = vec![ + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream( + json!([[client_1_peer_id, relay_1_peer_id], [client_2_peer_id, relay_2_peer_id]]), + 0, + ), + executed_state::scalar(json!([ + [client_1_peer_id, relay_1_peer_id], + [client_2_peer_id, relay_2_peer_id] + ])), + executed_state::par(2, 2), + executed_state::stream_string("result from unit_call_service", 0), + executed_state::request_sent_by(relay_1_peer_id), + executed_state::par(1, 0), + executed_state::request_sent_by(remote_peer_id), + ]; + + assert_eq!(relay_1_actual_trace, relay_1_expected_trace); + assert_eq!(relay_1_result.next_peer_pks, vec![String::from(client_1_peer_id)]); + + let client_1_result = checked_call_vm!(client_1, "asd", &script, relay_1_result.data, ""); + + let client_1_actual_trace = trace_from_result(&client_1_result); + + let client_1_expected_trace = vec![ + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream( + json!([[client_1_peer_id, relay_1_peer_id], [client_2_peer_id, relay_2_peer_id]]), + 0, + ), + executed_state::scalar(json!([ + [client_1_peer_id, relay_1_peer_id], + [client_2_peer_id, relay_2_peer_id] + ])), + executed_state::par(2, 2), + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream_string("result from unit_call_service", 0), + executed_state::par(1, 0), + executed_state::request_sent_by(remote_peer_id), + ]; + + assert_eq!(client_1_actual_trace, client_1_expected_trace); + assert!(client_1_result.next_peer_pks.is_empty()); + + let relay_2_result = checked_call_vm!(relay_2, "asd", &script, remote_result.data, ""); + + let relay_2_actual_trace = trace_from_result(&relay_2_result); + + let relay_2_expected_trace = vec![ + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream( + json!([[client_1_peer_id, relay_1_peer_id], [client_2_peer_id, relay_2_peer_id]]), + 0, + ), + executed_state::scalar(json!([ + [client_1_peer_id, relay_1_peer_id], + [client_2_peer_id, relay_2_peer_id] + ])), + executed_state::par(1, 3), + executed_state::request_sent_by(remote_peer_id), + executed_state::par(2, 0), + executed_state::stream_string("result from unit_call_service", 0), + executed_state::request_sent_by(relay_2_peer_id), + ]; + + assert_eq!(relay_2_actual_trace, relay_2_expected_trace); + assert_eq!(relay_2_result.next_peer_pks, vec![String::from(client_2_peer_id)]); + + let client_2_result = checked_call_vm!(client_2, "asd", script, relay_2_result.data, ""); + + let client_2_actual_trace = trace_from_result(&client_2_result); + + let client_2_expected_trace = vec![ + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream( + json!([[client_1_peer_id, relay_1_peer_id], [client_2_peer_id, relay_2_peer_id]]), + 0, + ), + executed_state::scalar(json!([ + [client_1_peer_id, relay_1_peer_id], + [client_2_peer_id, relay_2_peer_id] + ])), + executed_state::par(1, 3), + executed_state::request_sent_by(remote_peer_id), + executed_state::par(2, 0), + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream_string("result from unit_call_service", 0), + ]; + + assert_eq!(client_2_actual_trace, client_2_expected_trace); + assert!(client_2_result.next_peer_pks.is_empty()); +} + +#[test] +fn join_chat_2() { + let members_call_service1: CallServiceClosure = + Box::new(|_| -> CallServiceResult { CallServiceResult::ok(json!([["A"], ["B"]])) }); + + let relay_1_peer_id = "relay_1_peer_id"; + let mut relay_1 = create_avm(unit_call_service(), relay_1_peer_id); + + let remote_peer_id = "remove_peer_id"; + let mut remote = create_avm(members_call_service1, remote_peer_id); + + let client_peer_id = "client_peer_id"; + let mut client_1 = create_avm(unit_call_service(), client_peer_id); + + let script = f!(r#" + (seq + (call "{relay_1_peer_id}" ("identity" "") [] $void1) + (seq + (call "{remote_peer_id}" ("920e3ba3-cbdf-4ae3-8972-0fa2f31fffd9" "get_users") [] members) + (fold members m + (par + (seq + (call "{relay_1_peer_id}" ("identity" "") [] $void) + (call "{client_peer_id}" ("fgemb3" "add") [m] $void3) + ) + (next m) + ) + ) + ) + ) + "#); + + let client_1_result = checked_call_vm!(client_1, "asd", &script, "", ""); + let relay_1_result = checked_call_vm!(relay_1, "asd", &script, client_1_result.data, ""); + let remote_result = checked_call_vm!(remote, "asd", &script, relay_1_result.data, ""); + let relay_1_result = checked_call_vm!(relay_1, "asd", &script, remote_result.data, ""); + let client_1_result = checked_call_vm!(client_1, "asd", script, relay_1_result.data, ""); + + let client_1_actual_trace = trace_from_result(&client_1_result); + + let client_1_expected_trace = vec![ + executed_state::stream_string("result from unit_call_service", 0), + executed_state::scalar(json!([["A"], ["B"]])), + executed_state::par(2, 3), + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream_string("result from unit_call_service", 0), + executed_state::par(2, 0), + executed_state::stream_string("result from unit_call_service", 0), + executed_state::stream_string("result from unit_call_service", 0), + ]; + + assert_eq!(client_1_actual_trace, client_1_expected_trace); + assert!(client_1_result.next_peer_pks.is_empty()); +} + +#[test] +fn init_peer_id() { + let relay_1_peer_id = "relay_1_peer_id"; + let mut relay_1 = create_avm(unit_call_service(), relay_1_peer_id); + + let client_1_peer_id = "client_1_peer_id"; + let mut client_1 = create_avm(unit_call_service(), client_1_peer_id); + + let initiator_peer_id = "initiator_peer_id"; + let mut initiator = create_avm(unit_call_service(), initiator_peer_id); + + let remote_peer_id = "remote_peer_id"; + let members = json!([[client_1_peer_id], ["B"]]); + let members_call_service: CallServiceClosure = + Box::new(move |_| -> CallServiceResult { CallServiceResult::ok(members.clone()) }); + let mut remote = create_avm(members_call_service, remote_peer_id); + + let script = f!(r#"(seq + (seq + (call "{relay_1_peer_id}" ("identity" "") []) + (seq + (call "{remote_peer_id}" ("920e3ba3-cbdf-4ae3-8972-0fa2f31fffd9" "get_users") [] members) + (fold members m + (par + (seq + (call "{relay_1_peer_id}" ("identity" "") []) + (call "{client_1_peer_id}" ("fgemb3" "add") [m]) + ) + (next m) + ) + ) + ) + ) + (call %init_peer_id% ("identity" "") []) + ) + "#); + + let initiator_1_result = checked_call_vm!(initiator, initiator_peer_id, &script, "", ""); + let client_1_result = checked_call_vm!(client_1, initiator_peer_id, &script, initiator_1_result.data, ""); + let relay_1_result = checked_call_vm!(relay_1, initiator_peer_id, &script, client_1_result.data, ""); + let remote_result = checked_call_vm!(remote, initiator_peer_id, &script, relay_1_result.data, ""); + let relay_1_result = checked_call_vm!(relay_1, initiator_peer_id, &script, remote_result.data, ""); + let client_1_result = checked_call_vm!(client_1, initiator_peer_id, &script, relay_1_result.data, ""); + + let client_1_actual_trace = trace_from_result(&client_1_result); + + let client_1_expected_trace = vec![ + executed_state::scalar_string("result from unit_call_service"), + executed_state::scalar(json!([[client_1_peer_id], ["B"]])), + executed_state::par(2, 3), + executed_state::scalar_string("result from unit_call_service"), + executed_state::scalar_string("result from unit_call_service"), + executed_state::par(2, 0), + executed_state::scalar_string("result from unit_call_service"), + executed_state::scalar_string("result from unit_call_service"), + executed_state::request_sent_by(client_1_peer_id), + ]; + + assert_eq!(client_1_actual_trace, client_1_expected_trace); + assert_eq!(client_1_result.next_peer_pks, vec![initiator_peer_id.to_string()]); + + let initiator_1_result = checked_call_vm!(initiator, initiator_peer_id, script, client_1_result.data, ""); + + let initiator_1_actual_trace = trace_from_result(&initiator_1_result); + + let initiator_1_expected_trace = vec![ + executed_state::scalar_string("result from unit_call_service"), + executed_state::scalar(json!([[client_1_peer_id], ["B"]])), + executed_state::par(2, 3), + executed_state::scalar_string("result from unit_call_service"), + executed_state::scalar_string("result from unit_call_service"), + executed_state::par(2, 0), + executed_state::scalar_string("result from unit_call_service"), + executed_state::scalar_string("result from unit_call_service"), + executed_state::scalar_string("result from unit_call_service"), + ]; + + assert_eq!(initiator_1_actual_trace, initiator_1_expected_trace); + assert!(initiator_1_result.next_peer_pks.is_empty()); +} diff --git a/air/tests/test_module/integration/air_basic.rs b/air/tests/test_module/integration/create_service.rs similarity index 53% rename from air/tests/test_module/integration/air_basic.rs rename to air/tests/test_module/integration/create_service.rs index 609ac68d..ed02f529 100644 --- a/air/tests/test_module/integration/air_basic.rs +++ b/air/tests/test_module/integration/create_service.rs @@ -1,5 +1,5 @@ /* - * Copyright 2020 Fluence Labs Limited + * Copyright 2022 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,74 +14,8 @@ * limitations under the License. */ -use air::PreparationError; use air_test_utils::prelude::*; -#[test] -fn seq_par_call() { - let vm_peer_id = "some_peer_id"; - let mut vm = create_avm(unit_call_service(), vm_peer_id); - - let script = format!( - r#" - (seq - (par - (call "{0}" ("local_service_id" "local_fn_name") [] result_1) - (call "remote_peer_id" ("service_id" "fn_name") [] g) - ) - (call "{0}" ("local_service_id" "local_fn_name") [] result_2) - )"#, - vm_peer_id - ); - - let result = checked_call_vm!(vm, "asd", script, "", ""); - let actual_trace = trace_from_result(&result); - - let unit_call_service_result = "result from unit_call_service"; - let expected_trace = vec![ - executed_state::par(1, 1), - executed_state::scalar_string(unit_call_service_result), - executed_state::request_sent_by(vm_peer_id), - executed_state::scalar_string(unit_call_service_result), - ]; - - assert_eq!(actual_trace, expected_trace); - assert_eq!(result.next_peer_pks, vec![String::from("remote_peer_id")]); -} - -#[test] -fn par_par_call() { - let vm_peer_id = "some_peer_id"; - let mut vm = create_avm(unit_call_service(), vm_peer_id); - - let script = format!( - r#" - (par - (par - (call "{0}" ("local_service_id" "local_fn_name") [] result_1) - (call "remote_peer_id" ("service_id" "fn_name") [] g) - ) - (call "{0}" ("local_service_id" "local_fn_name") [] result_2) - )"#, - vm_peer_id, - ); - - let result = checked_call_vm!(vm, "asd", script, "", ""); - let actual_trace = trace_from_result(&result); - - let unit_call_service_result = "result from unit_call_service"; - let expected_trace = vec![ - executed_state::par(3, 1), - executed_state::par(1, 1), - executed_state::scalar_string(unit_call_service_result), - executed_state::request_sent_by(vm_peer_id), - executed_state::scalar_string(unit_call_service_result), - ]; - - assert_eq!(actual_trace, expected_trace); - assert_eq!(result.next_peer_pks, vec![String::from("remote_peer_id")]); -} - #[test] fn create_service() { let module = "greeting"; @@ -131,7 +65,7 @@ fn create_service() { let script = include_str!("./scripts/create_service.clj"); - let result = checked_call_vm!(set_variables_vm, "init_peer_id", script.clone(), "", ""); + let result = checked_call_vm!(set_variables_vm, "init_peer_id", script, "", ""); let result = checked_call_vm!(vm, "init_peer_id", script, "", result.data); let add_module_response = "add_module response"; @@ -152,17 +86,3 @@ fn create_service() { assert_eq!(actual_trace, expected_trace); assert_eq!(result.next_peer_pks, vec![String::from("remote_peer_id")]); } - -#[test] -fn invalid_air() { - let vm_peer_id = "some_peer_id"; - let mut vm = create_avm(unit_call_service(), vm_peer_id); - - let script = r#"(seq )"#; - - let result = call_vm!(vm, "", script, "", ""); - - let error_message = air_parser::parse(script).expect_err("air parser should fail on this script"); - let expected_error = PreparationError::AIRParseError(error_message); - assert!(check_error(&result, expected_error)); -} diff --git a/air/tests/test_module/integration/dashboard.rs b/air/tests/test_module/integration/dashboard.rs index 17e93f20..89f6c8e6 100644 --- a/air/tests/test_module/integration/dashboard.rs +++ b/air/tests/test_module/integration/dashboard.rs @@ -124,10 +124,10 @@ fn peer_host_function( #[rustfmt::skip] fn create_peer_host_function(peer_id: String, known_peer_ids: Vec) -> CallServiceClosure { - let relay_blueprints = (0..=2).map(|id| format!("{}_blueprint_{}", peer_id, id)).collect::>(); - let relay_modules = (0..=2).map(|id| format!("{}_module_{}", peer_id, id)).collect::>(); - let relay_interfaces = (0..=2).map(|id| format!("{}_interface_{}", peer_id, id)).collect::>(); - let relay_ident = format!("{}_ident", peer_id); + let relay_blueprints = (0..=2).map(|id| f!("{peer_id}_blueprint_{id}")).collect::>(); + let relay_modules = (0..=2).map(|id| f!("{peer_id}_module_{id}")).collect::>(); + let relay_interfaces = (0..=2).map(|id| f!("{peer_id}_interface_{id}")).collect::>(); + let relay_ident = f!("{peer_id}_ident"); peer_host_function( known_peer_ids, diff --git a/air/tests/test_module/integration/join.rs b/air/tests/test_module/integration/join.rs deleted file mode 100644 index 8349841a..00000000 --- a/air/tests/test_module/integration/join.rs +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright 2020 Fluence Labs Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -use air_test_utils::prelude::*; - -#[test] -fn join_chat() { - use std::collections::HashSet; - - let members_call_service1: CallServiceClosure = - Box::new(|_| -> CallServiceResult { CallServiceResult::ok(json!([["A", "Relay1"], ["B", "Relay2"]])) }); - - let mut relay_1 = create_avm(unit_call_service(), "Relay1"); - let mut relay_2 = create_avm(unit_call_service(), "Relay2"); - let mut remote = create_avm(members_call_service1, "Remote"); - let mut client_1 = create_avm(unit_call_service(), "A"); - let mut client_2 = create_avm(unit_call_service(), "B"); - - let script = r#" - (seq - (call "Relay1" ("identity" "") [] $void1) - (seq - (call "Remote" ("552196ea-b9b2-4761-98d4-8e7dba77fac4" "add") [] $void2) - (seq - (call "Remote" ("920e3ba3-cbdf-4ae3-8972-0fa2f31fffd9" "get_users") [] members) - (fold members m - (par - (seq - (call m.$.[1]! ("identity" "") [] $void) - (call m.$.[0]! ("fgemb3" "add") [] $void3) - ) - (next m) - ) - ) - ) - ) - ) - "#; - - let client_1_result = checked_call_vm!(client_1, "asd", script, "", ""); - - let client_1_actual_trace = trace_from_result(&client_1_result); - let client_1_expected_trace = vec![executed_state::request_sent_by("A")]; - - assert_eq!(client_1_actual_trace, client_1_expected_trace); - assert_eq!(client_1_result.next_peer_pks, vec![String::from("Relay1")]); - - let relay_1_result = checked_call_vm!(relay_1, "asd", script.clone(), client_1_result.data, ""); - - let relay_1_actual_trace = trace_from_result(&relay_1_result); - let relay_1_expected_trace = vec![ - executed_state::stream_string("result from unit_call_service", 0), - executed_state::request_sent_by("Relay1"), - ]; - - assert_eq!(relay_1_actual_trace, relay_1_expected_trace); - assert_eq!(relay_1_result.next_peer_pks, vec![String::from("Remote")]); - - let remote_result = checked_call_vm!(remote, "asd", script.clone(), relay_1_result.data, ""); - - let remote_actual_trace = trace_from_result(&remote_result); - let remote_expected_trace = vec![ - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream(json!([["A", "Relay1"], ["B", "Relay2"]]), 0), - executed_state::scalar(json!([["A", "Relay1"], ["B", "Relay2"]])), - executed_state::par(1, 2), - executed_state::request_sent_by("Remote"), - executed_state::par(1, 0), - executed_state::request_sent_by("Remote"), - ]; - - let remote_result_next_peer_pks: HashSet<_> = remote_result.next_peer_pks.iter().map(|s| s.as_str()).collect(); - let next_peer_pks_right = maplit::hashset! { - "Relay1", - "Relay2", - }; - - assert_eq!(remote_actual_trace, remote_expected_trace); - assert_eq!(remote_result_next_peer_pks, next_peer_pks_right); - - let relay_1_result = checked_call_vm!(relay_1, "asd", script.clone(), remote_result.data.clone(), ""); - - let relay_1_actual_trace = trace_from_result(&relay_1_result); - - let relay_1_expected_trace = vec![ - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream(json!([["A", "Relay1"], ["B", "Relay2"]]), 0), - executed_state::scalar(json!([["A", "Relay1"], ["B", "Relay2"]])), - executed_state::par(2, 2), - executed_state::stream_string("result from unit_call_service", 0), - executed_state::request_sent_by("Relay1"), - executed_state::par(1, 0), - executed_state::request_sent_by("Remote"), - ]; - - assert_eq!(relay_1_actual_trace, relay_1_expected_trace); - assert_eq!(relay_1_result.next_peer_pks, vec![String::from("A")]); - - let client_1_result = checked_call_vm!(client_1, "asd", script.clone(), relay_1_result.data, ""); - - let client_1_actual_trace = trace_from_result(&client_1_result); - - let client_1_expected_trace = vec![ - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream(json!([["A", "Relay1"], ["B", "Relay2"]]), 0), - executed_state::scalar(json!([["A", "Relay1"], ["B", "Relay2"]])), - executed_state::par(2, 2), - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream_string("result from unit_call_service", 0), - executed_state::par(1, 0), - executed_state::request_sent_by("Remote"), - ]; - - assert_eq!(client_1_actual_trace, client_1_expected_trace); - assert_eq!(client_1_result.next_peer_pks, Vec::::new()); - - let relay_2_result = checked_call_vm!(relay_2, "asd", script.clone(), remote_result.data, ""); - - let relay_2_actual_trace = trace_from_result(&relay_2_result); - - let relay_2_expected_trace = vec![ - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream(json!([["A", "Relay1"], ["B", "Relay2"]]), 0), - executed_state::scalar(json!([["A", "Relay1"], ["B", "Relay2"]])), - executed_state::par(1, 3), - executed_state::request_sent_by("Remote"), - executed_state::par(2, 0), - executed_state::stream_string("result from unit_call_service", 0), - executed_state::request_sent_by("Relay2"), - ]; - - assert_eq!(relay_2_actual_trace, relay_2_expected_trace); - assert_eq!(relay_2_result.next_peer_pks, vec![String::from("B")]); - - let client_2_result = checked_call_vm!(client_2, "asd", script, relay_2_result.data, ""); - - let client_2_actual_trace = trace_from_result(&client_2_result); - - let client_2_expected_trace = vec![ - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream(json!([["A", "Relay1"], ["B", "Relay2"]]), 0), - executed_state::scalar(json!([["A", "Relay1"], ["B", "Relay2"]])), - executed_state::par(1, 3), - executed_state::request_sent_by("Remote"), - executed_state::par(2, 0), - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream_string("result from unit_call_service", 0), - ]; - - assert_eq!(client_2_actual_trace, client_2_expected_trace); - assert_eq!(client_2_result.next_peer_pks, Vec::::new()); -} - -#[test] -fn join() { - let members_call_service1: CallServiceClosure = - Box::new(|_| -> CallServiceResult { CallServiceResult::ok(json!([["A"], ["B"]])) }); - - let mut relay_1 = create_avm(unit_call_service(), "Relay1"); - let mut remote = create_avm(members_call_service1, "Remote"); - let mut client_1 = create_avm(unit_call_service(), "A"); - - let script = r#" - (seq - (call "Relay1" ("identity" "") [] $void1) - (seq - (call "Remote" ("920e3ba3-cbdf-4ae3-8972-0fa2f31fffd9" "get_users") [] members) - (fold members m - (par - (seq - (call "Relay1" ("identity" "") [] $void) - (call "A" ("fgemb3" "add") [m] $void3) - ) - (next m) - ) - ) - ) - ) - "#; - - let client_1_result = checked_call_vm!(client_1, "asd", script, "", ""); - let relay_1_result = checked_call_vm!(relay_1, "asd", script, client_1_result.data, ""); - let remote_result = checked_call_vm!(remote, "asd", script, relay_1_result.data, ""); - let relay_1_result = checked_call_vm!(relay_1, "asd", script, remote_result.data, ""); - let client_1_result = checked_call_vm!(client_1, "asd", script, relay_1_result.data, ""); - - let client_1_actual_trace = trace_from_result(&client_1_result); - - let client_1_expected_trace = vec![ - executed_state::stream_string("result from unit_call_service", 0), - executed_state::scalar(json!([["A"], ["B"]])), - executed_state::par(2, 3), - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream_string("result from unit_call_service", 0), - executed_state::par(2, 0), - executed_state::stream_string("result from unit_call_service", 0), - executed_state::stream_string("result from unit_call_service", 0), - ]; - - assert_eq!(client_1_actual_trace, client_1_expected_trace); - assert_eq!(client_1_result.next_peer_pks, Vec::::new()); -} - -#[test] -fn init_peer_id() { - let members_call_service1: CallServiceClosure = - Box::new(|_| -> CallServiceResult { CallServiceResult::ok(json!([["A"], ["B"]])) }); - - let initiator_peer_id = String::from("initiator"); - - let mut relay_1 = create_avm(unit_call_service(), "Relay1"); - let mut remote = create_avm(members_call_service1, "Remote"); - let mut client_1 = create_avm(unit_call_service(), "A"); - let mut initiator = create_avm(unit_call_service(), initiator_peer_id.clone()); - - let script = r#"(seq - (seq - (call "Relay1" ("identity" "") []) - (seq - (call "Remote" ("920e3ba3-cbdf-4ae3-8972-0fa2f31fffd9" "get_users") [] members) - (fold members m - (par - (seq - (call "Relay1" ("identity" "") []) - (call "A" ("fgemb3" "add") [m]) - ) - (next m) - ) - ) - ) - ) - (call %init_peer_id% ("identity" "") []) - ) - "#; - - let initiator_1_result = checked_call_vm!(initiator, &initiator_peer_id, script, "", ""); - let client_1_result = checked_call_vm!(client_1, &initiator_peer_id, script, initiator_1_result.data, ""); - let relay_1_result = checked_call_vm!(relay_1, &initiator_peer_id, script, client_1_result.data, ""); - let remote_result = checked_call_vm!(remote, &initiator_peer_id, script, relay_1_result.data, ""); - let relay_1_result = checked_call_vm!(relay_1, &initiator_peer_id, script, remote_result.data, ""); - let client_1_result = checked_call_vm!(client_1, &initiator_peer_id, script, relay_1_result.data, ""); - - let client_1_actual_trace = trace_from_result(&client_1_result); - - let client_1_expected_trace = vec![ - executed_state::scalar_string("result from unit_call_service"), - executed_state::scalar(json!([["A"], ["B"]])), - executed_state::par(2, 3), - executed_state::scalar_string("result from unit_call_service"), - executed_state::scalar_string("result from unit_call_service"), - executed_state::par(2, 0), - executed_state::scalar_string("result from unit_call_service"), - executed_state::scalar_string("result from unit_call_service"), - executed_state::request_sent_by("A"), - ]; - - assert_eq!(client_1_actual_trace, client_1_expected_trace); - assert_eq!(client_1_result.next_peer_pks, vec![initiator_peer_id.clone()]); - - let initiator_1_result = checked_call_vm!(initiator, initiator_peer_id, script, client_1_result.data, ""); - - let initiator_1_actual_trace = trace_from_result(&initiator_1_result); - - let initiator_1_expected_trace = vec![ - executed_state::scalar_string("result from unit_call_service"), - executed_state::scalar(json!([["A"], ["B"]])), - executed_state::par(2, 3), - executed_state::scalar_string("result from unit_call_service"), - executed_state::scalar_string("result from unit_call_service"), - executed_state::par(2, 0), - executed_state::scalar_string("result from unit_call_service"), - executed_state::scalar_string("result from unit_call_service"), - executed_state::scalar_string("result from unit_call_service"), - ]; - - assert_eq!(initiator_1_actual_trace, initiator_1_expected_trace); - assert_eq!(initiator_1_result.next_peer_pks, Vec::::new()); -} diff --git a/air/tests/test_module/integration/mod.rs b/air/tests/test_module/integration/mod.rs index e4bdecd2..266baa38 100644 --- a/air/tests/test_module/integration/mod.rs +++ b/air/tests/test_module/integration/mod.rs @@ -14,19 +14,7 @@ * limitations under the License. */ -mod air_basic; -mod ap_with_fold; -mod call_evidence_basic; +mod chat_join; +mod create_service; mod dashboard; -mod data_merge; -mod empty_array; -mod flattening; -mod join; -mod join_behaviour; -mod lambda; -mod last_error; mod network_explore; -mod recursive_streams; -mod security_tetraplets; -mod streams; -mod streams_early_exit; diff --git a/air/tests/test_module/issues/issue_137.rs b/air/tests/test_module/issues/issue_137.rs index 036f5b8c..ffa2ac9e 100644 --- a/air/tests/test_module/issues/issue_137.rs +++ b/air/tests/test_module/issues/issue_137.rs @@ -29,33 +29,30 @@ fn issue_137() { let node_4_id = "node_4_id"; let mut node_4 = create_avm(unit_call_service(), node_4_id); - let script = format!( - r#" + let script = f!(r#" (seq - (call "{0}" ("" "") []) ;; initiator + (call "{initiator_id}" ("" "") []) ;; initiator (par (seq (par - (call "{1}" ("" "") []) ;; node 1 - (call "{2}" ("" "") []) ;; node 2 + (call "{node_1_id}" ("" "") []) ;; node 1 + (call "{node_2_id}" ("" "") []) ;; node 2 ) - (call "{3}" ("" "") []) ;; node 3 + (call "{node_3_id}" ("" "") []) ;; node 3 ) (par (seq - (call "{1}" ("" "") []) ;; node 1 - (call "{4}" ("" "") []) ;; node 4 + (call "{node_1_id}" ("" "") []) ;; node 1 + (call "{node_4_id}" ("" "") []) ;; node 4 ) (seq - (call "{2}" ("" "") []) ;; node 2 - (call "{4}" ("" "") []) ;; node 4 + (call "{node_2_id}" ("" "") []) ;; node 2 + (call "{node_4_id}" ("" "") []) ;; node 4 ) ) ) ) - "#, - initiator_id, node_1_id, node_2_id, node_3_id, node_4_id - ); + "#); let initiator_result = checked_call_vm!(initiator, "", &script, "", ""); let node_1_result = checked_call_vm!(node_1, "", &script, "", initiator_result.data.clone()); diff --git a/air/tests/test_module/issues/issue_173.rs b/air/tests/test_module/issues/issue_173.rs index 377897c5..961a0e61 100644 --- a/air/tests/test_module/issues/issue_173.rs +++ b/air/tests/test_module/issues/issue_173.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] // test for github.com/fluencelabs/aquavm/issues/173 fn issue_173() { diff --git a/air/tests/test_module/issues/issue_178.rs b/air/tests/test_module/issues/issue_178.rs index fec16d0f..68279795 100644 --- a/air/tests/test_module/issues/issue_178.rs +++ b/air/tests/test_module/issues/issue_178.rs @@ -16,8 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; use std::collections::HashSet; #[test] diff --git a/air/tests/test_module/issues/issue_180.rs b/air/tests/test_module/issues/issue_180.rs index 39232cdf..b895d1f9 100644 --- a/air/tests/test_module/issues/issue_180.rs +++ b/air/tests/test_module/issues/issue_180.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] // test for github.com/fluencelabs/aquavm/issues/180 fn issue_180() { diff --git a/air/tests/test_module/issues/issue_206.rs b/air/tests/test_module/issues/issue_206.rs index eab13763..3fb98f50 100644 --- a/air/tests/test_module/issues/issue_206.rs +++ b/air/tests/test_module/issues/issue_206.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] // test for github.com/fluencelabs/aquavm/issues/206 fn issue_206() { diff --git a/air/tests/test_module/issues/issue_211.rs b/air/tests/test_module/issues/issue_211.rs index 6c334cd7..a12a7be1 100644 --- a/air/tests/test_module/issues/issue_211.rs +++ b/air/tests/test_module/issues/issue_211.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] // test for github.com/fluencelabs/aquavm/issues/211 // On the versions < 0.20.1 it just crashes diff --git a/air/tests/test_module/issues/issue_214.rs b/air/tests/test_module/issues/issue_214.rs index 80c13f8b..ae2eea22 100644 --- a/air/tests/test_module/issues/issue_214.rs +++ b/air/tests/test_module/issues/issue_214.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] // test for github.com/fluencelabs/aquavm/issues/214 fn issue_214() { diff --git a/air/tests/test_module/issues/issue_216.rs b/air/tests/test_module/issues/issue_216.rs index 94d0fd44..62df7b2e 100644 --- a/air/tests/test_module/issues/issue_216.rs +++ b/air/tests/test_module/issues/issue_216.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] // test for github.com/fluencelabs/aquavm/issues/216 fn issue_216() { diff --git a/air/tests/test_module/issues/issue_221.rs b/air/tests/test_module/issues/issue_221.rs index 66a63a0a..b3739035 100644 --- a/air/tests/test_module/issues/issue_221.rs +++ b/air/tests/test_module/issues/issue_221.rs @@ -16,9 +16,6 @@ use air_test_utils::prelude::*; -use fstrings::f; -use fstrings::format_args_f; - #[test] // test for github.com/fluencelabs/aquavm/issues/221 fn issue_221() { diff --git a/air/tests/test_module/main.rs b/air/tests/test_module/main.rs index 43fb899c..8acaf045 100644 --- a/air/tests/test_module/main.rs +++ b/air/tests/test_module/main.rs @@ -15,6 +15,7 @@ */ // https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html +mod features; mod instructions; mod integration; mod issues; diff --git a/crates/air-lib/air-parser/src/parser/lexer/tests.rs b/crates/air-lib/air-parser/src/parser/lexer/tests.rs index 366b24c4..e1dce12c 100644 --- a/crates/air-lib/air-parser/src/parser/lexer/tests.rs +++ b/crates/air-lib/air-parser/src/parser/lexer/tests.rs @@ -22,6 +22,9 @@ use super::Token; use air_lambda_parser::LambdaAST; use air_lambda_parser::ValueAccessor; +use fstrings::f; +use fstrings::format_args_f; + fn run_lexer(input: &str) -> Vec, usize, LexerError>> { let lexer = AIRLexer::new(input); lexer.collect() @@ -189,7 +192,7 @@ fn string_literal() { #[test] fn integer_numbers() { let test_integer = 123; - let number_with_plus_sign = format!("+{}", test_integer); + let number_with_plus_sign = f!("+{test_integer}"); lexer_test( &number_with_plus_sign, @@ -200,14 +203,14 @@ fn integer_numbers() { ))), ); - let number = format!("{}", test_integer); + let number = f!("{test_integer}"); lexer_test( &number, Single(Ok((0, Token::I64(test_integer), number.len()))), ); - let number_with_minus_sign = format!("-{}", test_integer); + let number_with_minus_sign = f!("-{test_integer}"); lexer_test( &number_with_minus_sign, @@ -222,7 +225,7 @@ fn integer_numbers() { #[test] fn float_number() { let test_float = 123.123; - let float_number_with_plus_sign = format!("+{}", test_float); + let float_number_with_plus_sign = f!("+{test_float}"); lexer_test( &float_number_with_plus_sign, @@ -233,14 +236,14 @@ fn float_number() { ))), ); - let float_number = format!("{}", test_float); + let float_number = f!("{test_float}"); lexer_test( &float_number, Single(Ok((0, Token::F64(test_float), float_number.len()))), ); - let float_number_with_minus_sign = format!("-{}", test_float); + let float_number_with_minus_sign = f!("-{test_float}"); lexer_test( &float_number_with_minus_sign, diff --git a/crates/air-lib/air-parser/src/parser/tests/call.rs b/crates/air-lib/air-parser/src/parser/tests/call.rs index 3524bc66..5f93dd0d 100644 --- a/crates/air-lib/air-parser/src/parser/tests/call.rs +++ b/crates/air-lib/air-parser/src/parser/tests/call.rs @@ -396,17 +396,14 @@ fn parse_last_error() { #[test] fn seq_par_call() { let peer_id = "some_peer_id"; - let source_code = format!( - r#" + let source_code = f!(r#" (seq (par - (call "{0}" ("local_service_id" "local_fn_name") [] result_1) - (call "{0}" ("service_id" "fn_name") [] g) + (call "{peer_id}" ("local_service_id" "local_fn_name") [] result_1) + (call "{peer_id}" ("service_id" "fn_name") [] g) ) - (call "{0}" ("local_service_id" "local_fn_name") [] result_2) - )"#, - peer_id, - ); + (call "{peer_id}" ("local_service_id" "local_fn_name") [] result_2) + )"#); let instruction = parse(&source_code); let expected = seq( diff --git a/crates/air-lib/air-parser/src/parser/tests/fold.rs b/crates/air-lib/air-parser/src/parser/tests/fold.rs index e21db1b6..b4e551bc 100644 --- a/crates/air-lib/air-parser/src/parser/tests/fold.rs +++ b/crates/air-lib/air-parser/src/parser/tests/fold.rs @@ -20,7 +20,6 @@ use crate::ast::*; use crate::parser::ParserError; use air_lambda_ast::ValueAccessor; -use fstrings::f; use lalrpop_util::ParseError; #[test] diff --git a/crates/air-lib/test-utils/Cargo.toml b/crates/air-lib/test-utils/Cargo.toml index 4ab8ce8f..b618a37c 100644 --- a/crates/air-lib/test-utils/Cargo.toml +++ b/crates/air-lib/test-utils/Cargo.toml @@ -19,4 +19,5 @@ air-interpreter-interface = { path = "../interpreter-interface" } avm-server = { path = "../../../avm/server" } marine-rs-sdk = "0.6.15" +fstrings = "0.2.3" serde_json = "1.0.61" diff --git a/crates/air-lib/test-utils/src/lib.rs b/crates/air-lib/test-utils/src/lib.rs index 0af823c9..f763a5df 100644 --- a/crates/air-lib/test-utils/src/lib.rs +++ b/crates/air-lib/test-utils/src/lib.rs @@ -42,6 +42,9 @@ 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; }