mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 15:20:16 +00:00
introduce %timestamp% (#250)
This commit is contained in:
parent
5c2b9d442b
commit
490791b177
@ -1,4 +1,9 @@
|
||||
## Version 0.23.0 (2021-04-19)
|
||||
## Version 0.24.0 (2021-04-21)
|
||||
|
||||
[PR 250](https://github.com/fluencelabs/aquavm/pull/250):
|
||||
Introduced %timestamp% keyword
|
||||
|
||||
## Version 0.23.0 (2021-04-20)
|
||||
|
||||
[PR 248](https://github.com/fluencelabs/aquavm/pull/248):
|
||||
Introduced new for scalars
|
||||
|
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -75,7 +75,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "air-interpreter-interface"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
dependencies = [
|
||||
"fluence-it-types",
|
||||
"marine-rs-sdk",
|
||||
@ -216,7 +216,7 @@ version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "avm-server"
|
||||
version = "0.18.0"
|
||||
version = "0.19.0"
|
||||
dependencies = [
|
||||
"air-interpreter-interface",
|
||||
"avm-data-store",
|
||||
|
@ -27,9 +27,10 @@ pub(super) fn apply_to_arg(
|
||||
use ast::ApArgument::*;
|
||||
|
||||
let result = match argument {
|
||||
InitPeerId => apply_const(exec_ctx.init_peer_id.as_str(), exec_ctx, trace_ctx),
|
||||
InitPeerId => apply_const(exec_ctx.run_parameters.init_peer_id.as_str(), exec_ctx, trace_ctx),
|
||||
LastError(error_accessor) => apply_last_error(error_accessor, exec_ctx, trace_ctx)?,
|
||||
Literal(value) => apply_const(*value, exec_ctx, trace_ctx),
|
||||
Timestamp => apply_const(exec_ctx.run_parameters.timestamp, exec_ctx, trace_ctx),
|
||||
Number(value) => apply_const(value, exec_ctx, trace_ctx),
|
||||
Boolean(value) => apply_const(*value, exec_ctx, trace_ctx),
|
||||
EmptyArray => apply_const(serde_json::json!([]), exec_ctx, trace_ctx),
|
||||
@ -41,7 +42,7 @@ pub(super) fn apply_to_arg(
|
||||
|
||||
fn apply_const(value: impl Into<JValue>, exec_ctx: &ExecutionCtx<'_>, trace_ctx: &TraceHandler) -> ValueAggregate {
|
||||
let value = Rc::new(value.into());
|
||||
let tetraplet = SecurityTetraplet::literal_tetraplet(exec_ctx.init_peer_id.as_ref());
|
||||
let tetraplet = SecurityTetraplet::literal_tetraplet(exec_ctx.run_parameters.init_peer_id.as_ref());
|
||||
let tetraplet = Rc::new(tetraplet);
|
||||
|
||||
ValueAggregate::new(value, tetraplet, trace_ctx.trace_pos())
|
||||
|
@ -61,10 +61,10 @@ fn set_last_error<'i>(
|
||||
|
||||
let current_peer_id = match &tetraplet {
|
||||
// use tetraplet if they set, because an error could be propagated from data
|
||||
// (from CallServiceFailed state) and exec_ctx.current_peer_id won't mean
|
||||
// (from CallServiceFailed state) and exec_ctx.run_parameters.current_peer_id won't mean
|
||||
// a peer where the error was occurred
|
||||
Some(tetraplet) => tetraplet.peer_pk.clone(),
|
||||
None => exec_ctx.current_peer_id.to_string(),
|
||||
None => exec_ctx.run_parameters.current_peer_id.to_string(),
|
||||
};
|
||||
|
||||
log::warn!(
|
||||
|
@ -85,6 +85,6 @@ pub(crate) fn set_remote_call_result<'i>(
|
||||
exec_ctx.next_peer_pks.push(peer_pk);
|
||||
exec_ctx.subtree_complete = false;
|
||||
|
||||
let new_call_result = CallResult::sent_peer_id(exec_ctx.current_peer_id.clone());
|
||||
let new_call_result = CallResult::sent_peer_id(exec_ctx.run_parameters.current_peer_id.clone());
|
||||
trace_ctx.meet_call_end(new_call_result);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ pub(super) fn handle_prev_state<'i>(
|
||||
Err(CatchableError::LocalServiceError(ret_code, err_msg).into())
|
||||
}
|
||||
RequestSentBy(Sender::PeerIdWithCallId { peer_id, call_id })
|
||||
if peer_id.as_str() == exec_ctx.current_peer_id.as_str() =>
|
||||
if peer_id.as_str() == exec_ctx.run_parameters.current_peer_id.as_str() =>
|
||||
{
|
||||
// call results are identified by call_id that is saved in data
|
||||
match exec_ctx.call_results.remove(call_id) {
|
||||
@ -74,7 +74,7 @@ pub(super) fn handle_prev_state<'i>(
|
||||
}
|
||||
RequestSentBy(..) => {
|
||||
// check whether current node can execute this call
|
||||
let is_current_peer = tetraplet.peer_pk.as_str() == exec_ctx.current_peer_id.as_str();
|
||||
let is_current_peer = tetraplet.peer_pk.as_str() == exec_ctx.run_parameters.current_peer_id.as_str();
|
||||
if is_current_peer {
|
||||
return Ok(StateDescriptor::can_execute_now(prev_result));
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ impl<'i> ResolvedCall<'i> {
|
||||
|
||||
// call can be executed only on peers with such peer_id
|
||||
let tetraplet = &self.tetraplet;
|
||||
if tetraplet.peer_pk.as_str() != exec_ctx.current_peer_id.as_str() {
|
||||
if tetraplet.peer_pk.as_str() != exec_ctx.run_parameters.current_peer_id.as_str() {
|
||||
set_remote_call_result(tetraplet.peer_pk.clone(), exec_ctx, trace_ctx);
|
||||
return Ok(());
|
||||
}
|
||||
@ -108,7 +108,7 @@ impl<'i> ResolvedCall<'i> {
|
||||
|
||||
exec_ctx.subtree_complete = false;
|
||||
trace_ctx.meet_call_end(CallResult::sent_peer_id_with_call_id(
|
||||
exec_ctx.current_peer_id.clone(),
|
||||
exec_ctx.run_parameters.current_peer_id.clone(),
|
||||
call_id,
|
||||
));
|
||||
|
||||
|
@ -48,7 +48,7 @@ fn resolve_to_string<'i>(value: &ast::CallInstrValue<'i>, ctx: &ExecutionCtx<'i>
|
||||
use ast::CallInstrValue::*;
|
||||
|
||||
let resolved = match value {
|
||||
InitPeerId => ctx.init_peer_id.to_string(),
|
||||
InitPeerId => ctx.run_parameters.init_peer_id.to_string(),
|
||||
Literal(value) => value.to_string(),
|
||||
Variable(variable) => {
|
||||
let (resolved, _) = resolve_ast_variable_wl(variable, ctx)?;
|
||||
|
@ -34,7 +34,7 @@ pub(crate) fn are_matchable_eq<'ctx>(
|
||||
(InitPeerId, matchable) | (matchable, InitPeerId) => compare_matchable(
|
||||
matchable,
|
||||
exec_ctx,
|
||||
make_string_comparator(exec_ctx.init_peer_id.as_str()),
|
||||
make_string_comparator(exec_ctx.run_parameters.init_peer_id.as_str()),
|
||||
),
|
||||
|
||||
(LastError(error_accessor), matchable) | (matchable, LastError(error_accessor)) => {
|
||||
@ -47,6 +47,13 @@ pub(crate) fn are_matchable_eq<'ctx>(
|
||||
compare_matchable(matchable, exec_ctx, make_string_comparator(value))
|
||||
}
|
||||
|
||||
(Timestamp, Timestamp) => Ok(true),
|
||||
(Timestamp, matchable) | (matchable, Timestamp) => compare_matchable(
|
||||
matchable,
|
||||
exec_ctx,
|
||||
make_object_comparator(JValue::Number(exec_ctx.run_parameters.timestamp.into())),
|
||||
),
|
||||
|
||||
(EmptyArray, EmptyArray) => Ok(true),
|
||||
(EmptyArray, matchable) | (matchable, EmptyArray) => {
|
||||
compare_matchable(matchable, exec_ctx, make_object_comparator(JValue::Array(vec![])))
|
||||
@ -83,7 +90,7 @@ fn compare_matchable<'ctx>(
|
||||
|
||||
match matchable {
|
||||
InitPeerId => {
|
||||
let init_peer_id = exec_ctx.init_peer_id.clone();
|
||||
let init_peer_id = exec_ctx.run_parameters.init_peer_id.clone();
|
||||
let jvalue = init_peer_id.as_str().into();
|
||||
Ok(comparator(Cow::Owned(jvalue)))
|
||||
}
|
||||
@ -95,6 +102,10 @@ fn compare_matchable<'ctx>(
|
||||
let jvalue = str.to_string().into();
|
||||
Ok(comparator(Cow::Owned(jvalue)))
|
||||
}
|
||||
Timestamp => {
|
||||
let jvalue = exec_ctx.run_parameters.timestamp.into();
|
||||
Ok(comparator(Cow::Owned(jvalue)))
|
||||
}
|
||||
Number(number) => {
|
||||
let jvalue = number.into();
|
||||
Ok(comparator(Cow::Owned(jvalue)))
|
||||
|
@ -67,10 +67,10 @@ fn fail_with_literals<'i>(
|
||||
error_code,
|
||||
error_message,
|
||||
&fail.to_string(),
|
||||
exec_ctx.init_peer_id.as_ref(),
|
||||
exec_ctx.run_parameters.init_peer_id.as_ref(),
|
||||
);
|
||||
|
||||
let literal_tetraplet = SecurityTetraplet::literal_tetraplet(exec_ctx.init_peer_id.as_ref());
|
||||
let literal_tetraplet = SecurityTetraplet::literal_tetraplet(exec_ctx.run_parameters.init_peer_id.as_ref());
|
||||
let literal_tetraplet = Rc::new(literal_tetraplet);
|
||||
|
||||
fail_with_error_object(exec_ctx, Rc::new(error_object), Some(literal_tetraplet))
|
||||
|
@ -52,7 +52,7 @@ macro_rules! execute {
|
||||
&e,
|
||||
// TODO: avoid excess copying here
|
||||
&$instr.to_string(),
|
||||
$exec_ctx.current_peer_id.as_ref(),
|
||||
$exec_ctx.run_parameters.current_peer_id.as_ref(),
|
||||
None,
|
||||
);
|
||||
Err(e)
|
||||
|
@ -36,11 +36,8 @@ pub(crate) struct ExecutionCtx<'i> {
|
||||
/// Set of peer public keys that should receive resulted data.
|
||||
pub(crate) next_peer_pks: Vec<String>,
|
||||
|
||||
/// PeerId of a peer executing this AIR script at the moment.
|
||||
pub(crate) current_peer_id: Rc<String>,
|
||||
|
||||
/// PeerId of a peer send this AIR script.
|
||||
pub(crate) init_peer_id: Rc<String>,
|
||||
/// Parameters passed from a host that describes host and contains info from a particle.
|
||||
pub(crate) run_parameters: RcRunParameters,
|
||||
|
||||
/// Last error produced by local service.
|
||||
/// None means that there weren't any error.
|
||||
@ -68,17 +65,11 @@ pub(crate) struct ExecutionCtx<'i> {
|
||||
}
|
||||
|
||||
impl<'i> ExecutionCtx<'i> {
|
||||
pub(crate) fn new(
|
||||
current_peer_id: String,
|
||||
init_peer_id: String,
|
||||
call_results: CallResults,
|
||||
last_call_request_id: u32,
|
||||
) -> Self {
|
||||
let current_peer_id = Rc::new(current_peer_id);
|
||||
pub(crate) fn new(run_parameters: RunParameters, call_results: CallResults, last_call_request_id: u32) -> Self {
|
||||
let run_parameters = RcRunParameters::from_run_parameters(run_parameters);
|
||||
|
||||
Self {
|
||||
current_peer_id,
|
||||
init_peer_id: Rc::new(init_peer_id),
|
||||
run_parameters,
|
||||
subtree_complete: true,
|
||||
last_call_request_id,
|
||||
call_results,
|
||||
@ -96,9 +87,29 @@ impl<'i> ExecutionCtx<'i> {
|
||||
}
|
||||
}
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::fmt::Display;
|
||||
use std::fmt::Formatter;
|
||||
|
||||
/// It reflects RunParameters structure due to limitation of the marine macro to support Rc.
|
||||
#[derive(Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub(crate) struct RcRunParameters {
|
||||
pub(crate) init_peer_id: Rc<String>,
|
||||
pub(crate) current_peer_id: Rc<String>,
|
||||
pub(crate) timestamp: u64,
|
||||
}
|
||||
|
||||
impl RcRunParameters {
|
||||
pub(crate) fn from_run_parameters(run_parameters: RunParameters) -> Self {
|
||||
Self {
|
||||
init_peer_id: Rc::new(run_parameters.init_peer_id),
|
||||
current_peer_id: Rc::new(run_parameters.current_peer_id),
|
||||
timestamp: run_parameters.timestamp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'i> Display for ExecutionCtx<'i> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
writeln!(f, "scalars:")?;
|
||||
@ -107,7 +118,9 @@ impl<'i> Display for ExecutionCtx<'i> {
|
||||
writeln!(f, "streams:")?;
|
||||
writeln!(f, " {}", self.streams)?;
|
||||
|
||||
writeln!(f, "current peer id: {}", self.current_peer_id)?;
|
||||
writeln!(f, "current peer id: {}", self.run_parameters.current_peer_id)?;
|
||||
writeln!(f, "init peer id: {}", self.run_parameters.init_peer_id)?;
|
||||
writeln!(f, "timestamp: {}", self.run_parameters.timestamp)?;
|
||||
writeln!(f, "subtree complete: {}", self.subtree_complete)?;
|
||||
writeln!(f, "next peer public keys: {:?}", self.next_peer_pks)?;
|
||||
|
||||
|
@ -37,9 +37,10 @@ pub(crate) fn resolve_to_args<'i>(
|
||||
use ast::Value::*;
|
||||
|
||||
match value {
|
||||
InitPeerId => prepare_const(ctx.init_peer_id.as_str(), ctx),
|
||||
InitPeerId => prepare_const(ctx.run_parameters.init_peer_id.as_str(), ctx),
|
||||
LastError(error_accessor) => prepare_last_error(error_accessor, ctx),
|
||||
Literal(value) => prepare_const(value.to_string(), ctx),
|
||||
Timestamp => prepare_const(ctx.run_parameters.timestamp, ctx),
|
||||
Boolean(value) => prepare_const(*value, ctx),
|
||||
Number(value) => prepare_const(value, ctx),
|
||||
EmptyArray => prepare_const(json!([]), ctx),
|
||||
@ -53,7 +54,7 @@ pub(crate) fn prepare_const(
|
||||
ctx: &ExecutionCtx<'_>,
|
||||
) -> ExecutionResult<(JValue, RcSecurityTetraplets)> {
|
||||
let jvalue = arg.into();
|
||||
let tetraplet = SecurityTetraplet::literal_tetraplet(ctx.init_peer_id.as_ref());
|
||||
let tetraplet = SecurityTetraplet::literal_tetraplet(ctx.run_parameters.init_peer_id.as_ref());
|
||||
let tetraplet = Rc::new(tetraplet);
|
||||
|
||||
Ok((jvalue, vec![tetraplet]))
|
||||
@ -76,7 +77,7 @@ pub(crate) fn prepare_last_error<'i>(
|
||||
let tetraplets = match tetraplet {
|
||||
Some(tetraplet) => vec![tetraplet.clone()],
|
||||
None => {
|
||||
let tetraplet = SecurityTetraplet::literal_tetraplet(ctx.init_peer_id.as_ref());
|
||||
let tetraplet = SecurityTetraplet::literal_tetraplet(ctx.run_parameters.init_peer_id.as_ref());
|
||||
let tetraplet = Rc::new(tetraplet);
|
||||
vec![tetraplet]
|
||||
}
|
||||
|
@ -68,20 +68,10 @@ fn make_exec_ctx(
|
||||
call_results: &[u8],
|
||||
run_parameters: RunParameters,
|
||||
) -> PreparationResult<ExecutionCtx<'static>> {
|
||||
let RunParameters {
|
||||
init_peer_id,
|
||||
current_peer_id,
|
||||
} = run_parameters;
|
||||
|
||||
let call_results = serde_json::from_slice(call_results)
|
||||
.map_err(|e| PreparationError::CallResultsDeFailed(e, call_results.to_vec()))?;
|
||||
|
||||
let mut ctx = ExecutionCtx::new(
|
||||
current_peer_id,
|
||||
init_peer_id,
|
||||
call_results,
|
||||
prev_data.last_call_request_id,
|
||||
);
|
||||
let mut ctx = ExecutionCtx::new(run_parameters, call_results, prev_data.last_call_request_id);
|
||||
create_streams(&mut ctx, prev_data);
|
||||
|
||||
Ok(ctx)
|
||||
|
@ -30,7 +30,7 @@ fn seq_par_call() {
|
||||
(call "{vm_peer_id}" ("local_service_id" "local_fn_name") [] result_2)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let unit_call_service_result = "result from unit_call_service";
|
||||
@ -59,7 +59,7 @@ fn par_par_call() {
|
||||
(call "{vm_peer_id}" ("local_service_id" "local_fn_name") [] result_2)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let unit_call_service_result = "result from unit_call_service";
|
||||
|
@ -59,11 +59,23 @@ fn merge_streams_in_two_fold() {
|
||||
)
|
||||
"#);
|
||||
|
||||
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 result_0 = checked_call_vm!(set_variable, <_>::default(), &script, "", "");
|
||||
let result_1 = checked_call_vm!(vm1, <_>::default(), &script, "", result_0.data.clone());
|
||||
let result_2 = checked_call_vm!(vm2, <_>::default(), &script, "", result_0.data);
|
||||
let result_3 = checked_call_vm!(
|
||||
vm1,
|
||||
<_>::default(),
|
||||
&script,
|
||||
result_1.data.clone(),
|
||||
result_2.data.clone()
|
||||
);
|
||||
let result_4 = checked_call_vm!(
|
||||
vm2,
|
||||
<_>::default(),
|
||||
script,
|
||||
result_1.data.clone(),
|
||||
result_2.data.clone()
|
||||
);
|
||||
|
||||
let actual_trace_1 = trace_from_result(&result_1);
|
||||
|
||||
@ -173,8 +185,8 @@ fn stream_merge() {
|
||||
)
|
||||
"#;
|
||||
|
||||
let result = checked_call_vm!(vm1, "asd", script, "", "");
|
||||
checked_call_vm!(vm2, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(vm1, <_>::default(), script, "", "");
|
||||
checked_call_vm!(vm2, <_>::default(), script, "", result.data);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -198,7 +210,7 @@ fn fold_merge() {
|
||||
set_variable_vm_id, local_vm_id
|
||||
);
|
||||
|
||||
let set_variable_result = checked_call_vm!(set_variable_vm, "", &script, "", "");
|
||||
let set_variable_result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
|
||||
let mut local_vms = Vec::with_capacity(7);
|
||||
let mut local_vms_results = Vec::with_capacity(7);
|
||||
@ -207,7 +219,7 @@ fn fold_merge() {
|
||||
let mut vm = create_avm(echo_call_service(), peer_id);
|
||||
let result = checked_call_vm!(
|
||||
vm,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
set_variable_result.data.clone(),
|
||||
set_variable_result.data.clone()
|
||||
@ -218,24 +230,24 @@ fn fold_merge() {
|
||||
}
|
||||
|
||||
let mut local_vm = create_avm(echo_call_service(), local_vm_id);
|
||||
let result_1 = checked_call_vm!(local_vm, "", &script, "", local_vms_results[0].data.clone());
|
||||
let result_1 = checked_call_vm!(local_vm, <_>::default(), &script, "", local_vms_results[0].data.clone());
|
||||
let result_2 = checked_call_vm!(
|
||||
local_vm,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
result_1.data.clone(),
|
||||
local_vms_results[3].data.clone()
|
||||
);
|
||||
let result_3 = checked_call_vm!(
|
||||
local_vm,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
result_2.data.clone(),
|
||||
local_vms_results[4].data.clone()
|
||||
);
|
||||
let result_4 = checked_call_vm!(
|
||||
local_vm,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
result_3.data.clone(),
|
||||
local_vms_results[5].data.clone()
|
||||
@ -243,7 +255,7 @@ fn fold_merge() {
|
||||
|
||||
let result_5 = checked_call_vm!(
|
||||
local_vm,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
result_4.data.clone(),
|
||||
local_vms_results[1].data.clone()
|
||||
@ -251,7 +263,7 @@ fn fold_merge() {
|
||||
|
||||
let result_6 = checked_call_vm!(
|
||||
local_vm,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
result_5.data.clone(),
|
||||
local_vms_results[2].data.clone()
|
||||
@ -259,7 +271,7 @@ fn fold_merge() {
|
||||
|
||||
let result_7 = checked_call_vm!(
|
||||
local_vm,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
result_6.data.clone(),
|
||||
local_vms_results[6].data.clone()
|
||||
|
@ -38,7 +38,7 @@ fn executed_trace_seq_par_call() {
|
||||
];
|
||||
let initial_data = raw_data_from_trace(initial_trace);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", initial_data);
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", initial_data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -76,7 +76,7 @@ fn executed_trace_par_par_call() {
|
||||
|
||||
let initial_data = raw_data_from_trace(initial_state);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", &script, "", initial_data);
|
||||
let result = checked_call_vm!(vm, <_>::default(), &script, "", initial_data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -99,7 +99,7 @@ fn executed_trace_par_par_call() {
|
||||
|
||||
let initial_data = raw_data_from_trace(initial_state);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", initial_data);
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", initial_data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(actual_trace, expected_trace);
|
||||
@ -122,13 +122,13 @@ fn executed_trace_seq_seq() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm2, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm2, <_>::default(), &script, "", "");
|
||||
assert_eq!(result.next_peer_pks, vec![peer_id_1.clone()]);
|
||||
|
||||
let result = checked_call_vm!(vm1, "asd", &script, "", result.data);
|
||||
let result = checked_call_vm!(vm1, <_>::default(), &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 result = checked_call_vm!(vm2, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
@ -193,7 +193,7 @@ fn executed_trace_create_service() {
|
||||
];
|
||||
let initial_data = raw_data_from_trace(expected_trace.clone());
|
||||
|
||||
let result = checked_call_vm!(vm, "init_peer_id", script, "", initial_data);
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", initial_data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
@ -225,16 +225,16 @@ 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, "", "");
|
||||
let result = checked_call_vm!(vm1, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(vm2, <_>::default(), script, "", "");
|
||||
let result = checked_call_vm!(vm1, <_>::default(), script, "", result.data);
|
||||
let mut data = result.data;
|
||||
|
||||
for _ in 0..100 {
|
||||
let result = checked_call_vm!(vm2, "asd", script, "", data);
|
||||
let result = checked_call_vm!(vm2, <_>::default(), script, "", data);
|
||||
data = result.data;
|
||||
}
|
||||
|
||||
let result = checked_call_vm!(vm3, "asd", script, "", data);
|
||||
let result = checked_call_vm!(vm3, <_>::default(), script, "", data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let generation = 0;
|
||||
@ -295,9 +295,9 @@ fn executed_trace_par_seq_fold_in_cycle_call() {
|
||||
let mut data = vec![];
|
||||
|
||||
for _ in 0..100 {
|
||||
let result = checked_call_vm!(vm1, "asd", script, "", data);
|
||||
let result = checked_call_vm!(vm2, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(vm3, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(vm1, <_>::default(), script, "", data);
|
||||
let result = checked_call_vm!(vm2, <_>::default(), script, "", result.data);
|
||||
let result = checked_call_vm!(vm3, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
@ -356,13 +356,13 @@ fn executed_trace_seq_par_seq_seq() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm2, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm2, <_>::default(), &script, "", "");
|
||||
assert_eq!(result.next_peer_pks, vec![peer_id_1.to_string()]);
|
||||
|
||||
let result = checked_call_vm!(vm1, "asd", &script, "", result.data);
|
||||
let result = checked_call_vm!(vm1, <_>::default(), &script, "", result.data);
|
||||
assert_eq!(result.next_peer_pks, vec![peer_id_2.to_string()]);
|
||||
|
||||
let result = checked_call_vm!(vm2, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(vm2, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
|
@ -24,7 +24,7 @@ fn invalid_air() {
|
||||
|
||||
let script = r#"(seq )"#;
|
||||
|
||||
let result = call_vm!(vm, "", script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let error_message = air_parser::parse(script).expect_err("air parser should fail on this script");
|
||||
let expected_error = PreparationError::AIRParseError(error_message);
|
||||
|
@ -64,9 +64,9 @@ fn last_error_tetraplets() {
|
||||
set_variable_peer_id, fallible_peer_id, local_peer_id
|
||||
);
|
||||
|
||||
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 result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(fallible_vm, <_>::default(), &script, "", result.data);
|
||||
let _ = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_value = (*args.borrow()).as_ref().unwrap().clone();
|
||||
let last_error = actual_value.as_object().unwrap();
|
||||
@ -116,8 +116,8 @@ fn not_clear_last_error_in_match() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let _ = checked_call_vm!(local_vm, "asd", &script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let _ = checked_call_vm!(local_vm, <_>::default(), &script, "", result.data);
|
||||
|
||||
let actual_value = (*args.borrow()).as_ref().unwrap().clone();
|
||||
assert_eq!(actual_value, JValue::Null);
|
||||
@ -152,8 +152,8 @@ fn not_clear_last_error_in_mismatch() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let _ = checked_call_vm!(local_vm, "asd", &script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let _ = checked_call_vm!(local_vm, <_>::default(), &script, "", result.data);
|
||||
|
||||
let actual_value = (*args.borrow()).as_ref().unwrap().clone();
|
||||
assert_eq!(actual_value, JValue::Null);
|
||||
@ -180,8 +180,8 @@ fn track_current_peer_id() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(fallible_vm, "asd", &script, "", "");
|
||||
let _ = checked_call_vm!(local_vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(fallible_vm, <_>::default(), &script, "", "");
|
||||
let _ = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_value = (*args.borrow()).as_ref().unwrap().clone();
|
||||
let last_error = actual_value.as_object().unwrap();
|
||||
@ -206,8 +206,8 @@ fn variable_names_shown_in_error() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", &script, "", "");
|
||||
let result = checked_call_vm!(echo_vm, "", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(echo_vm, <_>::default(), script, "", result.data);
|
||||
let trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(
|
||||
@ -235,8 +235,8 @@ fn non_initialized_last_error() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let init_peer_id = "init_peer_id";
|
||||
let _ = checked_call_vm!(vm, init_peer_id, script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id("init_peer_id");
|
||||
let _ = checked_call_vm!(vm, test_params.clone(), script, "", "");
|
||||
|
||||
let actual_value = (*args.borrow()).as_ref().unwrap().clone();
|
||||
assert_eq!(actual_value, JValue::Null);
|
||||
@ -244,7 +244,7 @@ fn non_initialized_last_error() {
|
||||
let actual_tetraplets = (*tetraplets.borrow()).as_ref().unwrap().clone();
|
||||
assert_eq!(
|
||||
actual_tetraplets,
|
||||
vec![vec![SecurityTetraplet::new(init_peer_id, "", "", "")]]
|
||||
vec![vec![SecurityTetraplet::new(test_params.init_peer_id, "", "", "")]]
|
||||
);
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ fn access_last_error_by_not_exists_field() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(fallible_vm, "asd", &script, "", "");
|
||||
let result = call_vm!(fallible_vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error = ExecutionError::Catchable(rc!(CatchableError::LambdaApplierError(
|
||||
LambdaError::ValueNotContainSuchField {
|
||||
@ -302,8 +302,8 @@ fn last_error_with_par_one_subtree_failed() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(fallible_vm, "asd", &script, "", "");
|
||||
let _ = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(fallible_vm, <_>::default(), &script, "", "");
|
||||
let _ = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_value = (*args.borrow()).as_ref().unwrap().clone();
|
||||
let expected_value = json!({
|
||||
@ -330,7 +330,7 @@ fn fail_with_scalar_rebubble_error() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(fallible_vm, "", &script, "", "");
|
||||
let result = call_vm!(fallible_vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error = CatchableError::UserError {
|
||||
error: rc!(json!({
|
||||
@ -358,7 +358,7 @@ fn fail_with_scalar_from_call() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(vm, "", &script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error = CatchableError::UserError {
|
||||
error: rc!(json!({
|
||||
@ -384,7 +384,7 @@ fn fail_with_scalar_with_lambda_from_call() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(vm, "", &script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error = CatchableError::UserError {
|
||||
error: rc!(json!({
|
||||
@ -409,7 +409,7 @@ fn fail_with_scalar_from_call_not_enough_fields() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(vm, "", &script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error = CatchableError::InvalidLastErrorObjectError(LastErrorObjectError::ScalarMustContainField {
|
||||
scalar: service_result,
|
||||
@ -431,7 +431,7 @@ fn fail_with_scalar_from_call_not_right_type() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(vm, "", &script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error =
|
||||
CatchableError::InvalidLastErrorObjectError(LastErrorObjectError::ScalarMustBeObject(service_result));
|
||||
@ -451,7 +451,7 @@ fn fail_with_scalar_from_call_field_not_right_type() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(vm, "", &script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error = CatchableError::InvalidLastErrorObjectError(LastErrorObjectError::ScalarFieldIsWrongType {
|
||||
scalar: service_result.clone(),
|
||||
@ -475,7 +475,7 @@ fn last_error_with_match() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
|
||||
|
||||
let trace = trace_from_result(&result);
|
||||
assert_eq!(trace.len(), 2); // if match works there will be 2 calls in a resulted trace
|
||||
|
@ -57,11 +57,11 @@ fn dont_wait_on_json_path() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let init_peer_id = "asd";
|
||||
let result = checked_call_vm!(set_variable_vm, init_peer_id, &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, init_peer_id, script, "", result.data);
|
||||
let test_params = TestRunParameters::default();
|
||||
let result = checked_call_vm!(set_variable_vm, test_params.clone(), &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, test_params.clone(), script, "", result.data);
|
||||
|
||||
assert_eq!(result.next_peer_pks, vec![init_peer_id.to_string()]);
|
||||
assert_eq!(result.next_peer_pks, vec![test_params.init_peer_id.to_string()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -75,7 +75,7 @@ fn wait_on_stream_json_path_by_id() {
|
||||
(call "{local_peer_id}" ("history" "add") [$status.$[0]!])
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(local_vm, "", non_join_stream_script, "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), non_join_stream_script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(actual_trace.len(), 3);
|
||||
@ -86,7 +86,7 @@ fn wait_on_stream_json_path_by_id() {
|
||||
(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 result = checked_call_vm!(local_vm, <_>::default(), join_stream_script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(actual_trace.len(), 2); // par and the first call emit traces, second call doesn't
|
||||
@ -111,7 +111,7 @@ fn wait_on_empty_stream_json_path() {
|
||||
(call "{local_peer_id}" ("" "") [$ns.$.[0] $ns.$.[1] $ns])
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(local_vm, "", join_stream_script, "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), join_stream_script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(actual_trace.len(), 1); // only the first call should produce a trace
|
||||
@ -150,9 +150,8 @@ fn dont_wait_on_json_path_on_scalars() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let init_peer_id = "asd";
|
||||
let result = call_vm!(set_variable_vm, init_peer_id, &script, "", "");
|
||||
let array_result = call_vm!(array_consumer, init_peer_id, &script, "", result.data.clone());
|
||||
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let array_result = call_vm!(array_consumer, <_>::default(), &script, "", result.data.clone());
|
||||
|
||||
let expected_error =
|
||||
CatchableError::LambdaApplierError(LambdaError::ValueNotContainSuchArrayIdx { value: array, idx: 5 });
|
||||
@ -165,9 +164,8 @@ fn dont_wait_on_json_path_on_scalars() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let init_peer_id = "asd";
|
||||
let result = call_vm!(set_variable_vm, init_peer_id, &script, "", "");
|
||||
let object_result = call_vm!(object_consumer, init_peer_id, script, "", result.data);
|
||||
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let object_result = call_vm!(object_consumer, <_>::default(), script, "", result.data);
|
||||
|
||||
let expected_error = CatchableError::LambdaApplierError(LambdaError::ValueNotContainSuchField {
|
||||
value: object,
|
||||
@ -196,7 +194,7 @@ fn match_with_join_behaviour() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(peer_1, "", script, "", "");
|
||||
let result = checked_call_vm!(peer_1, <_>::default(), script, "", "");
|
||||
let trace = trace_from_result(&result);
|
||||
assert_eq!(trace.len(), 2);
|
||||
}
|
||||
@ -220,7 +218,7 @@ fn mismatch_with_join_behaviour() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(peer_1, "", script, "", "");
|
||||
let result = checked_call_vm!(peer_1, <_>::default(), script, "", "");
|
||||
let trace = trace_from_result(&result);
|
||||
assert_eq!(trace.len(), 2);
|
||||
}
|
||||
@ -244,7 +242,7 @@ fn fold_with_join_behaviour() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(peer_1, "", script, "", "");
|
||||
let result = checked_call_vm!(peer_1, <_>::default(), script, "", "");
|
||||
let trace = trace_from_result(&result);
|
||||
assert_eq!(trace.len(), 2);
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ fn flattening_scalar_arrays() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", script.clone(), "", "");
|
||||
let result = call_vm!(local_vm, "asd", script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), script.clone(), "", "");
|
||||
let result = call_vm!(local_vm, <_>::default(), script.clone(), "", result.data);
|
||||
|
||||
assert!(is_interpreter_succeded(&result));
|
||||
assert_eq!(
|
||||
@ -117,8 +117,8 @@ fn flattening_streams() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", script.clone(), "", "");
|
||||
let result = call_vm!(local_vm, "asd", script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), script.clone(), "", "");
|
||||
let result = call_vm!(local_vm, <_>::default(), script.clone(), "", result.data);
|
||||
|
||||
assert!(is_interpreter_succeded(&result));
|
||||
assert_eq!(
|
||||
@ -152,8 +152,8 @@ fn flattening_empty_values() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", script.clone(), "", "");
|
||||
let result = checked_call_vm!(local_vm, "asd", script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), script.clone(), "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), script.clone(), "", result.data);
|
||||
|
||||
assert!(is_interpreter_succeded(&result));
|
||||
assert_eq!(closure_call_args.args_var, Rc::new(RefCell::new(vec![])));
|
||||
@ -191,8 +191,8 @@ fn test_handling_non_flattening_values() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = call_vm!(local_vm, "asd", &script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = call_vm!(local_vm, <_>::default(), &script, "", result.data);
|
||||
|
||||
assert_eq!(result.ret_code, 1017);
|
||||
assert_eq!(
|
||||
|
@ -33,7 +33,7 @@ fn lambda_not_allowed_for_non_objects_and_arrays() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error = CatchableError::LambdaApplierError(LambdaError::FieldAccessorNotMatchValue {
|
||||
value: json!(some_string),
|
||||
@ -67,8 +67,8 @@ fn lambda_with_string_scalar() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
|
||||
let trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(&trace[2], &executed_state::scalar_number(1u32));
|
||||
@ -99,8 +99,8 @@ fn lambda_with_number_scalar() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
|
||||
let trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(&trace[2], &executed_state::scalar_number(1u32));
|
||||
@ -139,8 +139,8 @@ fn lambda_with_number_stream() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(&actual_trace[5], &executed_state::scalar_number(2));
|
||||
@ -184,8 +184,8 @@ fn lambda_with_number_stream_and_followed_scalar() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(&actual_trace[6], &executed_state::scalar_number(checkable_value));
|
||||
@ -216,8 +216,8 @@ fn lambda_with_scalar_join() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
|
||||
let trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(&trace[3], &executed_state::request_sent_by("set_variable"));
|
||||
@ -256,8 +256,8 @@ fn lambda_with_stream_join() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
assert_eq!(&actual_trace[6], &executed_state::request_sent_by("set_variable"));
|
||||
|
@ -27,7 +27,7 @@ fn empty_array() {
|
||||
(call "{vm_peer_id}" ("" "") [result])
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![executed_state::scalar(json!([])), executed_state::scalar(json!([]))];
|
||||
|
@ -57,10 +57,9 @@ fn scalars_scope() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let init_peer_id = "";
|
||||
let result = checked_call_vm!(set_array_0_vm, init_peer_id, &script, "", "");
|
||||
let result = checked_call_vm!(peer_1_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(some_peer_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(set_array_0_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(peer_1_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(some_peer_vm, <_>::default(), &script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -107,10 +106,9 @@ fn before_after_of_next() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let init_peer_id = "";
|
||||
let result = checked_call_vm!(set_array_0_vm, init_peer_id, &script, "", "");
|
||||
let result = checked_call_vm!(peer_0_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(peer_1_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(set_array_0_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(peer_0_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(peer_1_vm, <_>::default(), &script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -180,16 +178,15 @@ fn local_and_global_scalars() {
|
||||
(call "{local_consumer_peer_id}" ("" "") [local]) ;; local set by (1) will be used
|
||||
)"#);
|
||||
|
||||
let init_peer_id = "";
|
||||
let result = checked_call_vm!(set_variable_vm, init_peer_id, &script, "", "");
|
||||
let result = checked_call_vm!(local_setter_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(local_consumer_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(local_setter_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(local_consumer_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(local_setter_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(local_consumer_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(local_setter_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(local_consumer_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(local_setter_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(local_consumer_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(local_setter_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(local_consumer_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(local_setter_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(local_consumer_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(local_setter_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(local_consumer_vm, <_>::default(), &script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -247,7 +244,7 @@ fn new_with_randomly_set_scalars_in_fold_1() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = call_vm!(test_vm_1, "", &script, "", "");
|
||||
let result = call_vm!(test_vm_1, <_>::default(), &script, "", "");
|
||||
assert_eq!(result.ret_code, 0)
|
||||
}
|
||||
|
||||
@ -283,7 +280,7 @@ fn new_with_randomly_set_scalars_in_fold_2() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = call_vm!(test_vm_1, "", &script, "", "");
|
||||
let result = call_vm!(test_vm_1, <_>::default(), &script, "", "");
|
||||
let expected_error = ExecutionError::Catchable(rc!(CatchableError::VariableWasNotInitializedAfterNew(
|
||||
variable_name.to_string()
|
||||
)));
|
||||
|
@ -61,9 +61,9 @@ fn ap_with_fold() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", &script, "", "");
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
assert_eq!(result.next_peer_pks, vec![local_vm_peer_id.to_string()]);
|
||||
|
||||
let result = checked_call_vm!(local_vm, "", &script, "", result.data);
|
||||
let result = checked_call_vm!(local_vm, <_>::default(), &script, "", result.data);
|
||||
assert!(result.next_peer_pks.is_empty());
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ fn recursive_stream_with_early_exit() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = vec![
|
||||
executed_state::stream_number(1, 0),
|
||||
@ -118,7 +118,7 @@ fn recursive_stream_many_iterations() {
|
||||
(call "{vm_peer_id_2}" ("" "") ["{result_value}"])
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", &script, "", "");
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let actual_fold = &actual_trace[2];
|
||||
let expected_fold = executed_state::fold(vec![
|
||||
@ -138,7 +138,7 @@ fn recursive_stream_many_iterations() {
|
||||
let expected_last_state = executed_state::request_sent_by(vm_peer_id_1);
|
||||
assert_eq!(actual_last_state, &expected_last_state);
|
||||
|
||||
let result = checked_call_vm!(vm_2, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_2, <_>::default(), script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let actual_last_state = &actual_trace[20];
|
||||
let expected_last_state = executed_state::scalar_string(result_value);
|
||||
@ -197,9 +197,9 @@ fn recursive_stream_join() {
|
||||
(call "{vm_peer_id_2}" ("" "") ["{result_value}"])
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", &script, "", "");
|
||||
let result = checked_call_vm!(vm_3, "", &script, "", result.data);
|
||||
let result = checked_call_vm!(vm_2, "", &script, "", result.data);
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm_3, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(vm_2, <_>::default(), &script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![
|
||||
executed_state::par(1, 1),
|
||||
@ -277,8 +277,8 @@ fn recursive_stream_error_handling() {
|
||||
(call "{vm_peer_id_2}" ("" "") ["{result_value}"])
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", &script, "", "");
|
||||
let result = checked_call_vm!(vm_2, "", &script, "", result.data);
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm_2, <_>::default(), &script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let actual_last_state = &actual_trace[10];
|
||||
let expected_last_state = executed_state::scalar_string(result_value);
|
||||
@ -352,8 +352,8 @@ fn recursive_stream_inner_fold() {
|
||||
(call "{vm_peer_id_2}" ("" "") ["{result_value}"])
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", &script, "", "");
|
||||
let result = checked_call_vm!(vm_2, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm_2, <_>::default(), script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let actual_last_state = &actual_trace[22];
|
||||
@ -435,7 +435,8 @@ fn recursive_stream_fold_with_n_service_call() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm, vm_peer_id, &script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id(vm_peer_id);
|
||||
let result = checked_call_vm!(vm, test_params, &script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let actual_fold_state = match &actual_trace[2] {
|
||||
ExecutedState::Fold(fold_result) => fold_result,
|
||||
|
@ -38,7 +38,7 @@ fn empty_stream() {
|
||||
(null)
|
||||
)"#;
|
||||
|
||||
let _ = checked_call_vm!(vm, "", script, "", "");
|
||||
let _ = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -60,12 +60,12 @@ fn stream_merging_v0() {
|
||||
initiator_id, setter_1_id, setter_2_id, setter_3_id, executor_id
|
||||
);
|
||||
|
||||
let initiator_result = checked_call_vm!(initiator, "", &script, "", "");
|
||||
let setter_1_res = checked_call_vm!(setter_1, "", &script, "", initiator_result.data.clone());
|
||||
let setter_2_res = checked_call_vm!(setter_2, "", &script, "", initiator_result.data.clone());
|
||||
let setter_3_res = checked_call_vm!(setter_3, "", &script, "", initiator_result.data);
|
||||
let initiator_result = checked_call_vm!(initiator, <_>::default(), &script, "", "");
|
||||
let setter_1_res = checked_call_vm!(setter_1, <_>::default(), &script, "", initiator_result.data.clone());
|
||||
let setter_2_res = checked_call_vm!(setter_2, <_>::default(), &script, "", initiator_result.data.clone());
|
||||
let setter_3_res = checked_call_vm!(setter_3, <_>::default(), &script, "", initiator_result.data);
|
||||
|
||||
let executor_result_1 = checked_call_vm!(executor, "", &script, "", setter_1_res.data);
|
||||
let executor_result_1 = checked_call_vm!(executor, <_>::default(), &script, "", setter_1_res.data);
|
||||
let actual_trace_1 = trace_from_result(&executor_result_1);
|
||||
|
||||
let unit_call_service_result = "result from unit_call_service";
|
||||
@ -98,7 +98,13 @@ fn stream_merging_v0() {
|
||||
];
|
||||
assert_eq!(actual_trace_1, expected_trace_1);
|
||||
|
||||
let executor_result_2 = checked_call_vm!(executor, "", &script, executor_result_1.data.clone(), setter_2_res.data);
|
||||
let executor_result_2 = checked_call_vm!(
|
||||
executor,
|
||||
<_>::default(),
|
||||
&script,
|
||||
executor_result_1.data.clone(),
|
||||
setter_2_res.data
|
||||
);
|
||||
let actual_trace_2 = trace_from_result(&executor_result_2);
|
||||
|
||||
let expected_trace_2 = vec![
|
||||
@ -136,7 +142,13 @@ fn stream_merging_v0() {
|
||||
];
|
||||
assert_eq!(actual_trace_2, expected_trace_2);
|
||||
|
||||
let executor_result_3 = checked_call_vm!(executor, "", &script, executor_result_2.data.clone(), setter_3_res.data);
|
||||
let executor_result_3 = checked_call_vm!(
|
||||
executor,
|
||||
<_>::default(),
|
||||
&script,
|
||||
executor_result_2.data.clone(),
|
||||
setter_3_res.data
|
||||
);
|
||||
let actual_trace_3 = trace_from_result(&executor_result_3);
|
||||
|
||||
let expected_trace_3 = vec![
|
||||
@ -200,12 +212,12 @@ fn stream_merging_v1() {
|
||||
initiator_id, setter_1_id, setter_2_id, setter_3_id, executor_id
|
||||
);
|
||||
|
||||
let initiator_result = checked_call_vm!(initiator, "", &script, "", "");
|
||||
let setter_1_res = checked_call_vm!(setter_1, "", &script, "", initiator_result.data.clone());
|
||||
let setter_2_res = checked_call_vm!(setter_2, "", &script, "", initiator_result.data.clone());
|
||||
let setter_3_res = checked_call_vm!(setter_3, "", &script, "", initiator_result.data);
|
||||
let initiator_result = checked_call_vm!(initiator, <_>::default(), &script, "", "");
|
||||
let setter_1_res = checked_call_vm!(setter_1, <_>::default(), &script, "", initiator_result.data.clone());
|
||||
let setter_2_res = checked_call_vm!(setter_2, <_>::default(), &script, "", initiator_result.data.clone());
|
||||
let setter_3_res = checked_call_vm!(setter_3, <_>::default(), &script, "", initiator_result.data);
|
||||
|
||||
let executor_result_1 = checked_call_vm!(executor, "", &script, "", setter_1_res.data);
|
||||
let executor_result_1 = checked_call_vm!(executor, <_>::default(), &script, "", setter_1_res.data);
|
||||
let actual_trace_1 = trace_from_result(&executor_result_1);
|
||||
|
||||
let unit_call_service_result = "result from unit_call_service";
|
||||
@ -238,7 +250,13 @@ fn stream_merging_v1() {
|
||||
];
|
||||
assert_eq!(actual_trace_1, expected_trace_1);
|
||||
|
||||
let executor_result_2 = checked_call_vm!(executor, "", &script, executor_result_1.data.clone(), setter_2_res.data);
|
||||
let executor_result_2 = checked_call_vm!(
|
||||
executor,
|
||||
<_>::default(),
|
||||
&script,
|
||||
executor_result_1.data.clone(),
|
||||
setter_2_res.data
|
||||
);
|
||||
let actual_trace_2 = trace_from_result(&executor_result_2);
|
||||
|
||||
let expected_trace_2 = vec![
|
||||
@ -276,7 +294,13 @@ fn stream_merging_v1() {
|
||||
];
|
||||
assert_eq!(actual_trace_2, expected_trace_2);
|
||||
|
||||
let executor_result_3 = checked_call_vm!(executor, "", &script, executor_result_2.data.clone(), setter_3_res.data);
|
||||
let executor_result_3 = checked_call_vm!(
|
||||
executor,
|
||||
<_>::default(),
|
||||
&script,
|
||||
executor_result_2.data.clone(),
|
||||
setter_3_res.data
|
||||
);
|
||||
let actual_trace_3 = trace_from_result(&executor_result_3);
|
||||
|
||||
let expected_trace_3 = vec![
|
||||
@ -340,12 +364,12 @@ fn stream_merging_v2() {
|
||||
initiator_id, setter_1_id, setter_2_id, setter_3_id, executor_id
|
||||
);
|
||||
|
||||
let initiator_result = checked_call_vm!(initiator, "", &script, "", "");
|
||||
let setter_1_res = checked_call_vm!(setter_1, "", &script, "", initiator_result.data.clone());
|
||||
let setter_2_res = checked_call_vm!(setter_2, "", &script, "", initiator_result.data.clone());
|
||||
let setter_3_res = checked_call_vm!(setter_3, "", &script, "", initiator_result.data);
|
||||
let initiator_result = checked_call_vm!(initiator, <_>::default(), &script, "", "");
|
||||
let setter_1_res = checked_call_vm!(setter_1, <_>::default(), &script, "", initiator_result.data.clone());
|
||||
let setter_2_res = checked_call_vm!(setter_2, <_>::default(), &script, "", initiator_result.data.clone());
|
||||
let setter_3_res = checked_call_vm!(setter_3, <_>::default(), &script, "", initiator_result.data);
|
||||
|
||||
let executor_result_1 = checked_call_vm!(executor, "", &script, "", setter_1_res.data);
|
||||
let executor_result_1 = checked_call_vm!(executor, <_>::default(), &script, "", setter_1_res.data);
|
||||
let actual_trace_1 = trace_from_result(&executor_result_1);
|
||||
|
||||
let unit_call_service_result = "result from unit_call_service";
|
||||
@ -378,7 +402,13 @@ fn stream_merging_v2() {
|
||||
];
|
||||
assert_eq!(actual_trace_1, expected_trace_1);
|
||||
|
||||
let executor_result_2 = checked_call_vm!(executor, "", &script, executor_result_1.data.clone(), setter_2_res.data);
|
||||
let executor_result_2 = checked_call_vm!(
|
||||
executor,
|
||||
<_>::default(),
|
||||
&script,
|
||||
executor_result_1.data.clone(),
|
||||
setter_2_res.data
|
||||
);
|
||||
let actual_trace_2 = trace_from_result(&executor_result_2);
|
||||
|
||||
let expected_trace_2 = vec![
|
||||
@ -416,7 +446,13 @@ fn stream_merging_v2() {
|
||||
];
|
||||
assert_eq!(actual_trace_2, expected_trace_2);
|
||||
|
||||
let executor_result_3 = checked_call_vm!(executor, "", &script, executor_result_2.data.clone(), setter_3_res.data);
|
||||
let executor_result_3 = checked_call_vm!(
|
||||
executor,
|
||||
<_>::default(),
|
||||
&script,
|
||||
executor_result_2.data.clone(),
|
||||
setter_3_res.data
|
||||
);
|
||||
let actual_trace_3 = trace_from_result(&executor_result_3);
|
||||
|
||||
let expected_trace_3 = vec![
|
||||
|
@ -36,10 +36,10 @@ fn par_early_exit() {
|
||||
init_peer_id, setter_1_id, setter_2_id, setter_3_id
|
||||
);
|
||||
|
||||
let init_result_1 = checked_call_vm!(init, "", &script, "", "");
|
||||
let setter_1_res = checked_call_vm!(setter_1, "", &script, "", init_result_1.data.clone());
|
||||
let setter_2_res = checked_call_vm!(setter_2, "", &script, "", init_result_1.data.clone());
|
||||
let setter_3_res_1 = checked_call_vm!(setter_3, "", &script, "", init_result_1.data.clone());
|
||||
let init_result_1 = checked_call_vm!(init, <_>::default(), &script, "", "");
|
||||
let setter_1_res = checked_call_vm!(setter_1, <_>::default(), &script, "", init_result_1.data.clone());
|
||||
let setter_2_res = checked_call_vm!(setter_2, <_>::default(), &script, "", init_result_1.data.clone());
|
||||
let setter_3_res_1 = checked_call_vm!(setter_3, <_>::default(), &script, "", init_result_1.data.clone());
|
||||
let actual_trace_1 = trace_from_result(&setter_3_res_1);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -64,21 +64,21 @@ fn par_early_exit() {
|
||||
|
||||
let setter_3_res_2 = checked_call_vm!(
|
||||
setter_3,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
setter_3_res_1.data.clone(),
|
||||
setter_1_res.data.clone()
|
||||
);
|
||||
let setter_3_res_3 = checked_call_vm!(
|
||||
setter_3,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
setter_3_res_2.data.clone(),
|
||||
setter_2_res.data.clone()
|
||||
);
|
||||
let init_result_2 = checked_call_vm!(
|
||||
init,
|
||||
"",
|
||||
<_>::default(),
|
||||
&script,
|
||||
init_result_1.data.clone(),
|
||||
setter_3_res_3.data.clone()
|
||||
@ -142,7 +142,13 @@ fn par_early_exit() {
|
||||
executed_state::request_sent_by(setter_3_id),
|
||||
];
|
||||
let setter_3_malicious_data = raw_data_from_trace(setter_3_malicious_trace);
|
||||
let init_result_3 = call_vm!(init, "", &script, init_result_2.data.clone(), setter_3_malicious_data);
|
||||
let init_result_3 = call_vm!(
|
||||
init,
|
||||
<_>::default(),
|
||||
&script,
|
||||
init_result_2.data.clone(),
|
||||
setter_3_malicious_data
|
||||
);
|
||||
|
||||
let expected_error = UncatchableError::TraceError {
|
||||
trace_error: TraceHandlerError::MergeError(MergeError::IncorrectCallResult(CallResultError::ValuesNotEqual {
|
||||
@ -200,13 +206,25 @@ fn fold_early_exit() {
|
||||
last_peer_checker_id
|
||||
);
|
||||
|
||||
let variables_setter_result = checked_call_vm!(variables_setter, "", &script, "", "");
|
||||
let stream_setter_result = checked_call_vm!(stream_setter, "", &script, "", variables_setter_result.data);
|
||||
let fold_executor_result = checked_call_vm!(fold_executor, "", &script, "", stream_setter_result.data);
|
||||
let error_trigger_result = checked_call_vm!(error_trigger, "", &script, "", fold_executor_result.data);
|
||||
let last_error_receiver_result = checked_call_vm!(last_error_receiver, "", &script, "", error_trigger_result.data);
|
||||
let last_peer_checker_result =
|
||||
checked_call_vm!(last_peer_checker, "", &script, "", last_error_receiver_result.data);
|
||||
let variables_setter_result = checked_call_vm!(variables_setter, <_>::default(), &script, "", "");
|
||||
let stream_setter_result =
|
||||
checked_call_vm!(stream_setter, <_>::default(), &script, "", variables_setter_result.data);
|
||||
let fold_executor_result = checked_call_vm!(fold_executor, <_>::default(), &script, "", stream_setter_result.data);
|
||||
let error_trigger_result = checked_call_vm!(error_trigger, <_>::default(), &script, "", fold_executor_result.data);
|
||||
let last_error_receiver_result = checked_call_vm!(
|
||||
last_error_receiver,
|
||||
<_>::default(),
|
||||
&script,
|
||||
"",
|
||||
error_trigger_result.data
|
||||
);
|
||||
let last_peer_checker_result = checked_call_vm!(
|
||||
last_peer_checker,
|
||||
<_>::default(),
|
||||
&script,
|
||||
"",
|
||||
last_error_receiver_result.data
|
||||
);
|
||||
let actual_trace = trace_from_result(&last_peer_checker_result);
|
||||
|
||||
let unit_call_service_result = "result from unit_call_service";
|
||||
@ -298,13 +316,25 @@ fn fold_par_early_exit() {
|
||||
last_peer_checker_id
|
||||
);
|
||||
|
||||
let variables_setter_result = checked_call_vm!(variables_setter, "", &script, "", "");
|
||||
let stream_setter_result = checked_call_vm!(stream_setter, "", &script, "", variables_setter_result.data);
|
||||
let fold_executor_result = checked_call_vm!(fold_executor, "", &script, "", stream_setter_result.data);
|
||||
let error_trigger_result = checked_call_vm!(error_trigger, "", &script, "", fold_executor_result.data);
|
||||
let last_error_receiver_result = checked_call_vm!(last_error_receiver, "", &script, "", error_trigger_result.data);
|
||||
let last_peer_checker_result =
|
||||
checked_call_vm!(last_peer_checker, "", &script, "", last_error_receiver_result.data);
|
||||
let variables_setter_result = checked_call_vm!(variables_setter, <_>::default(), &script, "", "");
|
||||
let stream_setter_result =
|
||||
checked_call_vm!(stream_setter, <_>::default(), &script, "", variables_setter_result.data);
|
||||
let fold_executor_result = checked_call_vm!(fold_executor, <_>::default(), &script, "", stream_setter_result.data);
|
||||
let error_trigger_result = checked_call_vm!(error_trigger, <_>::default(), &script, "", fold_executor_result.data);
|
||||
let last_error_receiver_result = checked_call_vm!(
|
||||
last_error_receiver,
|
||||
<_>::default(),
|
||||
&script,
|
||||
"",
|
||||
error_trigger_result.data
|
||||
);
|
||||
let last_peer_checker_result = checked_call_vm!(
|
||||
last_peer_checker,
|
||||
<_>::default(),
|
||||
&script,
|
||||
"",
|
||||
last_error_receiver_result.data
|
||||
);
|
||||
let actual_trace = trace_from_result(&last_peer_checker_result);
|
||||
|
||||
let unit_call_service_result = "result from unit_call_service";
|
||||
|
@ -66,8 +66,8 @@ fn fold_with_inner_call() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let init_peer_id = String::from("some_init_peer_id");
|
||||
let result = checked_call_vm!(set_variable_vm, init_peer_id.clone(), script.clone(), "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id("init_peer_id");
|
||||
let result = checked_call_vm!(set_variable_vm, test_params.clone(), script.clone(), "", "");
|
||||
let mut data = result.data;
|
||||
|
||||
let first_arg_tetraplet = SecurityTetraplet {
|
||||
@ -78,7 +78,7 @@ fn fold_with_inner_call() {
|
||||
};
|
||||
|
||||
let second_arg_tetraplet = SecurityTetraplet {
|
||||
peer_pk: init_peer_id.clone(),
|
||||
peer_pk: test_params.init_peer_id.clone(),
|
||||
service_id: String::new(),
|
||||
function_name: String::new(),
|
||||
json_path: String::new(),
|
||||
@ -87,7 +87,7 @@ fn fold_with_inner_call() {
|
||||
let expected_tetraplets = vec![vec![first_arg_tetraplet], vec![second_arg_tetraplet]];
|
||||
let expected_tetraplets = Rc::new(RefCell::new(expected_tetraplets));
|
||||
for i in 0..10 {
|
||||
let result = checked_call_vm!(client_vms[i].0, init_peer_id.clone(), script.clone(), "", data);
|
||||
let result = checked_call_vm!(client_vms[i].0, test_params.clone(), script.clone(), "", data);
|
||||
data = result.data;
|
||||
|
||||
assert_eq!(client_vms[i].1, expected_tetraplets);
|
||||
@ -127,8 +127,8 @@ fn fold_json_path() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let init_peer_id = String::from("some_init_peer_id");
|
||||
let result = checked_call_vm!(set_variable_vm, init_peer_id.clone(), script.clone(), "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id("some_init_peer_id");
|
||||
let result = checked_call_vm!(set_variable_vm, test_params.clone(), script.clone(), "", "");
|
||||
|
||||
let first_arg_tetraplet = SecurityTetraplet {
|
||||
peer_pk: set_variable_vm_peer_id,
|
||||
@ -138,7 +138,7 @@ fn fold_json_path() {
|
||||
};
|
||||
|
||||
let second_arg_tetraplet = SecurityTetraplet {
|
||||
peer_pk: init_peer_id.clone(),
|
||||
peer_pk: test_params.init_peer_id.clone(),
|
||||
service_id: String::new(),
|
||||
function_name: String::new(),
|
||||
json_path: String::new(),
|
||||
@ -146,7 +146,7 @@ fn fold_json_path() {
|
||||
|
||||
let expected_tetraplets = vec![vec![first_arg_tetraplet], vec![second_arg_tetraplet]];
|
||||
let expected_tetraplets = Rc::new(RefCell::new(expected_tetraplets));
|
||||
checked_call_vm!(client_vm, init_peer_id, script, "", result.data);
|
||||
checked_call_vm!(client_vm, test_params, script, "", result.data);
|
||||
assert_eq!(arg_tetraplets, expected_tetraplets);
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ fn check_tetraplet_works_correctly() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", script.clone(), "", "");
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), script.clone(), "", "");
|
||||
|
||||
let first_arg_tetraplet = SecurityTetraplet {
|
||||
peer_pk: set_variable_vm_peer_id.clone(),
|
||||
@ -192,7 +192,7 @@ fn check_tetraplet_works_correctly() {
|
||||
|
||||
let expected_tetraplets = vec![vec![first_arg_tetraplet], vec![second_arg_tetraplet]];
|
||||
let expected_tetraplets = Rc::new(RefCell::new(expected_tetraplets));
|
||||
checked_call_vm!(client_vm, "", script, "", result.data);
|
||||
checked_call_vm!(client_vm, <_>::default(), script, "", result.data);
|
||||
assert_eq!(arg_tetraplets, expected_tetraplets);
|
||||
}
|
||||
|
||||
@ -281,7 +281,8 @@ fn tetraplet_with_wasm_modules() {
|
||||
|
||||
let mut vm = create_avm(host_func, local_peer_id);
|
||||
|
||||
let result = checked_call_vm!(vm, ADMIN_PEER_PK, script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id(ADMIN_PEER_PK);
|
||||
let result = checked_call_vm!(vm, test_params, script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string("Ok");
|
||||
|
||||
|
@ -35,8 +35,8 @@ fn ap_with_scalars() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", &script, "", "");
|
||||
let result = checked_call_vm!(vm_2, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm_2, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = vec![
|
||||
@ -61,7 +61,7 @@ fn ap_with_string_literal() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", script, "", "");
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = vec![
|
||||
@ -85,7 +85,7 @@ fn ap_with_bool_literal() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", script, "", "");
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = vec![executed_state::ap(Some(0)), executed_state::scalar(json!([true]))];
|
||||
@ -106,7 +106,7 @@ fn ap_with_number_literal() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", script, "", "");
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = vec![executed_state::ap(Some(0)), executed_state::scalar(json!([100]))];
|
||||
@ -122,12 +122,12 @@ fn ap_with_last_error() {
|
||||
|
||||
let script = f!(r#"
|
||||
(seq
|
||||
(ap %last_error% $stream)
|
||||
(ap %last_error% $stream)
|
||||
(call "{vm_1_peer_id}" ("" "") [$stream])
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", script, "", "");
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = vec![executed_state::ap(Some(0)), executed_state::scalar(json!([null]))];
|
||||
@ -136,6 +136,27 @@ fn ap_with_last_error() {
|
||||
assert!(result.next_peer_pks.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ap_with_timestamp() {
|
||||
let vm_1_peer_id = "vm_1_peer_id";
|
||||
let mut vm_1 = create_avm(echo_call_service(), vm_1_peer_id);
|
||||
|
||||
let script = f!(r#"
|
||||
(seq
|
||||
(ap %timestamp% scalar)
|
||||
(call "{vm_1_peer_id}" ("" "") [scalar])
|
||||
)
|
||||
"#);
|
||||
|
||||
let test_params = TestRunParameters::from_timestamp(1337);
|
||||
let result = checked_call_vm!(vm_1, test_params.clone(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = vec![executed_state::scalar_number(test_params.timestamp)];
|
||||
|
||||
assert_eq!(actual_trace, expected_state);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ap_with_dst_stream() {
|
||||
let vm_1_peer_id = "vm_1_peer_id";
|
||||
@ -155,8 +176,8 @@ fn ap_with_dst_stream() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm_1, "", &script, "", "");
|
||||
let result = checked_call_vm!(vm_2, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_1, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm_2, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = vec![
|
||||
|
@ -30,7 +30,8 @@ fn current_peer_id_call() {
|
||||
(call %init_peer_id% ("{service_id}" "{function_name}") [] result_name)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm, vm_peer_id, script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id(vm_peer_id);
|
||||
let result = checked_call_vm!(vm, test_params, script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![executed_state::scalar_string("result from unit_call_service")];
|
||||
@ -42,13 +43,29 @@ fn current_peer_id_call() {
|
||||
(call "{vm_peer_id}" ("{service_id}" "{function_name}") [] result_name)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script.clone(), "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script.clone(), "", "");
|
||||
|
||||
// test that empty string for data works
|
||||
let result_with_empty_string = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result_with_empty_string = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
assert_eq!(result_with_empty_string, result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_with_timestamp() {
|
||||
let vm_peer_id = "test_peer_id";
|
||||
let mut vm = create_avm(echo_call_service(), vm_peer_id);
|
||||
|
||||
let script = r#"(call %init_peer_id% ("" "") [%timestamp%] result_name)"#;
|
||||
|
||||
let test_params = TestRunParameters::new(vm_peer_id, 1337);
|
||||
let result = checked_call_vm!(vm, test_params.clone(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![executed_state::scalar_number(test_params.timestamp)];
|
||||
|
||||
assert_eq!(actual_trace, expected_trace);
|
||||
}
|
||||
|
||||
// Check that specifying remote peer id in call will result its appearing in next_peer_pks.
|
||||
#[test]
|
||||
fn remote_peer_id_call() {
|
||||
@ -58,7 +75,7 @@ fn remote_peer_id_call() {
|
||||
let remote_peer_id = String::from("some_remote_peer_id");
|
||||
let script = f!(r#"(call "{remote_peer_id}" ("local_service_id" "local_fn_name") ["arg"] result_name)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::request_sent_by(some_local_peer_id);
|
||||
@ -81,8 +98,8 @@ fn variables() {
|
||||
)
|
||||
"#;
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
assert!(result.next_peer_pks.is_empty());
|
||||
}
|
||||
@ -101,7 +118,7 @@ fn duplicate_variables() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = call_vm!(vm, "asd", script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let expected_error = UncatchableError::ShadowingIsNotAllowed(variable_name.to_string());
|
||||
assert!(check_error(&result, expected_error));
|
||||
@ -129,8 +146,8 @@ fn string_parameters() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string("arg1");
|
||||
|
@ -29,7 +29,7 @@ fn fail_with_last_error() {
|
||||
(fail %last_error%)
|
||||
)"#);
|
||||
|
||||
let result = call_vm!(vm, "", script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let expected_error = CatchableError::UserError {
|
||||
error: rc!(json!({
|
||||
@ -53,15 +53,15 @@ fn fail_with_literals() {
|
||||
(fail %last_error%)
|
||||
)"#;
|
||||
|
||||
let init_peer_id = "init_peer_id";
|
||||
let result = call_vm!(vm, init_peer_id, script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id("init_peer_id");
|
||||
let result = call_vm!(vm, test_params.clone(), script, "", "");
|
||||
|
||||
let expected_error = CatchableError::UserError {
|
||||
error: rc!(json!( {
|
||||
"error_code": 1337i64,
|
||||
"instruction": "fail 1337 error message",
|
||||
"message": "error message",
|
||||
"peer_id": init_peer_id,
|
||||
"peer_id": test_params.init_peer_id,
|
||||
})),
|
||||
};
|
||||
assert!(check_error(&result, expected_error));
|
||||
@ -85,7 +85,8 @@ fn fail_with_last_error_tetraplets() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let _ = checked_call_vm!(vm, local_peer_id, script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id(local_peer_id);
|
||||
let _ = checked_call_vm!(vm, test_params, script, "", "");
|
||||
assert_eq!(
|
||||
tetraplet_anchor.borrow()[0][0],
|
||||
SecurityTetraplet::new(local_peer_id, fallible_service_id, local_fn_name, "")
|
||||
@ -107,7 +108,8 @@ fn fail_with_literals_tetraplets() {
|
||||
(call "{local_peer_id}" ("" "") [%last_error%])
|
||||
)"#);
|
||||
|
||||
let _ = checked_call_vm!(vm, local_peer_id, script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id(local_peer_id);
|
||||
let _ = checked_call_vm!(vm, test_params, script, "", "");
|
||||
assert_eq!(
|
||||
tetraplet_anchor.borrow()[0][0],
|
||||
SecurityTetraplet::literal_tetraplet(local_peer_id)
|
||||
|
@ -37,8 +37,8 @@ fn lfold() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", lfold, "", "");
|
||||
let result = checked_call_vm!(vm, "", lfold, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), lfold, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), lfold, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string_array(vec!["1", "2", "3", "4", "5"]);
|
||||
@ -71,8 +71,8 @@ fn rfold() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", rfold, "", "");
|
||||
let result = checked_call_vm!(vm, "", rfold, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), rfold, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), rfold, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
assert_eq!(actual_trace.len(), 6);
|
||||
@ -113,8 +113,8 @@ fn inner_fold() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, "", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
assert_eq!(actual_trace.len(), 27);
|
||||
@ -158,7 +158,7 @@ fn inner_fold_with_same_iterator() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = call_vm!(vm, "", script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let expected_error = PreparationError::AIRParseError("".to_string());
|
||||
assert_eq!(result.ret_code, expected_error.to_error_code());
|
||||
@ -180,8 +180,8 @@ fn empty_iterable_fold() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", empty_fold, "", "");
|
||||
let result = checked_call_vm!(vm, "", empty_fold, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), empty_fold, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), empty_fold, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar(json!([]));
|
||||
@ -202,7 +202,7 @@ fn empty_literal_array_fold() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(vm, "", empty_fold, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), empty_fold, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
assert!(actual_trace.is_empty());
|
||||
@ -224,8 +224,8 @@ fn empty_fold_json_path() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", empty_fold, "", "");
|
||||
let result = checked_call_vm!(vm, "", empty_fold, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), empty_fold, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), empty_fold, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![executed_state::scalar(json!({ "messages": [] }))];
|
||||
@ -253,8 +253,8 @@ fn fold_with_join() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", fold_with_join, "", "");
|
||||
let result = checked_call_vm!(vm, "", fold_with_join, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), fold_with_join, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), fold_with_join, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
assert_eq!(actual_trace.len(), 4);
|
||||
@ -279,8 +279,8 @@ fn lambda() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, "", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar(json!({ "array": ["1", "2", "3", "4", "5"] }));
|
||||
@ -330,13 +330,13 @@ fn shadowing() {
|
||||
)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(set_variables_vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm_a, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_b, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_a, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_b, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_a, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm_b, "", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variables_vm, <_>::default(), script, "", "");
|
||||
let result = checked_call_vm!(vm_a, <_>::default(), script, "", result.data);
|
||||
let result = checked_call_vm!(vm_b, <_>::default(), script, "", result.data);
|
||||
let result = checked_call_vm!(vm_a, <_>::default(), script, "", result.data);
|
||||
let result = checked_call_vm!(vm_b, <_>::default(), script, "", result.data);
|
||||
let result = checked_call_vm!(vm_a, <_>::default(), script, "", result.data);
|
||||
let result = checked_call_vm!(vm_b, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![
|
||||
@ -366,13 +366,13 @@ fn shadowing_scope() {
|
||||
let mut vm_a = create_avm(echo_call_service(), "A");
|
||||
let mut vm_b = create_avm(echo_call_service(), "B");
|
||||
|
||||
let result = checked_call_vm!(set_variables_vm, "", script.clone(), "", "");
|
||||
let result = checked_call_vm!(vm_a, "", script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(vm_b, "", script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(vm_a, "", script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(vm_b, "", script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(set_variables_vm, <_>::default(), script.clone(), "", "");
|
||||
let result = checked_call_vm!(vm_a, <_>::default(), script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(vm_b, <_>::default(), script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(vm_a, <_>::default(), script.clone(), "", result.data);
|
||||
let result = checked_call_vm!(vm_b, <_>::default(), script.clone(), "", result.data);
|
||||
|
||||
vm_a.call(script, "", result.data, "")
|
||||
vm_a.call(script, "", result.data, <_>::default())
|
||||
}
|
||||
|
||||
let variable_shadowing_script = r#"
|
||||
|
@ -39,8 +39,8 @@ fn match_equal() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string("result_1");
|
||||
@ -71,8 +71,8 @@ fn match_not_equal() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string("result_2");
|
||||
@ -100,8 +100,8 @@ fn match_with_string() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string("result_1");
|
||||
@ -129,8 +129,40 @@ fn match_with_init_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);
|
||||
let test_params = TestRunParameters::from_init_peer_id(local_peer_id);
|
||||
let result = checked_call_vm!(set_variable_vm, test_params.clone(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, test_params.clone(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_executed_call_result = executed_state::scalar_string("result_1");
|
||||
|
||||
assert_eq!(actual_trace.len(), 2);
|
||||
assert_eq!(actual_trace[1], expected_executed_call_result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_with_timestamp() {
|
||||
let set_variable_peer_id = "set_variable_peer_id";
|
||||
let mut set_variable_vm = create_avm(echo_call_service(), set_variable_peer_id);
|
||||
|
||||
let local_peer_id = "local_peer_id";
|
||||
let mut vm = create_avm(echo_call_service(), local_peer_id);
|
||||
|
||||
let timestamp = 1337;
|
||||
let script = f!(r#"
|
||||
(seq
|
||||
(call "{set_variable_peer_id}" ("" "") [{timestamp}] value_1)
|
||||
(xor
|
||||
(match value_1 %timestamp%
|
||||
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_1"] result_1)
|
||||
)
|
||||
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["result_2"] result_2)
|
||||
)
|
||||
)"#);
|
||||
|
||||
let test_params = TestRunParameters::from_timestamp(timestamp);
|
||||
let result = checked_call_vm!(set_variable_vm, test_params.clone(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, test_params.clone(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_executed_call_result = executed_state::scalar_string("result_1");
|
||||
@ -152,7 +184,7 @@ fn match_with_equal_numbers() {
|
||||
(null)
|
||||
)";
|
||||
|
||||
let result = call_vm!(vm, "asd", script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
assert!(is_interpreter_succeded(&result));
|
||||
}
|
||||
@ -176,13 +208,13 @@ fn match_without_xor() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = call_vm!(set_variable_vm, "", &script, "", "");
|
||||
let result = call_vm!(vm, "", &script, "", result.data);
|
||||
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), &script, "", result.data);
|
||||
|
||||
let expected_error = CatchableError::MatchValuesNotEqual;
|
||||
assert!(check_error(&result, expected_error));
|
||||
|
||||
let result = call_vm!(vm, "", script, "", result.data);
|
||||
let result = call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let expected_error = CatchableError::MatchValuesNotEqual;
|
||||
assert!(check_error(&result, expected_error));
|
||||
@ -213,7 +245,7 @@ fn match_with_two_xors() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let mut actual_trace = trace_from_result(&result);
|
||||
let expected_executed_call_result = executed_state::request_sent_by(local_peer_id);
|
||||
@ -248,8 +280,8 @@ fn issue_165() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let setter_result = checked_call_vm!(result_setter, "", &script, "", "");
|
||||
let echo_result = checked_call_vm!(echo_peer, "", &script, "", setter_result.data);
|
||||
let setter_result = checked_call_vm!(result_setter, <_>::default(), &script, "", "");
|
||||
let echo_result = checked_call_vm!(echo_peer, <_>::default(), &script, "", setter_result.data);
|
||||
|
||||
let trace = trace_from_result(&echo_result);
|
||||
assert_eq!(trace.last().unwrap(), &executed_state::scalar(json!(1)));
|
||||
|
@ -39,8 +39,8 @@ fn mismatch_equal() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string("result_2");
|
||||
@ -71,8 +71,8 @@ fn mismatch_not_equal() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string("result_1");
|
||||
@ -100,8 +100,8 @@ fn mismatch_with_string() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string("result_2");
|
||||
@ -129,13 +129,13 @@ fn mismatch_without_xor() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = call_vm!(set_variable_vm, "asd", &script, "", "");
|
||||
let result = call_vm!(vm, "asd", &script, "", result.data);
|
||||
let result = call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = call_vm!(vm, <_>::default(), &script, "", result.data);
|
||||
|
||||
let expected_error = CatchableError::MismatchValuesEqual;
|
||||
assert!(check_error(&result, expected_error));
|
||||
|
||||
let result = call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let expected_error = CatchableError::MismatchValuesEqual;
|
||||
assert!(check_error(&result, expected_error));
|
||||
@ -166,7 +166,7 @@ fn mismatch_with_two_xors() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let mut actual_trace = trace_from_result(&result);
|
||||
let expected_executed_call_result = executed_state::request_sent_by(local_peer_id);
|
||||
|
@ -56,12 +56,18 @@ fn new_with_global_streams_seq() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", &script, "", "");
|
||||
let vm_1_result = checked_call_vm!(local_vm_1, "", &script, "", result.data);
|
||||
let vm_2_result = checked_call_vm!(local_vm_2, "", &script, "", vm_1_result.data.clone());
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let vm_1_result = checked_call_vm!(local_vm_1, <_>::default(), &script, "", result.data);
|
||||
let vm_2_result = checked_call_vm!(local_vm_2, <_>::default(), &script, "", vm_1_result.data.clone());
|
||||
|
||||
let vm_1_result = checked_call_vm!(local_vm_1, "", &script, vm_1_result.data, vm_2_result.data.clone());
|
||||
let vm_2_result = checked_call_vm!(local_vm_2, "", script, vm_2_result.data, vm_1_result.data);
|
||||
let vm_1_result = checked_call_vm!(
|
||||
local_vm_1,
|
||||
<_>::default(),
|
||||
&script,
|
||||
vm_1_result.data,
|
||||
vm_2_result.data.clone()
|
||||
);
|
||||
let vm_2_result = checked_call_vm!(local_vm_2, <_>::default(), script, vm_2_result.data, vm_1_result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&vm_2_result);
|
||||
let expected_trace = vec![
|
||||
@ -105,7 +111,7 @@ fn several_restrictions() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![
|
||||
@ -147,7 +153,7 @@ fn check_influence_to_not_restricted() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![
|
||||
@ -188,8 +194,8 @@ fn new_in_fold_with_ap() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", &script, "", "");
|
||||
let result = checked_call_vm!(vm, "", script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![
|
||||
@ -241,8 +247,8 @@ fn new_with_errors() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "", &script, "", "");
|
||||
let result = call_vm!(faillible_vm, "", script, "", result.data);
|
||||
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
|
||||
let result = call_vm!(faillible_vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![
|
||||
@ -301,8 +307,8 @@ fn new_with_global_scalars() {
|
||||
(call "{variable_receiver_peer_id}" ("" "") [scalar])
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", &script, "", "");
|
||||
let result = checked_call_vm!(variable_receiver, "", &script, "", result.data);
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(variable_receiver, <_>::default(), &script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -383,7 +389,7 @@ fn new_with_scalars_in_lfold_with_outside_next() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(test_vm, "", &script, "", "");
|
||||
let result = checked_call_vm!(test_vm, <_>::default(), &script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -440,7 +446,7 @@ fn new_with_scalars_in_rfold_with_outside_next() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(test_vm, "", &script, "", "");
|
||||
let result = checked_call_vm!(test_vm, <_>::default(), &script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
@ -500,7 +506,7 @@ fn new_with_scalars_in_fold_with_inside_next() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(test_vm, "", &script, "", "");
|
||||
let result = checked_call_vm!(test_vm, <_>::default(), &script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
|
@ -28,7 +28,7 @@ fn par_remote_remote() {
|
||||
(call "remote_peer_id_2" ("service_id" "fn_name") [] g)
|
||||
)"#;
|
||||
|
||||
let mut result = checked_call_vm!(vm, "", script, "", "");
|
||||
let mut result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let actual_peers: HashSet<_> = result.next_peer_pks.drain(..).collect();
|
||||
let expected_peers: HashSet<_> =
|
||||
@ -48,7 +48,7 @@ fn par_local_remote() {
|
||||
(call "remote_peer_id_2" ("service_id" "fn_name") [] g)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
assert_eq!(result.next_peer_pks, vec![String::from("remote_peer_id_2")]);
|
||||
}
|
||||
|
@ -26,13 +26,13 @@ fn seq_remote_remote() {
|
||||
(call "remote_peer_id_2" ("service_id" "fn_name") [] g)
|
||||
)"#;
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
assert_eq!(result.next_peer_pks, vec![String::from("remote_peer_id_1")]);
|
||||
|
||||
let initial_trace = vec![executed_state::scalar_string("")];
|
||||
let initial_data = raw_data_from_trace(initial_trace);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", initial_data);
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", initial_data);
|
||||
|
||||
assert_eq!(result.next_peer_pks, vec![String::from("remote_peer_id_2")]);
|
||||
}
|
||||
@ -49,6 +49,6 @@ fn seq_local_remote() {
|
||||
(call "{remote_peer_id}" ("service_id" "fn_name") [] g)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
assert_eq!(result.next_peer_pks, vec![remote_peer_id]);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ fn xor() {
|
||||
(call "{local_peer_id}" ("service_id_2" "local_fn_name") [] result_2)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_call_result = executed_state::scalar_string("success result from fallible_call_service");
|
||||
@ -47,7 +47,7 @@ fn xor() {
|
||||
(call "{local_peer_id}" ("service_id_1" "local_fn_name") [] result_2)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
assert_eq!(actual_trace.len(), 1);
|
||||
@ -68,7 +68,7 @@ fn xor_var_not_found() {
|
||||
(call "{local_peer_id}" ("service_id_2" "local_fn_name") ["expected"] result)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
assert_eq!(actual_trace[0], executed_state::par(1, 0));
|
||||
@ -93,7 +93,7 @@ fn xor_multiple_variables_found() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = call_vm!(set_variables_vm, "asd", &script, "", "");
|
||||
let result = call_vm!(set_variables_vm, <_>::default(), &script, "", "");
|
||||
|
||||
let expected_error = UncatchableError::ShadowingIsNotAllowed(variable_name.to_string());
|
||||
assert!(check_error(&result, expected_error));
|
||||
@ -125,7 +125,7 @@ fn xor_par() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", &script, "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), &script, "", "");
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let success_result = "success result from fallible_call_service";
|
||||
@ -144,7 +144,7 @@ fn xor_par() {
|
||||
|
||||
assert_eq!(actual_trace, expected_trace);
|
||||
|
||||
let result = checked_call_vm!(vm, "asd", script, "", result.data);
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
assert_eq!(actual_trace, expected_trace);
|
||||
@ -163,8 +163,8 @@ fn last_error_with_xor() {
|
||||
(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);
|
||||
let result = checked_call_vm!(faillible_vm, <_>::default(), script.clone(), "", "");
|
||||
let result = checked_call_vm!(vm, <_>::default(), script, "", result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_state = executed_state::scalar_string(
|
||||
|
@ -59,7 +59,7 @@ fn join_chat_1() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let client_1_result = checked_call_vm!(client_1, "asd", &script, "", "");
|
||||
let client_1_result = checked_call_vm!(client_1, <_>::default(), &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)];
|
||||
@ -67,7 +67,7 @@ fn join_chat_1() {
|
||||
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_result = checked_call_vm!(relay_1, <_>::default(), &script, client_1_result.data, "");
|
||||
|
||||
let relay_1_actual_trace = trace_from_result(&relay_1_result);
|
||||
let relay_1_expected_trace = vec![
|
||||
@ -78,7 +78,7 @@ fn join_chat_1() {
|
||||
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_result = checked_call_vm!(remote, <_>::default(), &script, relay_1_result.data, "");
|
||||
|
||||
let remote_actual_trace = trace_from_result(&remote_result);
|
||||
let remote_expected_trace = vec![
|
||||
@ -106,7 +106,7 @@ fn join_chat_1() {
|
||||
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_result = checked_call_vm!(relay_1, <_>::default(), &script, remote_result.data.clone(), "");
|
||||
|
||||
let relay_1_actual_trace = trace_from_result(&relay_1_result);
|
||||
|
||||
@ -130,7 +130,7 @@ fn join_chat_1() {
|
||||
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_result = checked_call_vm!(client_1, <_>::default(), &script, relay_1_result.data, "");
|
||||
|
||||
let client_1_actual_trace = trace_from_result(&client_1_result);
|
||||
|
||||
@ -154,7 +154,7 @@ fn join_chat_1() {
|
||||
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_result = checked_call_vm!(relay_2, <_>::default(), &script, remote_result.data, "");
|
||||
|
||||
let relay_2_actual_trace = trace_from_result(&relay_2_result);
|
||||
|
||||
@ -178,7 +178,7 @@ fn join_chat_1() {
|
||||
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_result = checked_call_vm!(client_2, <_>::default(), script, relay_2_result.data, "");
|
||||
|
||||
let client_2_actual_trace = trace_from_result(&client_2_result);
|
||||
|
||||
@ -235,11 +235,11 @@ fn join_chat_2() {
|
||||
)
|
||||
"#);
|
||||
|
||||
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_result = checked_call_vm!(client_1, <_>::default(), &script, "", "");
|
||||
let relay_1_result = checked_call_vm!(relay_1, <_>::default(), &script, client_1_result.data, "");
|
||||
let remote_result = checked_call_vm!(remote, <_>::default(), &script, relay_1_result.data, "");
|
||||
let relay_1_result = checked_call_vm!(relay_1, <_>::default(), &script, remote_result.data, "");
|
||||
let client_1_result = checked_call_vm!(client_1, <_>::default(), script, relay_1_result.data, "");
|
||||
|
||||
let client_1_actual_trace = trace_from_result(&client_1_result);
|
||||
|
||||
@ -295,12 +295,13 @@ fn init_peer_id() {
|
||||
)
|
||||
"#);
|
||||
|
||||
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 test_params = TestRunParameters::from_init_peer_id(initiator_peer_id);
|
||||
let initiator_1_result = checked_call_vm!(initiator, test_params.clone(), &script, "", "");
|
||||
let client_1_result = checked_call_vm!(client_1, test_params.clone(), &script, initiator_1_result.data, "");
|
||||
let relay_1_result = checked_call_vm!(relay_1, test_params.clone(), &script, client_1_result.data, "");
|
||||
let remote_result = checked_call_vm!(remote, test_params.clone(), &script, relay_1_result.data, "");
|
||||
let relay_1_result = checked_call_vm!(relay_1, test_params.clone(), &script, remote_result.data, "");
|
||||
let client_1_result = checked_call_vm!(client_1, test_params.clone(), &script, relay_1_result.data, "");
|
||||
|
||||
let client_1_actual_trace = trace_from_result(&client_1_result);
|
||||
|
||||
@ -319,7 +320,7 @@ fn init_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_result = checked_call_vm!(initiator, test_params.clone(), script, client_1_result.data, "");
|
||||
|
||||
let initiator_1_actual_trace = trace_from_result(&initiator_1_result);
|
||||
|
||||
|
@ -65,8 +65,9 @@ fn create_service() {
|
||||
|
||||
let script = include_str!("./scripts/create_service.clj");
|
||||
|
||||
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 test_params = TestRunParameters::from_init_peer_id("init_peer_id");
|
||||
let result = checked_call_vm!(set_variables_vm, test_params.clone(), script, "", "");
|
||||
let result = checked_call_vm!(vm, test_params.clone(), script, "", result.data);
|
||||
|
||||
let add_module_response = "add_module response";
|
||||
let add_blueprint_response = "add_blueprint response";
|
||||
|
@ -176,15 +176,17 @@ fn dashboard() {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let test_params = TestRunParameters::from_init_peer_id(client_id.clone());
|
||||
|
||||
// -> client 1
|
||||
let client_1_result = checked_call_vm!(client, &client_id, script, "", "");
|
||||
let client_1_result = checked_call_vm!(client, test_params.clone(), script, "", "");
|
||||
let next_peer_pks = into_hashset(client_1_result.next_peer_pks);
|
||||
let mut all_peer_pks = into_hashset(known_peer_ids.clone());
|
||||
all_peer_pks.insert(relay_id.clone());
|
||||
assert_eq!(next_peer_pks, all_peer_pks);
|
||||
|
||||
// client 1 -> relay 1
|
||||
let relay_1_result = checked_call_vm!(relay, &client_id, script, client_1_result.data.clone(), "");
|
||||
let relay_1_result = checked_call_vm!(relay, test_params.clone(), script, client_1_result.data.clone(), "");
|
||||
let next_peer_pks = into_hashset(relay_1_result.next_peer_pks.clone());
|
||||
all_peer_pks.remove(&relay_id);
|
||||
all_peer_pks.insert(client_id.clone());
|
||||
@ -193,7 +195,7 @@ fn dashboard() {
|
||||
// relay 1 -> client 2
|
||||
let client_2_result = checked_call_vm!(
|
||||
client,
|
||||
&client_id,
|
||||
test_params.clone(),
|
||||
script,
|
||||
client_1_result.data.clone(),
|
||||
relay_1_result.data.clone()
|
||||
@ -214,7 +216,7 @@ fn dashboard() {
|
||||
let prev_result = std::mem::replace(&mut avm.prev_result, vec![]);
|
||||
let known_peer_result = checked_call_vm!(
|
||||
avm.vm,
|
||||
client_id.clone(),
|
||||
test_params.clone(),
|
||||
script,
|
||||
prev_result,
|
||||
client_1_result.data.clone()
|
||||
@ -225,7 +227,7 @@ fn dashboard() {
|
||||
|
||||
relay_2_result = checked_call_vm!(
|
||||
relay,
|
||||
client_id.clone(),
|
||||
test_params.clone(),
|
||||
script,
|
||||
relay_2_result.data.clone(),
|
||||
avm.prev_result.clone()
|
||||
@ -234,7 +236,7 @@ fn dashboard() {
|
||||
|
||||
client_3_result = checked_call_vm!(
|
||||
client,
|
||||
client_id.clone(),
|
||||
test_params.clone(),
|
||||
script,
|
||||
client_3_result.data.clone(),
|
||||
relay_2_result.data.clone()
|
||||
@ -258,7 +260,13 @@ fn dashboard() {
|
||||
// peers 2 -> relay 3 -> client 4
|
||||
for avm in known_peers.iter_mut() {
|
||||
let prev_result = std::mem::replace(&mut avm.prev_result, vec![]);
|
||||
let known_peer_result = checked_call_vm!(avm.vm, &client_id, script, prev_result, relay_1_result.data.clone());
|
||||
let known_peer_result = checked_call_vm!(
|
||||
avm.vm,
|
||||
test_params.clone(),
|
||||
script,
|
||||
prev_result,
|
||||
relay_1_result.data.clone()
|
||||
);
|
||||
all_peer_pks.remove(&avm.peer_id);
|
||||
let next_peer_pks = into_hashset(known_peer_result.next_peer_pks.clone());
|
||||
assert_eq!(next_peer_pks, all_peer_pks);
|
||||
@ -269,7 +277,7 @@ fn dashboard() {
|
||||
|
||||
relay_3_result = checked_call_vm!(
|
||||
relay,
|
||||
&client_id,
|
||||
test_params.clone(),
|
||||
script,
|
||||
relay_3_result.data.clone(),
|
||||
avm.prev_result.clone()
|
||||
@ -279,7 +287,7 @@ fn dashboard() {
|
||||
// client -> peers -> relay -> client
|
||||
client_4_result = checked_call_vm!(
|
||||
client,
|
||||
&client_id,
|
||||
test_params.clone(),
|
||||
script,
|
||||
client_4_result.data.clone(),
|
||||
relay_3_result.data.clone()
|
||||
@ -306,14 +314,15 @@ fn dashboard() {
|
||||
|
||||
let prev_data = known_peers[j].prev_result.clone();
|
||||
let data = known_peers[i].prev_result.clone();
|
||||
let known_peer_i_j_result = checked_call_vm!(known_peers[j].vm, &client_id, script, prev_data, data);
|
||||
let known_peer_i_j_result =
|
||||
checked_call_vm!(known_peers[j].vm, test_params.clone(), script, prev_data, data);
|
||||
assert_eq!(known_peer_i_j_result.next_peer_pks, vec![relay_id.clone()]);
|
||||
|
||||
known_peers[j].prev_result = known_peer_i_j_result.data;
|
||||
|
||||
relay_4_result = checked_call_vm!(
|
||||
relay,
|
||||
&client_id,
|
||||
test_params.clone(),
|
||||
script,
|
||||
relay_4_result.data.clone(),
|
||||
known_peers[j].prev_result.clone()
|
||||
@ -323,7 +332,7 @@ fn dashboard() {
|
||||
// client -> peers -> relay -> client
|
||||
client_5_result = checked_call_vm!(
|
||||
client,
|
||||
&client_id,
|
||||
test_params.clone(),
|
||||
script,
|
||||
client_5_result.data.clone(),
|
||||
relay_4_result.data.clone()
|
||||
|
@ -46,72 +46,180 @@ fn network_explore() {
|
||||
|
||||
let script = include_str!("./scripts/network_explore.clj");
|
||||
|
||||
let client_result = checked_call_vm!(client, "", script, "", "");
|
||||
let client_result = checked_call_vm!(client, <_>::default(), script, "", "");
|
||||
assert_next_pks!(&client_result.next_peer_pks, &[relay_id]);
|
||||
|
||||
let relay_result = checked_call_vm!(relay, "", script, "", client_result.data.clone());
|
||||
let relay_result = checked_call_vm!(relay, <_>::default(), script, "", client_result.data.clone());
|
||||
assert_next_pks!(&relay_result.next_peer_pks, &[client_1_id]);
|
||||
|
||||
let client_1_result = checked_call_vm!(client_1, "", script, "", relay_result.data.clone());
|
||||
let client_1_result = checked_call_vm!(client_1, <_>::default(), script, "", relay_result.data.clone());
|
||||
assert_next_pks!(&client_1_result.next_peer_pks, &[client_2_id]);
|
||||
|
||||
let client_2_result = checked_call_vm!(client_2, "", script, "", client_1_result.data.clone());
|
||||
let client_2_result = checked_call_vm!(client_2, <_>::default(), script, "", client_1_result.data.clone());
|
||||
assert_next_pks!(&client_2_result.next_peer_pks, &[client_3_id]);
|
||||
|
||||
let client_3_result = checked_call_vm!(client_3, "", script, "", client_2_result.data.clone());
|
||||
let client_3_result = checked_call_vm!(client_3, <_>::default(), script, "", client_2_result.data.clone());
|
||||
assert_next_pks!(&client_3_result.next_peer_pks, &[relay_id]);
|
||||
|
||||
let relay_result = checked_call_vm!(relay, "", script, relay_result.data, client_3_result.data.clone());
|
||||
let relay_result = checked_call_vm!(
|
||||
relay,
|
||||
<_>::default(),
|
||||
script,
|
||||
relay_result.data,
|
||||
client_3_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&relay_result.next_peer_pks, &[client_1_id]);
|
||||
|
||||
let client_1_result = checked_call_vm!(client_1, "", script, client_1_result.data, relay_result.data.clone());
|
||||
let client_1_result = checked_call_vm!(
|
||||
client_1,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_1_result.data,
|
||||
relay_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_1_result.next_peer_pks, &[client_3_id]);
|
||||
|
||||
let client_3_result = checked_call_vm!(client_3, "", script, client_3_result.data, client_1_result.data.clone());
|
||||
let client_3_result = checked_call_vm!(
|
||||
client_3,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_3_result.data,
|
||||
client_1_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_3_result.next_peer_pks, &[relay_id]);
|
||||
|
||||
let relay_result = checked_call_vm!(relay, "", script, relay_result.data, client_3_result.data.clone());
|
||||
let relay_result = checked_call_vm!(
|
||||
relay,
|
||||
<_>::default(),
|
||||
script,
|
||||
relay_result.data,
|
||||
client_3_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&relay_result.next_peer_pks, &[client_2_id]);
|
||||
|
||||
let client_2_result = checked_call_vm!(client_2, "", script, client_2_result.data, relay_result.data.clone());
|
||||
let client_2_result = checked_call_vm!(
|
||||
client_2,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_2_result.data,
|
||||
relay_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_2_result.next_peer_pks, &[relay_id]);
|
||||
|
||||
let relay_result = checked_call_vm!(relay, "", script, relay_result.data, client_2_result.data.clone());
|
||||
let relay_result = checked_call_vm!(
|
||||
relay,
|
||||
<_>::default(),
|
||||
script,
|
||||
relay_result.data,
|
||||
client_2_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&relay_result.next_peer_pks, &[client_3_id]);
|
||||
|
||||
let client_3_result = checked_call_vm!(client_3, "", script, client_3_result.data, relay_result.data.clone());
|
||||
let client_3_result = checked_call_vm!(
|
||||
client_3,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_3_result.data,
|
||||
relay_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_3_result.next_peer_pks, &[client_1_id]);
|
||||
|
||||
let client_1_result = checked_call_vm!(client_1, "", script, client_1_result.data, client_3_result.data.clone());
|
||||
let client_1_result = checked_call_vm!(
|
||||
client_1,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_1_result.data,
|
||||
client_3_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_1_result.next_peer_pks, &[client_2_id]);
|
||||
|
||||
let client_2_result = checked_call_vm!(client_2, "", script, client_2_result.data, client_1_result.data.clone());
|
||||
let client_2_result = checked_call_vm!(
|
||||
client_2,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_2_result.data,
|
||||
client_1_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_2_result.next_peer_pks, &[relay_id]);
|
||||
|
||||
let relay_result = checked_call_vm!(relay, "", script, relay_result.data, client_2_result.data.clone());
|
||||
let relay_result = checked_call_vm!(
|
||||
relay,
|
||||
<_>::default(),
|
||||
script,
|
||||
relay_result.data,
|
||||
client_2_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&relay_result.next_peer_pks, &[client_3_id]);
|
||||
|
||||
let client_3_result = checked_call_vm!(client_3, "", script, client_3_result.data, relay_result.data.clone());
|
||||
let client_3_result = checked_call_vm!(
|
||||
client_3,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_3_result.data,
|
||||
relay_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_3_result.next_peer_pks, &[client_1_id]);
|
||||
|
||||
let client_1_result = checked_call_vm!(client_1, "", script, client_1_result.data, client_3_result.data.clone());
|
||||
let client_1_result = checked_call_vm!(
|
||||
client_1,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_1_result.data,
|
||||
client_3_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_1_result.next_peer_pks, &[client_2_id]);
|
||||
|
||||
let client_2_result = checked_call_vm!(client_2, "", script, client_2_result.data, client_1_result.data.clone());
|
||||
let client_2_result = checked_call_vm!(
|
||||
client_2,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_2_result.data,
|
||||
client_1_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_2_result.next_peer_pks, &[client_1_id]);
|
||||
|
||||
let client_1_result = checked_call_vm!(client_1, "", script, client_1_result.data, client_2_result.data.clone());
|
||||
let client_1_result = checked_call_vm!(
|
||||
client_1,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_1_result.data,
|
||||
client_2_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_1_result.next_peer_pks, &[client_2_id]);
|
||||
|
||||
let client_2_result = checked_call_vm!(client_2, "", script, client_2_result.data, client_1_result.data.clone());
|
||||
let client_2_result = checked_call_vm!(
|
||||
client_2,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_2_result.data,
|
||||
client_1_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_2_result.next_peer_pks, &[client_3_id]);
|
||||
|
||||
let client_3_result = checked_call_vm!(client_3, "", script, client_3_result.data, client_2_result.data.clone());
|
||||
let client_3_result = checked_call_vm!(
|
||||
client_3,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_3_result.data,
|
||||
client_2_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_3_result.next_peer_pks, &[relay_id]);
|
||||
|
||||
let relay_result = checked_call_vm!(relay, "", script, relay_result.data, client_3_result.data.clone());
|
||||
let relay_result = checked_call_vm!(
|
||||
relay,
|
||||
<_>::default(),
|
||||
script,
|
||||
relay_result.data,
|
||||
client_3_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&relay_result.next_peer_pks, &[client_id]);
|
||||
|
||||
let client_result = checked_call_vm!(client, "", script, client_result.data, relay_result.data.clone());
|
||||
let client_result = checked_call_vm!(
|
||||
client,
|
||||
<_>::default(),
|
||||
script,
|
||||
client_result.data,
|
||||
relay_result.data.clone()
|
||||
);
|
||||
assert_next_pks!(&client_result.next_peer_pks, &[]);
|
||||
}
|
||||
|
@ -54,11 +54,11 @@ fn issue_137() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let initiator_result = checked_call_vm!(initiator, "", &script, "", "");
|
||||
let node_1_result = checked_call_vm!(node_1, "", &script, "", initiator_result.data.clone());
|
||||
let node_2_result = checked_call_vm!(node_2, "", &script, "", initiator_result.data);
|
||||
let node_4_result_1 = checked_call_vm!(node_4, "", &script, "", node_1_result.data);
|
||||
let result = call_vm!(node_4, "", script, node_4_result_1.data, node_2_result.data);
|
||||
let initiator_result = checked_call_vm!(initiator, <_>::default(), &script, "", "");
|
||||
let node_1_result = checked_call_vm!(node_1, <_>::default(), &script, "", initiator_result.data.clone());
|
||||
let node_2_result = checked_call_vm!(node_2, <_>::default(), &script, "", initiator_result.data);
|
||||
let node_4_result_1 = checked_call_vm!(node_4, <_>::default(), &script, "", node_1_result.data);
|
||||
let result = call_vm!(node_4, <_>::default(), script, node_4_result_1.data, node_2_result.data);
|
||||
|
||||
assert!(is_interpreter_succeded(&result));
|
||||
}
|
||||
|
@ -57,12 +57,18 @@ fn issue_173() {
|
||||
)
|
||||
)"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable_vm, "", &script, "", "");
|
||||
let vm_1_result = checked_call_vm!(local_vm_1, "", &script, "", result.data);
|
||||
let vm_2_result = checked_call_vm!(local_vm_2, "", &script, "", vm_1_result.data.clone());
|
||||
let result = checked_call_vm!(set_variable_vm, <_>::default(), &script, "", "");
|
||||
let vm_1_result = checked_call_vm!(local_vm_1, <_>::default(), &script, "", result.data);
|
||||
let vm_2_result = checked_call_vm!(local_vm_2, <_>::default(), &script, "", vm_1_result.data.clone());
|
||||
|
||||
let vm_1_result = checked_call_vm!(local_vm_1, "", &script, vm_1_result.data, vm_2_result.data.clone());
|
||||
let vm_2_result = checked_call_vm!(local_vm_2, "", script, vm_2_result.data, vm_1_result.data);
|
||||
let vm_1_result = checked_call_vm!(
|
||||
local_vm_1,
|
||||
<_>::default(),
|
||||
&script,
|
||||
vm_1_result.data,
|
||||
vm_2_result.data.clone()
|
||||
);
|
||||
let vm_2_result = checked_call_vm!(local_vm_2, <_>::default(), script, vm_2_result.data, vm_1_result.data);
|
||||
|
||||
let actual_trace = trace_from_result(&vm_2_result);
|
||||
let expected_trace = vec![
|
||||
|
@ -45,7 +45,7 @@ fn issue_177() {
|
||||
// client 1: demand result for (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
let client_result_1 = client
|
||||
.runner
|
||||
.call(script, "", "", client_peer_id, HashMap::new())
|
||||
.call(script, "", "", client_peer_id, 0, HashMap::new())
|
||||
.expect("call should be success");
|
||||
let expected_call_requests = maplit::hashmap! {
|
||||
1 => CallRequestParams::new("getDataSrv", "-relay-", vec![], vec![]),
|
||||
@ -59,7 +59,7 @@ fn issue_177() {
|
||||
// client 2: send result to the specified relay
|
||||
let client_result_2 = client
|
||||
.runner
|
||||
.call(script, client_result_1.data, "", client_peer_id, call_results)
|
||||
.call(script, client_result_1.data, "", client_peer_id, 0, call_results)
|
||||
.expect("call should be success");
|
||||
assert!(client_result_2.call_requests.is_empty());
|
||||
assert_eq!(client_result_2.next_peer_pks, vec![relay_peer_id.to_string()]);
|
||||
@ -67,7 +67,14 @@ fn issue_177() {
|
||||
// relay 1: execute one time (without providing call results) on the relay and them send back to the client
|
||||
let relay_result_1 = relay
|
||||
.runner
|
||||
.call(script, "", client_result_2.data.clone(), client_peer_id, HashMap::new())
|
||||
.call(
|
||||
script,
|
||||
"",
|
||||
client_result_2.data.clone(),
|
||||
client_peer_id,
|
||||
0,
|
||||
HashMap::new(),
|
||||
)
|
||||
.expect("call should be success");
|
||||
let expected_call_requests = maplit::hashmap! {
|
||||
1 => CallRequestParams::new("op", "noop", vec![], vec![]),
|
||||
@ -81,7 +88,7 @@ fn issue_177() {
|
||||
};
|
||||
let relay_result_2 = relay
|
||||
.runner
|
||||
.call(script, relay_result_1.data.clone(), "", client_peer_id, call_results)
|
||||
.call(script, relay_result_1.data.clone(), "", client_peer_id, 0, call_results)
|
||||
.expect("call should be success");
|
||||
assert!(relay_result_2.next_peer_pks.is_empty());
|
||||
|
||||
@ -91,7 +98,7 @@ fn issue_177() {
|
||||
};
|
||||
let relay_result_3 = relay
|
||||
.runner
|
||||
.call(script, relay_result_2.data.clone(), "", client_peer_id, call_results)
|
||||
.call(script, relay_result_2.data.clone(), "", client_peer_id, 0, call_results)
|
||||
.expect("call should be success");
|
||||
assert!(relay_result_3.next_peer_pks.is_empty());
|
||||
|
||||
@ -101,7 +108,7 @@ fn issue_177() {
|
||||
};
|
||||
let relay_result_4 = relay
|
||||
.runner
|
||||
.call(script, relay_result_3.data.clone(), "", client_peer_id, call_results)
|
||||
.call(script, relay_result_3.data.clone(), "", client_peer_id, 0, call_results)
|
||||
.expect("call should be success");
|
||||
|
||||
// client 4: receive result from the relay
|
||||
@ -113,6 +120,7 @@ fn issue_177() {
|
||||
client_result_2.data,
|
||||
relay_result_4.data.clone(),
|
||||
client_peer_id,
|
||||
0,
|
||||
HashMap::new(),
|
||||
)
|
||||
.expect("call should be success");
|
||||
@ -129,7 +137,7 @@ fn issue_177() {
|
||||
// demand a result for (call %init_peer_id% ("peer" "timeout") [1000 "timeout"])
|
||||
let client_result_4 = client
|
||||
.runner
|
||||
.call(script, client_result_3.data, "", client_peer_id, call_results)
|
||||
.call(script, client_result_3.data, "", client_peer_id, 0, call_results)
|
||||
.expect("call should be success");
|
||||
let expected_call_requests = maplit::hashmap! {
|
||||
3 => CallRequestParams::new("peer", "timeout", vec![json!(1000u64), json!("timeout")], vec![
|
||||
@ -146,7 +154,7 @@ fn issue_177() {
|
||||
// timeout requests provided
|
||||
let client_result_5 = client
|
||||
.runner
|
||||
.call(script, client_result_4.data, "", client_peer_id, call_results);
|
||||
.call(script, client_result_4.data, "", client_peer_id, 0, call_results);
|
||||
// before patch the interpreter crashed here
|
||||
assert!(client_result_5.is_ok());
|
||||
}
|
||||
|
@ -41,14 +41,20 @@ fn par_ap_behaviour() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let mut client_result_1 = checked_call_vm!(client, "", &script, "", "");
|
||||
let mut client_result_1 = checked_call_vm!(client, <_>::default(), &script, "", "");
|
||||
let actual_next_peers: HashSet<_> = client_result_1.next_peer_pks.drain(..).collect();
|
||||
let expected_next_peers: HashSet<_> = maplit::hashset!(relay_id.to_string(), variable_setter_id.to_string());
|
||||
assert_eq!(actual_next_peers, expected_next_peers);
|
||||
|
||||
let setter_result = checked_call_vm!(variable_setter, "", &script, "", client_result_1.data.clone());
|
||||
let setter_result = checked_call_vm!(
|
||||
variable_setter,
|
||||
<_>::default(),
|
||||
&script,
|
||||
"",
|
||||
client_result_1.data.clone()
|
||||
);
|
||||
assert!(setter_result.next_peer_pks.is_empty());
|
||||
|
||||
let relay_result = checked_call_vm!(relay, "", script, "", client_result_1.data);
|
||||
let relay_result = checked_call_vm!(relay, <_>::default(), script, "", client_result_1.data);
|
||||
assert!(relay_result.next_peer_pks.is_empty());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ fn issue_180() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let peer_1_result = checked_call_vm!(peer_1, "", &script, "", "");
|
||||
let peer_1_result = checked_call_vm!(peer_1, <_>::default(), &script, "", "");
|
||||
let trace = trace_from_result(&peer_1_result);
|
||||
assert_eq!(trace.len(), 3);
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ fn issue_206() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(peer_1, peer_1_id, &script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id(peer_1_id);
|
||||
let result = checked_call_vm!(peer_1, test_params, &script, "", "");
|
||||
|
||||
let actual_trace = trace_from_result(&result);
|
||||
let expected_trace = vec![executed_state::ap(Some(0)), executed_state::scalar(json!(["is nil"]))];
|
||||
|
@ -66,7 +66,8 @@ fn issue_211() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(peer_1, peer_1_id, &script, "", "");
|
||||
let run_params = TestRunParameters::from_init_peer_id(peer_1_id);
|
||||
let result = checked_call_vm!(peer_1, run_params, &script, "", "");
|
||||
|
||||
let expected_trace = vec![
|
||||
executed_state::scalar_number(2),
|
||||
|
@ -56,7 +56,8 @@ fn issue_214() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(client, client_id, &script, "", "");
|
||||
let test_params = TestRunParameters::from_init_peer_id(client_id);
|
||||
let result = checked_call_vm!(client, test_params, &script, "", "");
|
||||
let expected_trace = vec![
|
||||
executed_state::scalar_string(relay_id),
|
||||
executed_state::scalar(scalar),
|
||||
|
@ -43,8 +43,9 @@ fn issue_216() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(some_peer, client_id, &script, "", "");
|
||||
let result = checked_call_vm!(client, client_id, &script, "", result.data); // before 0.20.4 it's just failed
|
||||
let test_params = TestRunParameters::from_init_peer_id(client_id);
|
||||
let result = checked_call_vm!(some_peer, test_params.clone(), &script, "", "");
|
||||
let result = checked_call_vm!(client, test_params, &script, "", result.data); // before 0.20.4 it's just failed
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
|
@ -72,12 +72,18 @@ fn issue_221() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let result = checked_call_vm!(set_variable, "", &script, "", "");
|
||||
let peer_1_result = checked_call_vm!(peer_1, "", &script, "", result.data.clone());
|
||||
let peer_2_result = checked_call_vm!(peer_2, "", &script, "", result.data.clone());
|
||||
let result = checked_call_vm!(set_variable, <_>::default(), &script, "", "");
|
||||
let peer_1_result = checked_call_vm!(peer_1, <_>::default(), &script, "", result.data.clone());
|
||||
let peer_2_result = checked_call_vm!(peer_2, <_>::default(), &script, "", result.data.clone());
|
||||
|
||||
let join_1_result = checked_call_vm!(join_1, "", &script, "", peer_1_result.data.clone());
|
||||
let join_1_result = checked_call_vm!(join_1, "", &script, join_1_result.data, peer_2_result.data.clone()); // before 0.20.9 it fails here
|
||||
let join_1_result = checked_call_vm!(join_1, <_>::default(), &script, "", peer_1_result.data.clone());
|
||||
let join_1_result = checked_call_vm!(
|
||||
join_1,
|
||||
<_>::default(),
|
||||
&script,
|
||||
join_1_result.data,
|
||||
peer_2_result.data.clone()
|
||||
); // before 0.20.9 it fails here
|
||||
let actual_trace = trace_from_result(&join_1_result);
|
||||
let expected_trace = vec![
|
||||
executed_state::scalar(json!([peer_1_id, peer_2_id])),
|
||||
|
@ -51,10 +51,9 @@ fn issue_241() {
|
||||
)
|
||||
"#);
|
||||
|
||||
let init_peer_id = "";
|
||||
let result = checked_call_vm!(set_array_0_vm, init_peer_id, &script, "", "");
|
||||
let result = checked_call_vm!(peer_1_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(some_peer_vm, init_peer_id, &script, "", result.data);
|
||||
let result = checked_call_vm!(set_array_0_vm, <_>::default(), &script, "", "");
|
||||
let result = checked_call_vm!(peer_1_vm, <_>::default(), &script, "", result.data);
|
||||
let result = checked_call_vm!(some_peer_vm, <_>::default(), &script, "", result.data);
|
||||
let actual_trace = trace_from_result(&result);
|
||||
|
||||
let expected_trace = vec![
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "avm-server"
|
||||
description = "Fluence AIR VM"
|
||||
version = "0.18.0"
|
||||
version = "0.19.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
license = "Apache-2.0"
|
||||
@ -16,7 +16,7 @@ name = "avm_server"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
air-interpreter-interface = { version = "0.8.0", path = "../../crates/air-lib/interpreter-interface" }
|
||||
air-interpreter-interface = { version = "0.9.0", path = "../../crates/air-lib/interpreter-interface" }
|
||||
avm-data-store = { version = "0.1.0", path = "../../crates/data-store" }
|
||||
fluence-faas = "0.16.0"
|
||||
polyplets = { version = "0.2.0", path = "../../crates/air-lib/polyplets" }
|
||||
|
@ -21,6 +21,7 @@ use super::AVMMemoryStats;
|
||||
use super::AVMOutcome;
|
||||
use super::CallResults;
|
||||
use crate::config::AVMConfig;
|
||||
use crate::interface::ParticleParameters;
|
||||
use crate::AVMResult;
|
||||
|
||||
use std::ops::Deref;
|
||||
@ -75,16 +76,22 @@ impl<E> AVM<E> {
|
||||
&mut self,
|
||||
air: impl Into<String>,
|
||||
data: impl Into<Vec<u8>>,
|
||||
init_user_id: impl Into<String>,
|
||||
particle_id: &str,
|
||||
particle_parameters: ParticleParameters<'_, '_>,
|
||||
call_results: CallResults,
|
||||
) -> AVMResult<AVMOutcome, E> {
|
||||
let init_user_id = init_user_id.into();
|
||||
let particle_id = particle_parameters.particle_id.as_str();
|
||||
let prev_data = self.data_store.read_data(particle_id)?;
|
||||
|
||||
let outcome = self
|
||||
.runner
|
||||
.call(air, prev_data, data, init_user_id, call_results)
|
||||
.call(
|
||||
air,
|
||||
prev_data,
|
||||
data,
|
||||
particle_parameters.init_peer_id.into_owned(),
|
||||
particle_parameters.timestamp,
|
||||
call_results,
|
||||
)
|
||||
.map_err(AVMError::RunnerError)?;
|
||||
|
||||
// persist resulted data
|
||||
|
@ -17,6 +17,7 @@
|
||||
mod call_request_parameters;
|
||||
mod call_service_result;
|
||||
mod outcome;
|
||||
mod particle_parameters;
|
||||
pub mod raw_outcome;
|
||||
|
||||
type JValue = serde_json::Value;
|
||||
@ -24,3 +25,4 @@ type JValue = serde_json::Value;
|
||||
pub use call_request_parameters::*;
|
||||
pub use call_service_result::*;
|
||||
pub use outcome::*;
|
||||
pub use particle_parameters::*;
|
||||
|
38
avm/server/src/interface/particle_parameters.rs
Normal file
38
avm/server/src/interface/particle_parameters.rs
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 std::borrow::Cow;
|
||||
|
||||
/// Represents parameters obtained from a particle.
|
||||
pub struct ParticleParameters<'init_peer_id, 'particle_id> {
|
||||
pub init_peer_id: Cow<'init_peer_id, String>,
|
||||
pub particle_id: Cow<'particle_id, String>,
|
||||
pub timestamp: u64,
|
||||
}
|
||||
|
||||
impl<'init_peer_id, 'particle_id> ParticleParameters<'init_peer_id, 'particle_id> {
|
||||
pub fn new(
|
||||
init_peer_id: Cow<'init_peer_id, String>,
|
||||
particle_id: Cow<'particle_id, String>,
|
||||
timestamp: u64,
|
||||
) -> Self {
|
||||
Self {
|
||||
init_peer_id,
|
||||
particle_id,
|
||||
timestamp,
|
||||
}
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ pub struct AVMMemoryStats {
|
||||
}
|
||||
|
||||
impl AVMRunner {
|
||||
/// Create AVM with provided config.
|
||||
/// Create AVM with the provided config.
|
||||
pub fn new(
|
||||
air_wasm_path: PathBuf,
|
||||
current_peer_id: impl Into<String>,
|
||||
@ -71,16 +71,17 @@ impl AVMRunner {
|
||||
air: impl Into<String>,
|
||||
prev_data: impl Into<Vec<u8>>,
|
||||
data: impl Into<Vec<u8>>,
|
||||
init_user_id: impl Into<String>,
|
||||
init_peer_id: impl Into<String>,
|
||||
timestamp: u64,
|
||||
call_results: CallResults,
|
||||
) -> RunnerResult<RawAVMOutcome> {
|
||||
let init_user_id = init_user_id.into();
|
||||
let args = prepare_args(
|
||||
air,
|
||||
prev_data,
|
||||
data,
|
||||
init_user_id,
|
||||
self.current_peer_id.clone(),
|
||||
init_peer_id.into(),
|
||||
timestamp,
|
||||
call_results,
|
||||
);
|
||||
|
||||
@ -113,17 +114,14 @@ fn prepare_args(
|
||||
air: impl Into<String>,
|
||||
prev_data: impl Into<Vec<u8>>,
|
||||
data: impl Into<Vec<u8>>,
|
||||
init_peer_id: impl Into<String>,
|
||||
current_peer_id: String,
|
||||
init_peer_id: String,
|
||||
timestamp: u64,
|
||||
call_results: CallResults,
|
||||
) -> Vec<IValue> {
|
||||
use fluence_faas::ne_vec::NEVec;
|
||||
|
||||
let run_parameters = vec![
|
||||
IValue::String(init_peer_id.into()),
|
||||
IValue::String(current_peer_id),
|
||||
];
|
||||
let run_parameters = NEVec::new(run_parameters).unwrap();
|
||||
let run_parameters =
|
||||
air_interpreter_interface::RunParameters::new(init_peer_id, current_peer_id, timestamp)
|
||||
.into_ivalue();
|
||||
|
||||
let call_results = crate::interface::into_raw_result(call_results);
|
||||
let call_results =
|
||||
@ -133,7 +131,7 @@ fn prepare_args(
|
||||
IValue::String(air.into()),
|
||||
IValue::ByteArray(prev_data.into()),
|
||||
IValue::ByteArray(data.into()),
|
||||
IValue::Record(run_parameters),
|
||||
run_parameters,
|
||||
IValue::ByteArray(call_results),
|
||||
]
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ pub struct Triplet<'i> {
|
||||
pub enum Value<'i> {
|
||||
InitPeerId,
|
||||
LastError(Option<LambdaAST<'i>>),
|
||||
Timestamp,
|
||||
Literal(&'i str),
|
||||
Number(Number),
|
||||
Boolean(bool),
|
||||
@ -79,6 +80,7 @@ pub enum CallOutputValue<'i> {
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||
pub enum ApArgument<'i> {
|
||||
InitPeerId,
|
||||
Timestamp,
|
||||
LastError(Option<LambdaAST<'i>>),
|
||||
Literal(&'i str),
|
||||
Number(Number),
|
||||
|
@ -25,6 +25,7 @@ impl fmt::Display for Value<'_> {
|
||||
InitPeerId => write!(f, "%init_peer_id%"),
|
||||
LastError(error_accessor) => display_last_error(f, error_accessor),
|
||||
Literal(literal) => write!(f, r#""{}""#, literal),
|
||||
Timestamp => write!(f, "%timestamp%"),
|
||||
Number(number) => write!(f, "{}", number),
|
||||
Boolean(bool) => write!(f, "{}", bool),
|
||||
EmptyArray => write!(f, "[]"),
|
||||
@ -64,6 +65,7 @@ impl fmt::Display for ApArgument<'_> {
|
||||
InitPeerId => write!(f, "%init_peer_id%"),
|
||||
LastError(error_accessor) => display_last_error(f, error_accessor),
|
||||
Literal(str) => write!(f, r#""{}""#, str),
|
||||
Timestamp => write!(f, "%timestamp%"),
|
||||
Number(number) => write!(f, "{}", number),
|
||||
Boolean(bool) => write!(f, "{}", bool),
|
||||
EmptyArray => write!(f, "[]"),
|
||||
|
@ -178,6 +178,7 @@ Value: Value<'input> = {
|
||||
<LastError> => Value::LastError(None),
|
||||
<le:LastErrorWithLambda> => Value::LastError(Some(le)),
|
||||
<l:Literal> => Value::Literal(l),
|
||||
Timestamp => Value::Timestamp,
|
||||
<n:Number> => Value::Number(n),
|
||||
<b:Boolean> => Value::Boolean(b),
|
||||
"[" "]" => Value::EmptyArray,
|
||||
@ -191,6 +192,7 @@ ApArgument: ApArgument<'input> = {
|
||||
InitPeerId => ApArgument::InitPeerId,
|
||||
<LastError> => ApArgument::LastError(None),
|
||||
<le:LastErrorWithLambda> => ApArgument::LastError(Some(le)),
|
||||
Timestamp => ApArgument::Timestamp,
|
||||
<l:Literal> => ApArgument::Literal(l),
|
||||
<n:Number> => ApArgument::Number(n),
|
||||
<b:Boolean> => ApArgument::Boolean(b),
|
||||
@ -222,6 +224,7 @@ extern {
|
||||
InitPeerId => Token::InitPeerId,
|
||||
LastError => Token::LastError,
|
||||
LastErrorWithLambda => Token::LastErrorWithLambda(<LambdaAST<'input>>),
|
||||
Timestamp => Token::Timestamp,
|
||||
|
||||
call => Token::Call,
|
||||
ap => Token::Ap,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -190,6 +190,7 @@ fn string_to_token(input: &str, start_pos: usize) -> LexerResult<Token> {
|
||||
|
||||
INIT_PEER_ID => Ok(Token::InitPeerId),
|
||||
_ if input.starts_with(LAST_ERROR) => parse_last_error(input, start_pos),
|
||||
TIMESTAMP => Ok(Token::Timestamp),
|
||||
|
||||
TRUE_VALUE => Ok(Token::Boolean(true)),
|
||||
FALSE_VALUE => Ok(Token::Boolean(false)),
|
||||
@ -238,6 +239,7 @@ const MISMATCH_INSTR: &str = "mismatch";
|
||||
|
||||
const INIT_PEER_ID: &str = "%init_peer_id%";
|
||||
const LAST_ERROR: &str = "%last_error%";
|
||||
const TIMESTAMP: &str = "%timestamp%";
|
||||
|
||||
const TRUE_VALUE: &str = "true";
|
||||
const FALSE_VALUE: &str = "false";
|
||||
|
@ -158,6 +158,16 @@ fn init_peer_id() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn timestamp() {
|
||||
const TIMESTAMP: &str = "%timestamp%";
|
||||
|
||||
lexer_test(
|
||||
TIMESTAMP,
|
||||
Single(Ok((0, Token::Timestamp, TIMESTAMP.len()))),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stream() {
|
||||
const STREAM: &str = "$stream____asdasd";
|
||||
|
@ -53,6 +53,7 @@ pub enum Token<'input> {
|
||||
InitPeerId,
|
||||
LastError,
|
||||
LastErrorWithLambda(LambdaAST<'input>),
|
||||
Timestamp,
|
||||
|
||||
Call,
|
||||
Ap,
|
||||
|
@ -92,3 +92,27 @@ fn ap_with_empty_array() {
|
||||
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ap_with_init_peer_id() {
|
||||
let source_code = r#"
|
||||
(ap %init_peer_id% $stream)
|
||||
"#;
|
||||
|
||||
let actual = parse(source_code);
|
||||
let expected = ap(ApArgument::InitPeerId, Variable::stream("$stream", 28));
|
||||
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ap_with_timestamp() {
|
||||
let source_code = r#"
|
||||
(ap %timestamp% $stream)
|
||||
"#;
|
||||
|
||||
let actual = parse(source_code);
|
||||
let expected = ap(ApArgument::Timestamp, Variable::stream("$stream", 25));
|
||||
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
@ -374,6 +374,24 @@ fn parse_init_peer_id() {
|
||||
assert_eq!(instruction, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_timestamp() {
|
||||
let source_code = r#"
|
||||
(call "peer_id" ("service_id" "fn_name") [%timestamp%])
|
||||
"#;
|
||||
|
||||
let instruction = parse(source_code);
|
||||
let expected = call(
|
||||
CallInstrValue::Literal("peer_id"),
|
||||
CallInstrValue::Literal("service_id"),
|
||||
CallInstrValue::Literal("fn_name"),
|
||||
Rc::new(vec![Value::Timestamp]),
|
||||
CallOutputValue::None,
|
||||
);
|
||||
|
||||
assert_eq!(instruction, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_last_error() {
|
||||
let source_code = format!(
|
||||
|
@ -50,6 +50,22 @@ fn parse_match_with_init_peer_id() {
|
||||
assert_eq!(instruction, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_match_with_timestamp() {
|
||||
let source_code = r#"
|
||||
(match %timestamp% v1
|
||||
(null)
|
||||
)
|
||||
"#;
|
||||
let instruction = parse(source_code);
|
||||
let expected = match_(
|
||||
Value::Timestamp,
|
||||
Value::Variable(VariableWithLambda::scalar("v1", 28)),
|
||||
null(),
|
||||
);
|
||||
assert_eq!(instruction, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_mismatch() {
|
||||
let source_code = r#"
|
||||
|
@ -120,6 +120,7 @@ impl<'i> VariableValidator<'i> {
|
||||
pub(super) fn met_ap(&mut self, ap: &Ap<'i>, span: Span) {
|
||||
match &ap.argument {
|
||||
ApArgument::Number(_)
|
||||
| ApArgument::Timestamp
|
||||
| ApArgument::InitPeerId
|
||||
| ApArgument::Boolean(_)
|
||||
| ApArgument::Literal(_)
|
||||
@ -229,6 +230,7 @@ impl<'i> VariableValidator<'i> {
|
||||
fn met_matchable(&mut self, matchable: &Value<'i>, span: Span) {
|
||||
match matchable {
|
||||
Value::InitPeerId
|
||||
| Value::Timestamp
|
||||
| Value::Number(_)
|
||||
| Value::Boolean(_)
|
||||
| Value::Literal(_)
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "air-interpreter-interface"
|
||||
description = "Interface of the AIR interpreter"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
license = "Apache-2.0"
|
||||
|
@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use fluence_it_types::ne_vec::NEVec;
|
||||
use fluence_it_types::IValue;
|
||||
use marine_rs_sdk::marine;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
@ -27,4 +29,29 @@ pub struct RunParameters {
|
||||
|
||||
/// Peer id of a current peer.
|
||||
pub current_peer_id: String,
|
||||
|
||||
/// Unix timestamp from a particle in milliseconds.
|
||||
/// It represents time when this particle was sent from the init peer id.
|
||||
pub timestamp: u64,
|
||||
}
|
||||
|
||||
impl RunParameters {
|
||||
pub fn new(init_peer_id: String, current_peer_id: String, timestamp: u64) -> Self {
|
||||
Self {
|
||||
init_peer_id,
|
||||
current_peer_id,
|
||||
timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_ivalue(self) -> IValue {
|
||||
let run_parameters = vec![
|
||||
IValue::String(self.init_peer_id),
|
||||
IValue::String(self.current_peer_id),
|
||||
IValue::U64(self.timestamp),
|
||||
];
|
||||
// unwrap is safe here because run_parameters is non-empty array
|
||||
let run_parameters = NEVec::new(run_parameters).unwrap();
|
||||
IValue::Record(run_parameters)
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ pub type JValue = serde_json::Value;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! checked_call_vm {
|
||||
($vm:expr, $init_peer_id:expr, $script:expr, $prev_data:expr, $data:expr) => {{
|
||||
match $vm.call($script, $prev_data, $data, $init_peer_id) {
|
||||
($vm:expr, $test_run_parameters:expr, $script:expr, $prev_data:expr, $data:expr) => {{
|
||||
match $vm.call($script, $prev_data, $data, $test_run_parameters) {
|
||||
Ok(v) if v.ret_code != 0 => {
|
||||
panic!("VM returns a error: {} {}", v.ret_code, v.error_message)
|
||||
}
|
||||
@ -67,8 +67,8 @@ macro_rules! checked_call_vm {
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! call_vm {
|
||||
($vm:expr, $init_peer_id:expr, $script:expr, $prev_data:expr, $data:expr) => {
|
||||
match $vm.call($script, $prev_data, $data, $init_peer_id) {
|
||||
($vm:expr, $test_run_parameters:expr, $script:expr, $prev_data:expr, $data:expr) => {
|
||||
match $vm.call($script, $prev_data, $data, $test_run_parameters) {
|
||||
Ok(v) => v,
|
||||
Err(err) => panic!("VM call failed: {}", err),
|
||||
}
|
||||
|
@ -29,18 +29,28 @@ pub struct TestRunner {
|
||||
pub call_service: CallServiceClosure,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct TestRunParameters {
|
||||
pub init_peer_id: String,
|
||||
pub timestamp: u64,
|
||||
}
|
||||
|
||||
impl TestRunner {
|
||||
pub fn call(
|
||||
&mut self,
|
||||
air: impl Into<String>,
|
||||
prev_data: impl Into<Vec<u8>>,
|
||||
data: impl Into<Vec<u8>>,
|
||||
init_user_id: impl Into<String>,
|
||||
test_run_params: TestRunParameters,
|
||||
) -> Result<RawAVMOutcome, String> {
|
||||
let air = air.into();
|
||||
let mut prev_data = prev_data.into();
|
||||
let mut data = data.into();
|
||||
let init_user_id = init_user_id.into();
|
||||
|
||||
let TestRunParameters {
|
||||
init_peer_id,
|
||||
timestamp,
|
||||
} = test_run_params;
|
||||
|
||||
let mut call_results = HashMap::new();
|
||||
let mut next_peer_pks = HashSet::new();
|
||||
@ -52,7 +62,8 @@ impl TestRunner {
|
||||
air.clone(),
|
||||
prev_data,
|
||||
data,
|
||||
init_user_id.clone(),
|
||||
init_peer_id.clone(),
|
||||
timestamp,
|
||||
call_results,
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
@ -99,3 +110,26 @@ pub fn create_avm(
|
||||
call_service,
|
||||
}
|
||||
}
|
||||
|
||||
impl TestRunParameters {
|
||||
pub fn new(init_peer_id: impl Into<String>, timestamp: u64) -> Self {
|
||||
Self {
|
||||
init_peer_id: init_peer_id.into(),
|
||||
timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_init_peer_id(init_peer_id: impl Into<String>) -> Self {
|
||||
Self {
|
||||
init_peer_id: init_peer_id.into(),
|
||||
timestamp: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_timestamp(timestamp: u64) -> Self {
|
||||
Self {
|
||||
init_peer_id: String::new(),
|
||||
timestamp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user