diff --git a/Cargo.lock b/Cargo.lock index 3705cc9f..08aab1ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,13 +70,16 @@ dependencies = [ [[package]] name = "aquamarine-vm" version = "0.1.6" -source = "git+https://github.com/fluencelabs/fce#f022a2dec4229f1dd739794e98a0e5d080ea13d5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e111be27ea8e9a48016b5c749a87e52de8a01801b569009024e4effb0a178e" dependencies = [ - "fluence-faas 0.1.18 (git+https://github.com/fluencelabs/fce)", + "fluence-faas", + "log", "maplit", + "parking_lot 0.11.1", "serde", "serde_json", - "stepper-interface 0.1.0 (git+https://github.com/fluencelabs/aquamarine)", + "stepper-interface 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -635,31 +638,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6101e9c7bd51f7478c41c2c1ce2405ef9e87fac5576c012877d5a9feed628a61" dependencies = [ "boolinator", - "fce-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fce-wit-interfaces 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "fce-wit-parser 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log", - "multi-map", - "multimap", - "parity-wasm", - "pwasm-utils", - "safe-transmute", - "serde", - "wasmer-interface-types-fl", - "wasmer-runtime-core-fl", - "wasmer-runtime-fl", - "wasmer-wasi-fl", -] - -[[package]] -name = "fce" -version = "0.1.14" -source = "git+https://github.com/fluencelabs/fce#f022a2dec4229f1dd739794e98a0e5d080ea13d5" -dependencies = [ - "boolinator", - "fce-utils 0.1.0 (git+https://github.com/fluencelabs/fce)", - "fce-wit-interfaces 0.1.9 (git+https://github.com/fluencelabs/fce)", - "fce-wit-parser 0.1.11 (git+https://github.com/fluencelabs/fce)", + "fce-utils", + "fce-wit-interfaces", + "fce-wit-parser", "log", "multi-map", "multimap", @@ -679,11 +660,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcdd9d63fa5f87e03514ba8ca3bb91a25121bbf1c63a26df710f166ab8f274f7" -[[package]] -name = "fce-utils" -version = "0.1.0" -source = "git+https://github.com/fluencelabs/fce#f022a2dec4229f1dd739794e98a0e5d080ea13d5" - [[package]] name = "fce-wit-interfaces" version = "0.1.9" @@ -694,15 +670,6 @@ dependencies = [ "wasmer-interface-types-fl", ] -[[package]] -name = "fce-wit-interfaces" -version = "0.1.9" -source = "git+https://github.com/fluencelabs/fce#f022a2dec4229f1dd739794e98a0e5d080ea13d5" -dependencies = [ - "multimap", - "wasmer-interface-types-fl", -] - [[package]] name = "fce-wit-parser" version = "0.1.11" @@ -710,20 +677,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "064d9e93e4b588385e77582be61b6d7aaeb352b0af7b33ab9807d61ee606f4e5" dependencies = [ "anyhow", - "fce-wit-interfaces 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde", - "walrus", - "wasmer-interface-types-fl", - "wasmer-runtime-core-fl", -] - -[[package]] -name = "fce-wit-parser" -version = "0.1.11" -source = "git+https://github.com/fluencelabs/fce#f022a2dec4229f1dd739794e98a0e5d080ea13d5" -dependencies = [ - "anyhow", - "fce-wit-interfaces 0.1.9 (git+https://github.com/fluencelabs/fce)", + "fce-wit-interfaces", "serde", "walrus", "wasmer-interface-types-fl", @@ -748,11 +702,11 @@ dependencies = [ [[package]] name = "fluence-app-service" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5d68695059de51743eddcd98a0ba77ec3af7fa51b2eb5fcb35edce05ff1144" +checksum = "f05261ebf65e17d28d158da1eccd0e2129e21c9fe5ac7a2d578262cdcd2a981b" dependencies = [ - "fluence-faas 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "fluence-faas", "log", "maplit", "serde", @@ -769,30 +723,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "760e23d5582bee6ec9800c0a3e179525e80a28482d17a09ed7d138d121020368" dependencies = [ "cmd_lib", - "fce 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "fce-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fluence-sdk-main", - "itertools", - "log", - "safe-transmute", - "serde", - "serde_derive", - "serde_json", - "toml", - "wasmer-interface-types-fl", - "wasmer-runtime-core-fl", - "wasmer-runtime-fl", - "wasmer-wasi-fl", -] - -[[package]] -name = "fluence-faas" -version = "0.1.18" -source = "git+https://github.com/fluencelabs/fce#f022a2dec4229f1dd739794e98a0e5d080ea13d5" -dependencies = [ - "cmd_lib", - "fce 0.1.14 (git+https://github.com/fluencelabs/fce)", - "fce-utils 0.1.0 (git+https://github.com/fluencelabs/fce)", + "fce", + "fce-utils", "fluence-sdk-main", "itertools", "log", @@ -992,6 +924,15 @@ dependencies = [ "serde", ] +[[package]] +name = "instant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "inventory" version = "0.1.10" @@ -1123,6 +1064,15 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "lock_api" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" version = "0.4.11" @@ -1276,8 +1226,19 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ - "lock_api", - "parking_lot_core", + "lock_api 0.3.4", + "parking_lot_core 0.7.2", +] + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api 0.4.2", + "parking_lot_core 0.8.2", ] [[package]] @@ -1294,6 +1255,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + [[package]] name = "petgraph" version = "0.5.1" @@ -1685,7 +1660,8 @@ dependencies = [ [[package]] name = "stepper-interface" version = "0.1.0" -source = "git+https://github.com/fluencelabs/aquamarine#5cb4cc0fb0c149a4bd3160dd0bac9c3d5ac3db7d" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2be93d2a8a33f133cdf62e2097b5b58cf46d816240e03df26c27af3432b7b87" dependencies = [ "fluence", "serde", @@ -1694,7 +1670,7 @@ dependencies = [ [[package]] name = "stepper-lib" -version = "0.1.3" +version = "0.2.0" dependencies = [ "air-parser", "aqua-test-utils", @@ -1744,9 +1720,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.55" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a571a711dddd09019ccc628e1b17fe87c59b09d513c06c026877aa708334f37a" +checksum = "a9802ddde94170d186eeee5005b798d9c159fa970403f1be19976d0cfb939b72" dependencies = [ "proc-macro2", "quote", @@ -1790,18 +1766,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2", "quote", @@ -2102,7 +2078,7 @@ dependencies = [ "libc", "nix", "page_size", - "parking_lot", + "parking_lot 0.10.2", "rustc_version", "serde", "serde-bench", @@ -2131,7 +2107,7 @@ dependencies = [ "libc", "nix", "page_size", - "parking_lot", + "parking_lot 0.10.2", "rustc_version", "serde", "serde-bench", diff --git a/crates/air-parser/Cargo.toml b/crates/air-parser/Cargo.toml index db392421..597f4e70 100644 --- a/crates/air-parser/Cargo.toml +++ b/crates/air-parser/Cargo.toml @@ -3,6 +3,7 @@ name = "air-parser" version = "0.1.0" authors = ["Fluence Labs"] edition = "2018" +license = "Apache-2.0" [build-dependencies] lalrpop = { git = "https://github.com/fluencelabs/lalrpop", branch = "cloneable_parser", version = "0.19.1", features = ["lexer"] } diff --git a/crates/air-parser/src/ast.rs b/crates/air-parser/src/ast.rs index c323ebe9..447e1cdb 100644 --- a/crates/air-parser/src/ast.rs +++ b/crates/air-parser/src/ast.rs @@ -57,7 +57,6 @@ pub enum InstructionValue<'i> { Variable(&'i str), Literal(&'i str), JsonPath { variable: &'i str, path: &'i str }, - CurrentPeerId, InitPeerId, } diff --git a/crates/air-parser/src/lalrpop/aqua.lalrpop b/crates/air-parser/src/lalrpop/aqua.lalrpop index ba19aa60..98ab8810 100644 --- a/crates/air-parser/src/lalrpop/aqua.lalrpop +++ b/crates/air-parser/src/lalrpop/aqua.lalrpop @@ -65,7 +65,6 @@ InstructionValue: InstructionValue<'input> = { let path = path.next().expect("contain component after dot"); InstructionValue::JsonPath { variable, path } }, - CURRENT_PEER_ID => InstructionValue::CurrentPeerId, INIT_PEER_ID => InstructionValue::InitPeerId, } @@ -75,7 +74,6 @@ match { r"[\w_-]+" => ALPHANUMERIC, r"[\w_-]+\[\]" => ACCUMULATOR, r#"[\w_-]+\.*\$([\w._-]*(\[[\w"]+\])*!*)+"# => JSON_PATH, - r#"%current_peer_id%"# => CURRENT_PEER_ID, r#"%init_peer_id%"# => INIT_PEER_ID, "seq", "call", diff --git a/crates/air-parser/src/lalrpop/aqua.rs b/crates/air-parser/src/lalrpop/aqua.rs index a0712c09..21854d89 100644 --- a/crates/air-parser/src/lalrpop/aqua.rs +++ b/crates/air-parser/src/lalrpop/aqua.rs @@ -1,5 +1,5 @@ // auto-generated: "lalrpop 0.19.1" -// sha256: 28e49a3d2dd29ac97678a166f8a0d8c6e0b6e7e83484e8abfe5efefcebc7034 +// sha256: f53aa8ddac4c357917b8acc87af2adfdec1579fc84f61f4789a773b776a157f use crate::ast::*; use crate::lalrpop::parser::InstructionError; use lalrpop_util::ErrorRecovery; @@ -38,136 +38,134 @@ mod __parse__Instr { } const __ACTION: &[i8] = &[ // State 0 - 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, + 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, // State 1 - 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 2 - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 3 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, // State 4 - 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, + 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, // State 5 - 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, + 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, // State 6 - 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, + 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, // State 7 - 9, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 8 - 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, + 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, // State 9 - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 10 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, // State 11 - 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, + 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, // State 12 - 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, + 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, // State 13 - 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, + 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, // State 14 - 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 15 - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 16 - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 17 - 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, + 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, // State 18 - 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 30, 0, 0, 0, 0, + 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 30, 0, 0, 0, // State 19 - 9, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 20 - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 21 - 9, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 0, + 9, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 32, 0, // State 22 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 23 - 0, 0, 0, 0, 0, 2, 3, 4, 26, 5, 6, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 26, 5, 6, 7, 0, 0, 0, 0, 0, // State 24 - 0, -21, -21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -21, + 0, -21, -21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -21, // State 25 - 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 26 - -24, -24, -24, -24, -24, 0, 0, 0, 0, 0, 0, 0, 0, -24, -24, -24, -24, 0, + -24, -24, -24, -24, -24, 0, 0, 0, 0, 0, 0, 0, 0, -24, -24, -24, 0, // State 27 - -32, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -32, -32, -32, -32, 0, + -31, -31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -31, -31, -31, 0, // State 28 - -33, -33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -33, -33, -33, -33, 0, + -32, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -32, -32, -32, 0, // State 29 - -6, -6, -6, -6, -6, 0, 0, 0, 0, 0, 0, 0, 0, -6, -6, -6, -6, -6, + -6, -6, -6, -6, -6, 0, 0, 0, 0, 0, 0, 0, 0, -6, -6, -6, -6, // State 30 - -26, -26, -26, -26, -26, 0, 0, 0, 0, 0, 0, 0, 0, -26, -26, -26, -26, 0, + -26, -26, -26, -26, -26, 0, 0, 0, 0, 0, 0, 0, 0, -26, -26, -26, 0, // State 31 - -27, -27, -27, -27, -27, 0, 0, 0, 0, 0, 0, 0, 0, -27, -27, -27, -27, 0, + -25, -25, -25, -25, -25, 0, 0, 0, 0, 0, 0, 0, 0, -25, -25, -25, 0, // State 32 - -25, -25, -25, -25, -25, 0, 0, 0, 0, 0, 0, 0, 0, -25, -25, -25, -25, 0, + 0, 0, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 33 - 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -20, -20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -20, // State 34 - 0, -20, -20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -20, + 0, 0, 0, -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 35 - 0, 0, 0, -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -12, -12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 36 - 0, 0, -12, -12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 37 - 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -22, -22, -22, -22, -22, 0, 0, 0, 0, 0, 0, 0, 0, -22, -22, -22, 0, // State 38 - -22, -22, -22, -22, -22, 0, 0, 0, 0, 0, 0, 0, 0, -22, -22, -22, -22, 0, + 0, -19, -19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -19, // State 39 - 0, -19, -19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -19, + 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 40 - 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 41 - 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 42 - 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -34, 0, -34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -34, -34, -34, 0, // State 43 - -35, 0, -35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -35, -35, -35, -35, 0, + -23, -23, -23, -23, -23, 0, 0, 0, 0, 0, 0, 0, 0, -23, -23, -23, 0, // State 44 - -23, -23, -23, -23, -23, 0, 0, 0, 0, 0, 0, 0, 0, -23, -23, -23, -23, 0, + 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 45 - 0, 0, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 46 - 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -14, -14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -14, // State 47 - 0, -14, -14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -14, + 0, -13, -13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -13, // State 48 - 0, -13, -13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -13, + 0, -15, -15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -15, // State 49 - 0, -15, -15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -15, + 0, 0, -27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 50 - 0, 0, -28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 51 - 0, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -17, -17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -17, // State 52 - 0, -17, -17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -17, + 0, 0, -28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 53 - 0, 0, -29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -4, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -4, -4, -4, 0, // State 54 - -4, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -4, -4, -4, -4, 0, + -7, 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, 0, 0, -7, -7, -7, 0, // State 55 - -7, 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, 0, 0, -7, -7, -7, -7, 0, + 0, 0, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, 0, 0, 0, // State 56 - 0, 0, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, 0, 0, 0, 0, + 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 57 - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -33, -33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -33, -33, -33, 0, // State 58 - -34, -34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -34, -34, -34, -34, 0, + 0, -18, -18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -18, // State 59 - 0, -18, -18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -18, + 0, -16, -16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16, // State 60 - 0, -16, -16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16, + -5, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, 0, // State 61 - -5, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, -5, 0, + 0, 0, -9, 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, -9, 0, 0, 0, // State 62 - 0, 0, -9, 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, -9, 0, 0, 0, 0, - // State 63 - 0, 0, 0, -11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]; fn __action(state: i8, integer: usize) -> i8 { - __ACTION[(state as usize) * 18 + integer] + __ACTION[(state as usize) * 17 + integer] } const __EOF_ACTION: &[i8] = &[ // State 0 @@ -215,7 +213,7 @@ mod __parse__Instr { // State 21 0, // State 22 - -36, + -35, // State 23 0, // State 24 @@ -237,9 +235,9 @@ mod __parse__Instr { // State 32 0, // State 33 - 0, - // State 34 -20, + // State 34 + 0, // State 35 0, // State 36 @@ -247,9 +245,9 @@ mod __parse__Instr { // State 37 0, // State 38 - 0, - // State 39 -19, + // State 39 + 0, // State 40 0, // State 41 @@ -263,19 +261,19 @@ mod __parse__Instr { // State 45 0, // State 46 - 0, - // State 47 -14, - // State 48 + // State 47 -13, - // State 49 + // State 48 -15, + // State 49 + 0, // State 50 0, // State 51 - 0, - // State 52 -17, + // State 52 + 0, // State 53 0, // State 54 @@ -287,63 +285,61 @@ mod __parse__Instr { // State 57 0, // State 58 - 0, - // State 59 -18, - // State 60 + // State 59 -16, + // State 60 + 0, // State 61 0, // State 62 0, - // State 63 - 0, ]; fn __goto(state: i8, nt: usize) -> i8 { match nt { 2 => 21, 3 => match state { 10 => 17, - 3 => 33, - 8 => 37, - 18 => 50, + 3 => 32, + 8 => 36, + 18 => 49, _ => 26, }, 4 => match state { - 21 => 61, - _ => 54, + 21 => 60, + _ => 53, }, 5 => 18, 6 => 14, 7 => match state { - 20 => 57, - _ => 35, + 20 => 56, + _ => 34, }, 8 => match state { 5 => 12, 6 => 13, 0 => 22, - 11 => 40, - 12 => 41, - 13 => 42, - 17 => 46, + 11 => 39, + 12 => 40, + 13 => 41, + 17 => 45, _ => 11, }, 9 => match state { 2 => 10, - 7 | 20 => 36, - 15..=16 => 43, - 19 | 21 => 55, + 7 | 20 => 35, + 15..=16 => 42, + 19 | 21 => 54, _ => 27, }, - 10 => 51, + 10 => 50, 12 => match state { 1 => 28, _ => 16, }, 13 => 7, 14 => match state { - 16 => 45, + 16 => 44, _ => 20, }, _ => 0, @@ -365,7 +361,6 @@ mod __parse__Instr { r###""xor""###, r###"ACCUMULATOR"###, r###"ALPHANUMERIC"###, - r###"CURRENT_PEER_ID"###, r###"INIT_PEER_ID"###, r###"JSON_PATH"###, ]; @@ -421,7 +416,7 @@ mod __parse__Instr { #[inline] fn error_action(&self, state: i8) -> i8 { - __action(state, 18 - 1) + __action(state, 17 - 1) } #[inline] @@ -491,18 +486,17 @@ mod __parse__Instr { Token(2, _) if true => Some(2), Token(3, _) if true => Some(3), Token(4, _) if true => Some(4), - Token(12, _) if true => Some(5), - Token(13, _) if true => Some(6), - Token(14, _) if true => Some(7), - Token(15, _) if true => Some(8), - Token(16, _) if true => Some(9), - Token(17, _) if true => Some(10), - Token(18, _) if true => Some(11), - Token(10, _) if true => Some(12), - Token(8, _) if true => Some(13), + Token(11, _) if true => Some(5), + Token(12, _) if true => Some(6), + Token(13, _) if true => Some(7), + Token(14, _) if true => Some(8), + Token(15, _) if true => Some(9), + Token(16, _) if true => Some(10), + Token(17, _) if true => Some(11), + Token(9, _) if true => Some(12), + Token(7, _) if true => Some(13), Token(5, _) if true => Some(14), - Token(6, _) if true => Some(15), - Token(9, _) if true => Some(16), + Token(8, _) if true => Some(15), _ => None, } } @@ -516,8 +510,8 @@ mod __parse__Instr { ) -> __Symbol<'input> { match __token_index { - 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 => match __token { - Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(10, __tok0) | Token(8, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(9, __tok0) if true => __Symbol::Variant0(__tok0), + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 => match __token { + Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(9, __tok0) | Token(7, __tok0) | Token(5, __tok0) | Token(8, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), }, _ => unreachable!(), @@ -693,7 +687,7 @@ mod __parse__Instr { 26 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, - nonterminal_produced: 9, + nonterminal_produced: 10, } } 27 => { @@ -703,48 +697,42 @@ mod __parse__Instr { } } 28 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 10, - } - } - 29 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, nonterminal_produced: 11, } } - 30 => { + 29 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 0, nonterminal_produced: 11, } } - 31 => { + 30 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, nonterminal_produced: 12, } } - 32 => { + 31 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, nonterminal_produced: 13, } } - 33 => { + 32 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 4, nonterminal_produced: 13, } } - 34 => { + 33 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, nonterminal_produced: 14, } } - 35 => __state_machine::SimulatedReduce::Accept, + 34 => __state_machine::SimulatedReduce::Accept, _ => panic!("invalid reduction index {}", __reduce_index) } } @@ -937,9 +925,6 @@ mod __parse__Instr { __reduce33(errors, input, __lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), &())>) } 34 => { - __reduce34(errors, input, __lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), &())>) - } - 35 => { // __Instr = Instr => ActionFn(0); let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0.clone(); @@ -1081,11 +1066,11 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // () = Arg => ActionFn(29); + // () = Arg => ActionFn(28); let __sym0 = __pop_Variant2(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action29::<>(errors, input, __sym0); + let __nt = super::__action28::<>(errors, input, __sym0); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (1, 0) } @@ -1100,10 +1085,10 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // ()* = => ActionFn(27); + // ()* = => ActionFn(26); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action27::<>(errors, input, &__start, &__end); + let __nt = super::__action26::<>(errors, input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 1) } @@ -1118,11 +1103,11 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // ()* = ()+ => ActionFn(28); + // ()* = ()+ => ActionFn(27); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action28::<>(errors, input, __sym0); + let __nt = super::__action27::<>(errors, input, __sym0); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 1) } @@ -1137,11 +1122,11 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // ()+ = Arg => ActionFn(34); + // ()+ = Arg => ActionFn(33); let __sym0 = __pop_Variant2(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action34::<>(errors, input, __sym0); + let __nt = super::__action33::<>(errors, input, __sym0); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } @@ -1156,13 +1141,13 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // ()+ = ()+, Arg => ActionFn(35); + // ()+ = ()+, Arg => ActionFn(34); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant2(__symbols); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action35::<>(errors, input, __sym0, __sym1); + let __nt = super::__action34::<>(errors, input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 2) } @@ -1177,11 +1162,11 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // Alphanumeric = ALPHANUMERIC => ActionFn(26); + // Alphanumeric = ALPHANUMERIC => ActionFn(25); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action26::<>(errors, input, __sym0); + let __nt = super::__action25::<>(errors, input, __sym0); __symbols.push((__start, __Symbol::Variant0(__nt), __end)); (1, 3) } @@ -1215,13 +1200,13 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // Args = "[", "]" => ActionFn(36); + // Args = "[", "]" => ActionFn(35); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action36::<>(errors, input, __sym0, __sym1); + let __nt = super::__action35::<>(errors, input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 5) } @@ -1236,14 +1221,14 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // Args = "[", ()+, "]" => ActionFn(37); + // Args = "[", ()+, "]" => ActionFn(36); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant3(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym2.2.clone(); - let __nt = super::__action37::<>(errors, input, __sym0, __sym1, __sym2); + let __nt = super::__action36::<>(errors, input, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (3, 5) } @@ -1391,7 +1376,7 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // Instr = "(", "call", PeerPart, FPart, Args, Output, ")" => ActionFn(38); + // Instr = "(", "call", PeerPart, FPart, Args, Output, ")" => ActionFn(37); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant7(__symbols); @@ -1402,7 +1387,7 @@ mod __parse__Instr { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym6.2.clone(); - let __nt = super::__action38::<>(errors, input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action37::<>(errors, input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (7, 8) } @@ -1417,7 +1402,7 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // Instr = "(", "call", PeerPart, FPart, Args, ")" => ActionFn(39); + // Instr = "(", "call", PeerPart, FPart, Args, ")" => ActionFn(38); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant4(__symbols); @@ -1427,7 +1412,7 @@ mod __parse__Instr { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); - let __nt = super::__action39::<>(errors, input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action38::<>(errors, input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (6, 8) } @@ -1612,7 +1597,7 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // InstructionValue = CURRENT_PEER_ID => ActionFn(24); + // InstructionValue = INIT_PEER_ID => ActionFn(24); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); @@ -1630,25 +1615,6 @@ mod __parse__Instr { __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) - { - // InstructionValue = INIT_PEER_ID => ActionFn(25); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action25::<>(errors, input, __sym0); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (1, 9) - } - pub(crate) fn __reduce27< - 'input, - 'err, - >( - errors: &'err mut Vec, InstructionError>>, - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: ::std::marker::PhantomData<(&'input (), &'err ())>, - ) -> (usize, usize) { // Output = Alphanumeric => ActionFn(14); let __sym0 = __pop_Variant0(__symbols); @@ -1658,7 +1624,7 @@ mod __parse__Instr { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 10) } - pub(crate) fn __reduce28< + pub(crate) fn __reduce27< 'input, 'err, >( @@ -1677,6 +1643,25 @@ mod __parse__Instr { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 10) } + pub(crate) fn __reduce28< + 'input, + 'err, + >( + errors: &'err mut Vec, InstructionError>>, + input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, + _: ::std::marker::PhantomData<(&'input (), &'err ())>, + ) -> (usize, usize) + { + // Output? = Output => ActionFn(29); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action29::<>(errors, input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 11) + } pub(crate) fn __reduce29< 'input, 'err, @@ -1688,33 +1673,14 @@ mod __parse__Instr { _: ::std::marker::PhantomData<(&'input (), &'err ())>, ) -> (usize, usize) { - // Output? = Output => ActionFn(30); - let __sym0 = __pop_Variant7(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action30::<>(errors, input, __sym0); - __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (1, 11) - } - pub(crate) fn __reduce30< - 'input, - 'err, - >( - errors: &'err mut Vec, InstructionError>>, - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: ::std::marker::PhantomData<(&'input (), &'err ())>, - ) -> (usize, usize) - { - // Output? = => ActionFn(31); + // Output? = => ActionFn(30); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action31::<>(errors, input, &__start, &__end); + let __nt = super::__action30::<>(errors, input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce31< + pub(crate) fn __reduce30< 'input, 'err, >( @@ -1733,7 +1699,7 @@ mod __parse__Instr { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (1, 12) } - pub(crate) fn __reduce32< + pub(crate) fn __reduce31< 'input, 'err, >( @@ -1752,7 +1718,7 @@ mod __parse__Instr { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 13) } - pub(crate) fn __reduce33< + pub(crate) fn __reduce32< 'input, 'err, >( @@ -1775,7 +1741,7 @@ mod __parse__Instr { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 13) } - pub(crate) fn __reduce34< + pub(crate) fn __reduce33< 'input, 'err, >( @@ -1814,7 +1780,6 @@ mod __intern_token { ("^(\\))", false), ("^(\\[)", false), ("^(\\])", false), - ("^(%current_peer_id%)", false), ("^(%init_peer_id%)", false), ("^(;[\u{0}-\t\u{b}-\u{c}\u{e}-\u{10ffff}]*[\n\r]*)", true), ("^([\\-0-9A-Z_a-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ\u{300}-ʹͶ-ͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ\u{483}-ԯԱ-Ֆՙՠ-ֈ\u{591}-\u{5bd}\u{5bf}\u{5c1}-\u{5c2}\u{5c4}-\u{5c5}\u{5c7}א-תׯ-ײ\u{610}-\u{61a}ؠ-٩ٮ-ۓە-\u{6dc}\u{6df}-\u{6e8}\u{6ea}-ۼۿܐ-\u{74a}ݍ-ޱ߀-ߵߺ\u{7fd}ࠀ-\u{82d}ࡀ-\u{85b}ࡠ-ࡪࢠ-ࢴࢶ-ࣇ\u{8d3}-\u{8e1}\u{8e3}-\u{963}०-९ॱ-ঃঅ-ঌএ-ঐও-নপ-রলশ-হ\u{9bc}-\u{9c4}ে-ৈো-ৎ\u{9d7}ড়-ঢ়য়-\u{9e3}০-ৱৼ\u{9fe}\u{a01}-ਃਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹ\u{a3c}ਾ-\u{a42}\u{a47}-\u{a48}\u{a4b}-\u{a4d}\u{a51}ਖ਼-ੜਫ਼੦-\u{a75}\u{a81}-ઃઅ-ઍએ-ઑઓ-નપ-રલ-ળવ-હ\u{abc}-\u{ac5}\u{ac7}-ૉો-\u{acd}ૐૠ-\u{ae3}૦-૯ૹ-\u{aff}\u{b01}-ଃଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଵ-ହ\u{b3c}-\u{b44}େ-ୈୋ-\u{b4d}\u{b55}-\u{b57}ଡ଼-ଢ଼ୟ-\u{b63}୦-୯ୱ\u{b82}-ஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-ஹ\u{bbe}-ூெ-ைொ-\u{bcd}ௐ\u{bd7}௦-௯\u{c00}-ఌఎ-ఐఒ-నప-హఽ-ౄ\u{c46}-\u{c48}\u{c4a}-\u{c4d}\u{c55}-\u{c56}ౘ-ౚౠ-\u{c63}౦-౯ಀ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ\u{cbc}-ೄ\u{cc6}-ೈೊ-\u{ccd}\u{cd5}-\u{cd6}ೞೠ-\u{ce3}೦-೯ೱ-ೲ\u{d00}-ഌഎ-ഐഒ-\u{d44}െ-ൈൊ-ൎൔ-\u{d57}ൟ-\u{d63}൦-൯ൺ-ൿ\u{d81}-ඃඅ-ඖක-නඳ-රලව-ෆ\u{dca}\u{dcf}-\u{dd4}\u{dd6}ෘ-\u{ddf}෦-෯ෲ-ෳก-\u{e3a}เ-\u{e4e}๐-๙ກ-ຂຄຆ-ຊຌ-ຣລວ-ຽເ-ໄໆ\u{ec8}-\u{ecd}໐-໙ໜ-ໟༀ\u{f18}-\u{f19}༠-༩\u{f35}\u{f37}\u{f39}༾-ཇཉ-ཬ\u{f71}-\u{f84}\u{f86}-\u{f97}\u{f99}-\u{fbc}\u{fc6}က-၉ၐ-\u{109d}Ⴀ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ\u{135d}-\u{135f}ᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-\u{1714}ᜠ-\u{1734}ᝀ-\u{1753}ᝠ-ᝬᝮ-ᝰ\u{1772}-\u{1773}ក-\u{17d3}ៗៜ-\u{17dd}០-៩\u{180b}-\u{180d}᠐-᠙ᠠ-ᡸᢀ-ᢪᢰ-ᣵᤀ-ᤞ\u{1920}-ᤫᤰ-\u{193b}᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-\u{1a1b}ᨠ-\u{1a5e}\u{1a60}-\u{1a7c}\u{1a7f}-᪉᪐-᪙ᪧ\u{1ab0}-\u{1ac0}\u{1b00}-ᭋ᭐-᭙\u{1b6b}-\u{1b73}\u{1b80}-᯳ᰀ-\u{1c37}᱀-᱉ᱍ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿ\u{1cd0}-\u{1cd2}\u{1cd4}-ᳺᴀ-\u{1df9}\u{1dfb}-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ\u{200c}-\u{200d}‿-⁀⁔ⁱⁿₐ-ₜ\u{20d0}-\u{20f0}ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⒶ-ⓩⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ\u{2d7f}-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ\u{2de0}-\u{2dff}ⸯ々-〇〡-\u{302f}〱-〵〸-〼ぁ-ゖ\u{3099}-\u{309a}ゝ-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-鿼ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-\u{a672}\u{a674}-\u{a67d}ꙿ-\u{a6f1}ꜗ-ꜟꜢ-ꞈꞋ-ꞿꟂ-ꟊꟵ-ꠧ\u{a82c}ꡀ-ꡳꢀ-\u{a8c5}꣐-꣙\u{a8e0}-ꣷꣻꣽ-\u{a92d}ꤰ-꥓ꥠ-ꥼ\u{a980}-꧀ꧏ-꧙ꧠ-ꧾꨀ-\u{aa36}ꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺ-ꫂꫛ-ꫝꫠ-ꫯꫲ-\u{aaf6}ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯪ꯬-\u{abed}꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ\u{fe00}-\u{fe0f}\u{fe20}-\u{fe2f}︳-︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ𐀀-𐀋𐀍-𐀦𐀨-𐀺𐀼-𐀽𐀿-𐁍𐁐-𐁝𐂀-𐃺𐅀-𐅴\u{101fd}𐊀-𐊜𐊠-𐋐\u{102e0}𐌀-𐌟𐌭-𐍊𐍐-\u{1037a}𐎀-𐎝𐎠-𐏃𐏈-𐏏𐏑-𐏕𐐀-𐒝𐒠-𐒩𐒰-𐓓𐓘-𐓻𐔀-𐔧𐔰-𐕣𐘀-𐜶𐝀-𐝕𐝠-𐝧𐠀-𐠅𐠈𐠊-𐠵𐠷-𐠸𐠼𐠿-𐡕𐡠-𐡶𐢀-𐢞𐣠-𐣲𐣴-𐣵𐤀-𐤕𐤠-𐤹𐦀-𐦷𐦾-𐦿𐨀-\u{10a03}\u{10a05}-\u{10a06}\u{10a0c}-𐨓𐨕-𐨗𐨙-𐨵\u{10a38}-\u{10a3a}\u{10a3f}𐩠-𐩼𐪀-𐪜𐫀-𐫇𐫉-\u{10ae6}𐬀-𐬵𐭀-𐭕𐭠-𐭲𐮀-𐮑𐰀-𐱈𐲀-𐲲𐳀-𐳲𐴀-\u{10d27}𐴰-𐴹𐺀-𐺩\u{10eab}-\u{10eac}𐺰-𐺱𐼀-𐼜𐼧𐼰-\u{10f50}𐾰-𐿄𐿠-𐿶𑀀-\u{11046}𑁦-𑁯\u{1107f}-\u{110ba}𑃐-𑃨𑃰-𑃹\u{11100}-\u{11134}𑄶-𑄿𑅄-𑅇𑅐-\u{11173}𑅶\u{11180}-𑇄\u{111c9}-\u{111cc}𑇎-𑇚𑇜𑈀-𑈑𑈓-\u{11237}\u{1123e}𑊀-𑊆𑊈𑊊-𑊍𑊏-𑊝𑊟-𑊨𑊰-\u{112ea}𑋰-𑋹\u{11300}-𑌃𑌅-𑌌𑌏-𑌐𑌓-𑌨𑌪-𑌰𑌲-𑌳𑌵-𑌹\u{1133b}-𑍄𑍇-𑍈𑍋-𑍍𑍐\u{11357}𑍝-𑍣\u{11366}-\u{1136c}\u{11370}-\u{11374}𑐀-𑑊𑑐-𑑙\u{1145e}-𑑡𑒀-𑓅𑓇𑓐-𑓙𑖀-\u{115b5}𑖸-\u{115c0}𑗘-\u{115dd}𑘀-\u{11640}𑙄𑙐-𑙙𑚀-𑚸𑛀-𑛉𑜀-𑜚\u{1171d}-\u{1172b}𑜰-𑜹𑠀-\u{1183a}𑢠-𑣩𑣿-𑤆𑤉𑤌-𑤓𑤕-𑤖𑤘-𑤵𑤷-𑤸\u{1193b}-\u{11943}𑥐-𑥙𑦠-𑦧𑦪-\u{119d7}\u{119da}-𑧡𑧣-𑧤𑨀-\u{11a3e}\u{11a47}𑩐-\u{11a99}𑪝𑫀-𑫸𑰀-𑰈𑰊-\u{11c36}\u{11c38}-𑱀𑱐-𑱙𑱲-𑲏\u{11c92}-\u{11ca7}𑲩-\u{11cb6}𑴀-𑴆𑴈-𑴉𑴋-\u{11d36}\u{11d3a}\u{11d3c}-\u{11d3d}\u{11d3f}-\u{11d47}𑵐-𑵙𑵠-𑵥𑵧-𑵨𑵪-𑶎\u{11d90}-\u{11d91}𑶓-𑶘𑶠-𑶩𑻠-𑻶𑾰𒀀-𒎙𒐀-𒑮𒒀-𒕃𓀀-𓐮𔐀-𔙆𖠀-𖨸𖩀-𖩞𖩠-𖩩𖫐-𖫭\u{16af0}-\u{16af4}𖬀-\u{16b36}𖭀-𖭃𖭐-𖭙𖭣-𖭷𖭽-𖮏𖹀-𖹿𖼀-𖽊\u{16f4f}-𖾇\u{16f8f}-𖾟𖿠-𖿡𖿣-\u{16fe4}𖿰-𖿱𗀀-𘟷𘠀-𘳕𘴀-𘴈𛀀-𛄞𛅐-𛅒𛅤-𛅧𛅰-𛋻𛰀-𛱪𛱰-𛱼𛲀-𛲈𛲐-𛲙\u{1bc9d}-\u{1bc9e}\u{1d165}-\u{1d169}𝅭-\u{1d172}\u{1d17b}-\u{1d182}\u{1d185}-\u{1d18b}\u{1d1aa}-\u{1d1ad}\u{1d242}-\u{1d244}𝐀-𝑔𝑖-𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒹𝒻𝒽-𝓃𝓅-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔞-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕒-𝚥𝚨-𝛀𝛂-𝛚𝛜-𝛺𝛼-𝜔𝜖-𝜴𝜶-𝝎𝝐-𝝮𝝰-𝞈𝞊-𝞨𝞪-𝟂𝟄-𝟋𝟎-𝟿\u{1da00}-\u{1da36}\u{1da3b}-\u{1da6c}\u{1da75}\u{1da84}\u{1da9b}-\u{1da9f}\u{1daa1}-\u{1daaf}\u{1e000}-\u{1e006}\u{1e008}-\u{1e018}\u{1e01b}-\u{1e021}\u{1e023}-\u{1e024}\u{1e026}-\u{1e02a}𞄀-𞄬\u{1e130}-𞄽𞅀-𞅉𞅎𞋀-𞋹𞠀-𞣄\u{1e8d0}-\u{1e8d6}𞤀-𞥋𞥐-𞥙𞸀-𞸃𞸅-𞸟𞸡-𞸢𞸤𞸧𞸩-𞸲𞸴-𞸷𞸹𞸻𞹂𞹇𞹉𞹋𞹍-𞹏𞹑-𞹒𞹔𞹗𞹙𞹛𞹝𞹟𞹡-𞹢𞹤𞹧-𞹪𞹬-𞹲𞹴-𞹷𞹹-𞹼𞹾𞺀-𞺉𞺋-𞺛𞺡-𞺣𞺥-𞺩𞺫-𞺻🄰-🅉🅐-🅩🅰-🆉🯰-🯹𠀀-𪛝𪜀-𫜴𫝀-𫠝𫠠-𬺡𬺰-𮯠丽-𪘀𰀀-𱍊\u{e0100}-\u{e01ef}]+)", false), @@ -2206,25 +2171,12 @@ fn __action24< input: &'input str, (_, __0, _): (usize, &'input str, usize), ) -> InstructionValue<'input> -{ - InstructionValue::CurrentPeerId -} - -#[allow(unused_variables)] -fn __action25< - 'input, - 'err, ->( - errors: &'err mut Vec, InstructionError>>, - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> InstructionValue<'input> { InstructionValue::InitPeerId } #[allow(unused_variables)] -fn __action26< +fn __action25< 'input, 'err, >( @@ -2237,7 +2189,7 @@ fn __action26< } #[allow(unused_variables)] -fn __action27< +fn __action26< 'input, 'err, >( @@ -2251,7 +2203,7 @@ fn __action27< } #[allow(unused_variables)] -fn __action28< +fn __action27< 'input, 'err, >( @@ -2264,7 +2216,7 @@ fn __action28< } #[allow(unused_variables)] -fn __action29< +fn __action28< 'input, 'err, >( @@ -2277,7 +2229,7 @@ fn __action29< } #[allow(unused_variables)] -fn __action30< +fn __action29< 'input, 'err, >( @@ -2290,7 +2242,7 @@ fn __action30< } #[allow(unused_variables)] -fn __action31< +fn __action30< 'input, 'err, >( @@ -2304,7 +2256,7 @@ fn __action31< } #[allow(unused_variables)] -fn __action32< +fn __action31< 'input, 'err, >( @@ -2317,7 +2269,7 @@ fn __action32< } #[allow(unused_variables)] -fn __action33< +fn __action32< 'input, 'err, >( @@ -2331,7 +2283,7 @@ fn __action33< } #[allow(unused_variables)] -fn __action34< +fn __action33< 'input, 'err, >( @@ -2342,13 +2294,13 @@ fn __action34< { let __start0 = __0.0.clone(); let __end0 = __0.2.clone(); - let __temp0 = __action29( + let __temp0 = __action28( errors, input, __0, ); let __temp0 = (__start0, __temp0, __end0); - __action32( + __action31( errors, input, __temp0, @@ -2356,7 +2308,7 @@ fn __action34< } #[allow(unused_variables)] -fn __action35< +fn __action34< 'input, 'err, >( @@ -2368,13 +2320,13 @@ fn __action35< { let __start0 = __1.0.clone(); let __end0 = __1.2.clone(); - let __temp0 = __action29( + let __temp0 = __action28( errors, input, __1, ); let __temp0 = (__start0, __temp0, __end0); - __action33( + __action32( errors, input, __0, @@ -2383,7 +2335,7 @@ fn __action35< } #[allow(unused_variables)] -fn __action36< +fn __action35< 'input, 'err, >( @@ -2395,7 +2347,7 @@ fn __action36< { let __start0 = __0.2.clone(); let __end0 = __1.0.clone(); - let __temp0 = __action27( + let __temp0 = __action26( errors, input, &__start0, @@ -2412,7 +2364,7 @@ fn __action36< } #[allow(unused_variables)] -fn __action37< +fn __action36< 'input, 'err, >( @@ -2425,7 +2377,7 @@ fn __action37< { let __start0 = __1.0.clone(); let __end0 = __1.2.clone(); - let __temp0 = __action28( + let __temp0 = __action27( errors, input, __1, @@ -2441,7 +2393,7 @@ fn __action37< } #[allow(unused_variables)] -fn __action38< +fn __action37< 'input, 'err, >( @@ -2458,7 +2410,7 @@ fn __action38< { let __start0 = __5.0.clone(); let __end0 = __5.2.clone(); - let __temp0 = __action30( + let __temp0 = __action29( errors, input, __5, @@ -2478,7 +2430,7 @@ fn __action38< } #[allow(unused_variables)] -fn __action39< +fn __action38< 'input, 'err, >( @@ -2494,7 +2446,7 @@ fn __action39< { let __start0 = __4.2.clone(); let __end0 = __5.0.clone(); - let __temp0 = __action31( + let __temp0 = __action30( errors, input, &__start0, diff --git a/crates/air-parser/src/lalrpop/tests.rs b/crates/air-parser/src/lalrpop/tests.rs index fddac791..7f6f0c17 100644 --- a/crates/air-parser/src/lalrpop/tests.rs +++ b/crates/air-parser/src/lalrpop/tests.rs @@ -238,16 +238,21 @@ fn parse_fold_with_xor_par_seq() { } #[test] -fn parse_current_init_peer_id() { - let source_code = r#" +fn parse_init_peer_id() { + let peer_id = String::from("some_peer_id"); + let source_code = format!( + r#" (seq - (call %current_peer_id% ("local_service_id" "local_fn_name") []) + (call "{}" ("local_service_id" "local_fn_name") []) (call %init_peer_id% ("service_id" "fn_name") []) - )"#; + )"#, + peer_id + ); + let instruction = parse(&source_code.as_ref()); let expected = seq( Instruction::Call(Call { - peer_part: PeerPk(CurrentPeerId), + peer_part: PeerPk(InstructionValue::Literal(&peer_id)), function_part: ServiceIdWithFuncName( Literal("local_service_id"), Literal("local_fn_name"), @@ -262,24 +267,30 @@ fn parse_current_init_peer_id() { output: None, }), ); + assert_eq!(instruction, expected); } #[test] fn seq_par_call() { - let source_code = r#" + let peer_id = String::from("some_peer_id"); + let source_code = format!( + r#" (seq (par - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_1) - (call "remote_peer_id" ("service_id" "fn_name") [] g) + (call "{0}" ("local_service_id" "local_fn_name") [] result_1) + (call "{0}" ("service_id" "fn_name") [] g) ) - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_2) - )"#; + (call "{0}" ("local_service_id" "local_fn_name") [] result_2) + )"#, + peer_id, + ); + let instruction = parse(&source_code.as_ref()); let expected = seq( par( Instruction::Call(Call { - peer_part: PeerPk(CurrentPeerId), + peer_part: PeerPk(InstructionValue::Literal(&peer_id)), function_part: ServiceIdWithFuncName( Literal("local_service_id"), Literal("local_fn_name"), @@ -288,14 +299,14 @@ fn seq_par_call() { output: Scalar("result_1"), }), Instruction::Call(Call { - peer_part: PeerPk(Literal("remote_peer_id")), + peer_part: PeerPk(Literal(&peer_id)), function_part: ServiceIdWithFuncName(Literal("service_id"), Literal("fn_name")), args: Rc::new(vec![]), output: Scalar("g"), }), ), Instruction::Call(Call { - peer_part: PeerPk(CurrentPeerId), + peer_part: PeerPk(InstructionValue::Literal(&peer_id)), function_part: ServiceIdWithFuncName( Literal("local_service_id"), Literal("local_fn_name"), @@ -304,6 +315,7 @@ fn seq_par_call() { output: Scalar("result_2"), }), ); + assert_eq!(instruction, expected); } diff --git a/crates/polyplets/Cargo.toml b/crates/polyplets/Cargo.toml index e83e5a4a..cee496e1 100644 --- a/crates/polyplets/Cargo.toml +++ b/crates/polyplets/Cargo.toml @@ -3,6 +3,7 @@ name = "polyplets" version = "0.1.0" authors = ["Fluence Labs"] edition = "2018" +license = "Apache-2.0" [lib] name = "polyplets" diff --git a/crates/stepper-interface/Cargo.toml b/crates/stepper-interface/Cargo.toml index f2015505..70cf7d85 100644 --- a/crates/stepper-interface/Cargo.toml +++ b/crates/stepper-interface/Cargo.toml @@ -4,6 +4,7 @@ description = "Interface of the Aquamarine stepper" version = "0.1.0" authors = ["Fluence Labs"] edition = "2018" +license = "Apache-2.0" [lib] name = "stepper_interface" diff --git a/crates/test-module/Cargo.toml b/crates/test-module/Cargo.toml index 9fa5ddbe..6d656984 100644 --- a/crates/test-module/Cargo.toml +++ b/crates/test-module/Cargo.toml @@ -3,6 +3,7 @@ name = "aqua-test-module" version = "0.1.0" authors = ["Fluence Labs"] edition = "2018" +license = "Apache-2.0" [[bin]] name = "aqua_test_module" diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 45c8f777..c21cd4bd 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -3,6 +3,7 @@ name = "aqua-test-utils" version = "0.1.0" authors = ["Fluence Labs"] edition = "2018" +license = "Apache-2.0" [lib] name = "aqua_test_utils" @@ -10,5 +11,5 @@ path = "src/lib.rs" [dependencies] fluence = { version = "=0.2.13", features = ["logger"] } -aquamarine-vm = { git = "https://github.com/fluencelabs/fce", branch = "master", features = ["raw-aquamarine-vm-api"] } +aquamarine-vm = { version = "=0.1.6", features = ["raw-aquamarine-vm-api"] } serde_json = "1.0.56" diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index c1313136..41969777 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -29,10 +29,10 @@ pub use aquamarine_vm::vec1::Vec1; pub use aquamarine_vm::AquamarineVM; pub use aquamarine_vm::AquamarineVMConfig; pub use aquamarine_vm::AquamarineVMError; -pub use aquamarine_vm::HostExportedFunc; -pub use aquamarine_vm::HostImportDescriptor; +pub use aquamarine_vm::CallServiceClosure; pub use aquamarine_vm::IType; pub use aquamarine_vm::IValue; +pub use aquamarine_vm::ParticleParameters; pub use aquamarine_vm::StepperOutcome; use std::collections::HashMap; @@ -41,21 +41,14 @@ use std::path::PathBuf; type JValue = serde_json::Value; pub fn create_aqua_vm( - call_service: HostExportedFunc, + call_service: CallServiceClosure, current_peer_id: impl Into, ) -> AquamarineVM { - let call_service_descriptor = HostImportDescriptor { - host_exported_func: call_service, - argument_types: vec![IType::String, IType::String, IType::String, IType::String], - output_type: Some(IType::Record(0)), - error_handler: None, - }; - let tmp_dir = std::env::temp_dir(); let config = AquamarineVMConfig { aquamarine_wasm_path: PathBuf::from("../target/wasm32-wasi/debug/aquamarine.wasm"), - call_service: call_service_descriptor, + call_service, current_peer_id: current_peer_id.into(), particle_data_store: tmp_dir, logging_mask: i32::max_value(), @@ -64,7 +57,7 @@ pub fn create_aqua_vm( AquamarineVM::new(config).expect("vm should be created") } -pub fn unit_call_service() -> HostExportedFunc { +pub fn unit_call_service() -> CallServiceClosure { Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![ @@ -76,7 +69,7 @@ pub fn unit_call_service() -> HostExportedFunc { }) } -pub fn echo_string_call_service() -> HostExportedFunc { +pub fn echo_string_call_service() -> CallServiceClosure { Box::new(|_, args| -> Option { let arg = match &args[2] { IValue::String(str) => str, @@ -95,7 +88,7 @@ pub fn echo_string_call_service() -> HostExportedFunc { }) } -pub fn echo_number_call_service() -> HostExportedFunc { +pub fn echo_number_call_service() -> CallServiceClosure { Box::new(|_, args| -> Option { let arg = match &args[2] { IValue::String(str) => str, @@ -110,7 +103,7 @@ pub fn echo_number_call_service() -> HostExportedFunc { }) } -pub fn set_variable_call_service(json: impl Into) -> HostExportedFunc { +pub fn set_variable_call_service(json: impl Into) -> CallServiceClosure { let json = json.into(); Box::new(move |_, _| -> Option { Some(IValue::Record( @@ -119,7 +112,7 @@ pub fn set_variable_call_service(json: impl Into) -> HostExportedFunc { }) } -pub fn set_variables_call_service(ret_mapping: HashMap) -> HostExportedFunc { +pub fn set_variables_call_service(ret_mapping: HashMap) -> CallServiceClosure { Box::new(move |_, args| -> Option { let arg_name = match &args[2] { IValue::String(json_str) => { diff --git a/stepper-lib/Cargo.toml b/stepper-lib/Cargo.toml index 4d6a2b98..318efa8f 100644 --- a/stepper-lib/Cargo.toml +++ b/stepper-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stepper-lib" -version = "0.1.3" +version = "0.2.0" authors = ["Fluence Labs"] edition = "2018" @@ -28,7 +28,7 @@ wasm-bindgen = "=0.2.65" [dev_dependencies] aqua-test-utils = { path = "../crates/test-utils" } -fluence-app-service = "=0.1.17" +fluence-app-service = "=0.1.18" criterion = "0.3.3" csv = "1.1.5" diff --git a/stepper-lib/benches/call_benchmark.rs b/stepper-lib/benches/call_benchmark.rs index f86a0f2f..024475e8 100644 --- a/stepper-lib/benches/call_benchmark.rs +++ b/stepper-lib/benches/call_benchmark.rs @@ -13,7 +13,7 @@ use std::cell::RefCell; thread_local!(static VM: RefCell = RefCell::new(create_aqua_vm(unit_call_service(), "test_peer_id"))); thread_local!(static SCRIPT: String = String::from( r#" - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_name) + (call "test_peer_id" ("local_service_id" "local_fn_name") [] result_name) "#, ) ); diff --git a/stepper-lib/benches/chat_benchmark.rs b/stepper-lib/benches/chat_benchmark.rs index 98735a4b..64b224ba 100644 --- a/stepper-lib/benches/chat_benchmark.rs +++ b/stepper-lib/benches/chat_benchmark.rs @@ -2,7 +2,7 @@ use aqua_test_utils::create_aqua_vm; use aqua_test_utils::unit_call_service; use aqua_test_utils::AquamarineVM; use aqua_test_utils::AquamarineVMError; -use aqua_test_utils::HostExportedFunc; +use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::StepperOutcome; use aqua_test_utils::Vec1; @@ -16,7 +16,7 @@ use std::cell::RefCell; thread_local!(static RELAY_1_VM: RefCell = RefCell::new(create_aqua_vm(unit_call_service(), "Relay1"))); thread_local!(static RELAY_2_VM: RefCell = RefCell::new(create_aqua_vm(unit_call_service(), "Relay2"))); thread_local!(static REMOTE_VM: RefCell = RefCell::new({ - let members_call_service: HostExportedFunc = Box::new(|_, _| -> Option { + let members_call_service: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![ IValue::S32(0), diff --git a/stepper-lib/benches/create_service_benchmark.rs b/stepper-lib/benches/create_service_benchmark.rs index ff11b782..0a9a2534 100644 --- a/stepper-lib/benches/create_service_benchmark.rs +++ b/stepper-lib/benches/create_service_benchmark.rs @@ -2,7 +2,7 @@ use aqua_test_utils::create_aqua_vm; use aqua_test_utils::set_variables_call_service; use aqua_test_utils::AquamarineVM; use aqua_test_utils::AquamarineVMError; -use aqua_test_utils::HostExportedFunc; +use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::StepperOutcome; use aqua_test_utils::Vec1; @@ -20,7 +20,7 @@ thread_local!(static VM: RefCell = RefCell::new({ let add_blueprint_response = String::from("add_blueprint response"); let create_response = String::from("create response"); - let call_service: HostExportedFunc = Box::new(move |_, args| -> Option { + let call_service: CallServiceClosure = Box::new(move |_, args| -> Option { let builtin_service = match &args[0] { IValue::String(str) => str, _ => unreachable!(), diff --git a/stepper-lib/src/air/call.rs b/stepper-lib/src/air/call.rs index 016d60e5..a9c7c29f 100644 --- a/stepper-lib/src/air/call.rs +++ b/stepper-lib/src/air/call.rs @@ -79,13 +79,13 @@ mod tests { use aqua_test_utils::echo_string_call_service; use aqua_test_utils::set_variable_call_service; use aqua_test_utils::unit_call_service; - use aqua_test_utils::HostExportedFunc; + use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::Vec1; use std::rc::Rc; - // Check that %current_peer_id% alias works correctly (by comparing result with it and explicit peer id). + // Check that %init_peer_id% alias works correctly (by comparing result with it and explicit peer id). // Additionally, check that empty string for data does the same as empty call path. #[test] fn current_peer_id_call() { @@ -99,12 +99,12 @@ mod tests { let function_name = String::from("local_fn_name"); let script = format!( r#" - (call %current_peer_id% ("{}" "{}") [] result_name) + (call %init_peer_id% ("{}" "{}") [] result_name) "#, service_id, function_name ); - let res = call_vm!(vm, "asd", script.clone(), "[]", "[]"); + let res = call_vm!(vm, vm_peer_id.clone(), script.clone(), "[]", "[]"); let call_path: CallEvidencePath = serde_json::from_slice(&res.data).expect("should be a valid json"); let executed_call_state = Call(Executed(Rc::new(JValue::String(String::from("test"))))); @@ -176,7 +176,7 @@ mod tests { use crate::call_evidence::CallResult::*; use crate::call_evidence::EvidenceState::*; - let call_service: HostExportedFunc = Box::new(|_, args| -> Option { + let call_service: CallServiceClosure = Box::new(|_, args| -> Option { let arg = match &args[2] { IValue::String(str) => str, _ => unreachable!(), diff --git a/stepper-lib/src/air/call/triplet.rs b/stepper-lib/src/air/call/triplet.rs index bd248834..10c33ed1 100644 --- a/stepper-lib/src/air/call/triplet.rs +++ b/stepper-lib/src/air/call/triplet.rs @@ -81,7 +81,6 @@ fn resolve_to_string<'i>(value: &InstructionValue<'i>, ctx: &ExecutionCtx<'i>) - use crate::air::resolve::resolve_to_jvaluable; let resolved = match value { - InstructionValue::CurrentPeerId => ctx.current_peer_id.clone(), InstructionValue::InitPeerId => ctx.init_peer_id.clone(), InstructionValue::Literal(value) => value.to_string(), InstructionValue::Variable(name) => { diff --git a/stepper-lib/src/air/par.rs b/stepper-lib/src/air/par.rs index 0eb25dd9..6fa87bd7 100644 --- a/stepper-lib/src/air/par.rs +++ b/stepper-lib/src/air/par.rs @@ -195,14 +195,16 @@ mod tests { #[test] fn par_local_remote() { - let mut vm = create_aqua_vm(unit_call_service(), ""); + let local_peer_id = "local_peer_id"; + let mut vm = create_aqua_vm(unit_call_service(), local_peer_id); - let script = String::from( + let script = format!( r#" (par - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_name) + (call "{}" ("local_service_id" "local_fn_name") [] result_name) (call "remote_peer_id_2" ("service_id" "fn_name") [] g) )"#, + local_peer_id ); let res = call_vm!(vm, "", script, "[]", "[]"); diff --git a/stepper-lib/src/air/resolve.rs b/stepper-lib/src/air/resolve.rs index 7df41e90..6ff78d06 100644 --- a/stepper-lib/src/air/resolve.rs +++ b/stepper-lib/src/air/resolve.rs @@ -37,7 +37,6 @@ pub(crate) fn resolve_to_args<'i>( } match value { - InstructionValue::CurrentPeerId => handle_string_arg(ctx.current_peer_id.as_str(), ctx), InstructionValue::InitPeerId => handle_string_arg(ctx.init_peer_id.as_str(), ctx), InstructionValue::Literal(value) => handle_string_arg(value, ctx), InstructionValue::Variable(name) => { diff --git a/stepper-lib/src/air/seq.rs b/stepper-lib/src/air/seq.rs index c5f70eaf..d9e079bc 100644 --- a/stepper-lib/src/air/seq.rs +++ b/stepper-lib/src/air/seq.rs @@ -65,17 +65,20 @@ mod tests { #[test] fn seq_local_remote() { - let mut vm = create_aqua_vm(unit_call_service(), ""); + let local_peer_id = "local_peer_id"; + let remote_peer_id = String::from("remote_peer_id"); + let mut vm = create_aqua_vm(unit_call_service(), local_peer_id); - let script = String::from( + let script = format!( r#" (seq - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_name) - (call "remote_peer_id_2" ("service_id" "fn_name") [] g) + (call "{}" ("local_service_id" "local_fn_name") [] result_name) + (call "{}" ("service_id" "fn_name") [] g) )"#, + local_peer_id, remote_peer_id ); let res = call_vm!(vm, "asd", script, "[]", "[]"); - assert_eq!(res.next_peer_pks, vec![String::from("remote_peer_id_2")]); + assert_eq!(res.next_peer_pks, vec![remote_peer_id]); } } diff --git a/stepper-lib/src/air/xor.rs b/stepper-lib/src/air/xor.rs index 61f9c994..8df5f823 100644 --- a/stepper-lib/src/air/xor.rs +++ b/stepper-lib/src/air/xor.rs @@ -44,13 +44,13 @@ mod tests { use aqua_test_utils::call_vm; use aqua_test_utils::create_aqua_vm; - use aqua_test_utils::HostExportedFunc; + use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::Vec1; use std::rc::Rc; - fn fallible_call_service(fallible_service_id: String) -> HostExportedFunc { + fn fallible_call_service(fallible_service_id: String) -> CallServiceClosure { Box::new(move |_, args| -> Option { let builtin_service = match &args[0] { IValue::String(str) => str, @@ -76,15 +76,17 @@ mod tests { use crate::call_evidence::CallResult::*; use crate::call_evidence::EvidenceState::*; + let local_peer_id = "local_peer_id"; let fallible_service_id = String::from("service_id_1"); - let mut vm = create_aqua_vm(fallible_call_service(fallible_service_id), ""); + let mut vm = create_aqua_vm(fallible_call_service(fallible_service_id), local_peer_id); - let script = String::from( + let script = format!( r#" (xor - (call %current_peer_id% ("service_id_1" "local_fn_name") [] result_1) - (call %current_peer_id% ("service_id_2" "local_fn_name") [] result_2) + (call "{0}" ("service_id_1" "local_fn_name") [] result_1) + (call "{0}" ("service_id_2" "local_fn_name") [] result_2) )"#, + local_peer_id, ); let res = call_vm!(vm, "asd", script, "[]", "[]"); @@ -95,12 +97,13 @@ mod tests { assert_eq!(call_path[0], Call(CallServiceFailed(String::from(r#""error""#)))); assert_eq!(call_path[1], executed_call_result); - let script = String::from( + let script = format!( r#" (xor - (call %current_peer_id% ("service_id_2" "local_fn_name") [] result_1) - (call %current_peer_id% ("service_id_1" "local_fn_name") [] result_2) + (call "{0}" ("service_id_2" "local_fn_name") [] result_1) + (call "{0}" ("service_id_1" "local_fn_name") [] result_2) )"#, + local_peer_id ); let res = call_vm!(vm, "asd", script, "[]", "[]"); @@ -116,26 +119,28 @@ mod tests { use crate::call_evidence::EvidenceState::*; let fallible_service_id = String::from("service_id_1"); - let mut vm = create_aqua_vm(fallible_call_service(fallible_service_id.clone()), ""); + let local_peer_id = "local_peer_id"; + let mut vm = create_aqua_vm(fallible_call_service(fallible_service_id.clone()), local_peer_id); - let script = String::from( + let script = format!( r#" (xor (par (seq - (call %current_peer_id% ("service_id_2" "local_fn_name") [] result_1) - (call %current_peer_id% ("service_id_2" "local_fn_name") [] result_2) + (call "{0}" ("service_id_2" "local_fn_name") [] result_1) + (call "{0}" ("service_id_2" "local_fn_name") [] result_2) ) (par - (call %current_peer_id% ("service_id_1" "local_fn_name") [] result_3) - (call %current_peer_id% ("service_id_2" "local_fn_name") [] result_4) + (call "{0}" ("service_id_1" "local_fn_name") [] result_3) + (call "{0}" ("service_id_2" "local_fn_name") [] result_4) ) ) (seq - (call %current_peer_id% ("service_id_2" "local_fn_name") [] result_4) - (call %current_peer_id% ("service_id_2" "local_fn_name") [] result_5) + (call "{0}" ("service_id_2" "local_fn_name") [] result_4) + (call "{0}" ("service_id_2" "local_fn_name") [] result_5) ) )"#, + local_peer_id ); let result = call_vm!(vm, "asd", script.clone(), "[]", "[]"); @@ -144,7 +149,7 @@ mod tests { let res = String::from("res"); let executed_call_result = Rc::new(JValue::String(res)); - let right_path = vec![ + let expected_path = vec![ Par(2, 2), Call(Executed(executed_call_result.clone())), Call(Executed(executed_call_result.clone())), @@ -154,10 +159,10 @@ mod tests { Call(Executed(executed_call_result.clone())), ]; - assert_eq!(result_path, right_path); + assert_eq!(result_path, expected_path); let result = call_vm!(vm, "asd", script, "[]", result.data); let result_path: CallEvidencePath = serde_json::from_slice(&result.data).expect("should be valid json"); - assert_eq!(result_path, right_path); + assert_eq!(result_path, expected_path); } } diff --git a/stepper-lib/src/call_evidence/state.rs b/stepper-lib/src/call_evidence/state.rs index 3afec3e9..1212236d 100644 --- a/stepper-lib/src/call_evidence/state.rs +++ b/stepper-lib/src/call_evidence/state.rs @@ -226,15 +226,15 @@ mod tests { let merged_path = merge_call_paths(prev_path, current_path).expect("merging should be successful"); - let mut right_merged_path = CallEvidencePath::new(); - right_merged_path.push_back(Par(1, 1)); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Par(1, 1)); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + let mut expected_merged_path = CallEvidencePath::new(); + expected_merged_path.push_back(Par(1, 1)); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Par(1, 1)); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - assert_eq!(merged_path, right_merged_path); + assert_eq!(merged_path, expected_merged_path); } #[test] @@ -261,17 +261,17 @@ mod tests { let merged_path = merge_call_paths(prev_path, current_path).expect("merging should be successful"); - let mut right_merged_path = CallEvidencePath::new(); - right_merged_path.push_back(Par(2, 2)); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(RequestSent(String::from("peer_1")))); - right_merged_path.push_back(Par(1, 1)); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + let mut expected_merged_path = CallEvidencePath::new(); + expected_merged_path.push_back(Par(2, 2)); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(RequestSent(String::from("peer_1")))); + expected_merged_path.push_back(Par(1, 1)); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - assert_eq!(merged_path, right_merged_path); + assert_eq!(merged_path, expected_merged_path); } #[test] @@ -304,20 +304,20 @@ mod tests { let merged_path = merge_call_paths(prev_path, current_path).expect("merging should be successful"); - let mut right_merged_path = CallEvidencePath::new(); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Par(3, 3)); - right_merged_path.push_back(Par(1, 1)); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Par(1, 1)); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(RequestSent(String::from("peer_1")))); - right_merged_path.push_back(Par(1, 2)); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); - right_merged_path.push_back(Call(RequestSent(String::from("peer_1")))); + let mut expected_merged_path = CallEvidencePath::new(); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Par(3, 3)); + expected_merged_path.push_back(Par(1, 1)); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Par(1, 1)); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(RequestSent(String::from("peer_1")))); + expected_merged_path.push_back(Par(1, 2)); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(Executed(Rc::new(JValue::Null)))); + expected_merged_path.push_back(Call(RequestSent(String::from("peer_1")))); - assert_eq!(merged_path, right_merged_path); + assert_eq!(merged_path, expected_merged_path); } } diff --git a/stepper-lib/tests/air_basic.rs b/stepper-lib/tests/air_basic.rs index cf938f6d..53cf587e 100644 --- a/stepper-lib/tests/air_basic.rs +++ b/stepper-lib/tests/air_basic.rs @@ -18,7 +18,7 @@ use aqua_test_utils::call_vm; use aqua_test_utils::create_aqua_vm; use aqua_test_utils::set_variables_call_service; use aqua_test_utils::unit_call_service; -use aqua_test_utils::HostExportedFunc; +use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::Vec1; @@ -36,15 +36,16 @@ fn seq_par_call() { let vm_peer_id = String::from("some_peer_id"); let mut vm = create_aqua_vm(unit_call_service(), vm_peer_id.clone()); - let script = String::from( + let script = format!( r#" (seq (par - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_1) + (call "{0}" ("local_service_id" "local_fn_name") [] result_1) (call "remote_peer_id" ("service_id" "fn_name") [] g) ) - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_2) + (call "{0}" ("local_service_id" "local_fn_name") [] result_2) )"#, + vm_peer_id ); let res = call_vm!(vm, "asd", script, "[]", "[]"); @@ -52,14 +53,14 @@ fn seq_par_call() { serde_json::from_slice(&res.data).expect("stepper should return valid json"); let test_string = String::from("test"); - let right_path = vec![ + let expected_path = vec![ Par(1, 1), Call(Executed(Rc::new(JValue::String(test_string.clone())))), Call(RequestSent(vm_peer_id)), Call(Executed(Rc::new(JValue::String(test_string.clone())))), ]; - assert_eq!(resulted_path, right_path); + assert_eq!(resulted_path, expected_path); assert_eq!(res.next_peer_pks, vec![String::from("remote_peer_id")]); } @@ -71,15 +72,16 @@ fn par_par_call() { let vm_peer_id = String::from("some_peer_id"); let mut vm = create_aqua_vm(unit_call_service(), vm_peer_id.clone()); - let script = String::from( + let script = format!( r#" (par (par - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_1) + (call "{0}" ("local_service_id" "local_fn_name") [] result_1) (call "remote_peer_id" ("service_id" "fn_name") [] g) ) - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_2) + (call "{0}" ("local_service_id" "local_fn_name") [] result_2) )"#, + vm_peer_id, ); let res = call_vm!(vm, "asd", script, "[]", "[]"); @@ -87,7 +89,7 @@ fn par_par_call() { serde_json::from_slice(&res.data).expect("stepper should return valid json"); let test_string = String::from("test"); - let right_path = vec![ + let expected_path = vec![ Par(3, 1), Par(1, 1), Call(Executed(Rc::new(JValue::String(test_string.clone())))), @@ -95,7 +97,7 @@ fn par_par_call() { Call(Executed(Rc::new(JValue::String(test_string.clone())))), ]; - assert_eq!(resulted_path, right_path); + assert_eq!(resulted_path, expected_path); assert_eq!(res.next_peer_pks, vec![String::from("remote_peer_id")]); } @@ -133,7 +135,7 @@ fn create_service() { let add_blueprint_response = String::from("add_blueprint response"); let create_response = String::from("create response"); - let call_service: HostExportedFunc = Box::new(move |_, args| -> Option { + let call_service: CallServiceClosure = Box::new(move |_, args| -> Option { let builtin_service = match &args[0] { IValue::String(str) => str, _ => unreachable!(), @@ -162,7 +164,7 @@ fn create_service() { let add_blueprint_response = String::from("add_blueprint response"); let create_response = String::from("create response"); let resulted_path: Vec = serde_json::from_slice(&res.data).expect("should be a correct json"); - let right_path = vec![ + let expected_path = vec![ Call(Executed(Rc::new(module_bytes))), Call(Executed(Rc::new(module_config))), Call(Executed(Rc::new(blueprint))), @@ -172,6 +174,6 @@ fn create_service() { Call(RequestSent(String::from("A"))), ]; - assert_eq!(resulted_path, right_path); + assert_eq!(resulted_path, expected_path); assert_eq!(res.next_peer_pks, vec![String::from("remote_peer_id")]); } diff --git a/stepper-lib/tests/call_evidence_basic.rs b/stepper-lib/tests/call_evidence_basic.rs index 7dbc14f3..a0509b34 100644 --- a/stepper-lib/tests/call_evidence_basic.rs +++ b/stepper-lib/tests/call_evidence_basic.rs @@ -18,7 +18,7 @@ use aqua_test_utils::call_vm; use aqua_test_utils::create_aqua_vm; use aqua_test_utils::echo_number_call_service; use aqua_test_utils::unit_call_service; -use aqua_test_utils::HostExportedFunc; +use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::Vec1; @@ -33,17 +33,19 @@ fn evidence_seq_par_call() { use stepper_lib::CallResult::*; use stepper_lib::EvidenceState::{self, *}; - let mut vm = create_aqua_vm(unit_call_service(), ""); + let local_peer_id = "local_peer_id"; + let mut vm = create_aqua_vm(unit_call_service(), local_peer_id); - let script = String::from( + let script = format!( r#" (seq (par - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_1) + (call "{0}" ("local_service_id" "local_fn_name") [] result_1) (call "remote_peer_id" ("service_id" "fn_name") [] g) ) - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_2) + (call "{0}" ("local_service_id" "local_fn_name") [] result_2) )"#, + local_peer_id ); let initial_state = json!([ @@ -58,14 +60,14 @@ fn evidence_seq_par_call() { serde_json::from_slice(&res.data).expect("stepper should return valid json"); let test_string = String::from("test"); - let right_path = vec![ + let expected_path = vec![ Par(1, 1), Call(Executed(Rc::new(JValue::String(test_string.clone())))), Call(Executed(Rc::new(JValue::String(test_string.clone())))), Call(Executed(Rc::new(JValue::String(test_string)))), ]; - assert_eq!(resulted_path, right_path); + assert_eq!(resulted_path, expected_path); assert!(res.next_peer_pks.is_empty()); } @@ -74,17 +76,19 @@ fn evidence_par_par_call() { use stepper_lib::CallResult::*; use stepper_lib::EvidenceState::{self, *}; - let mut vm = create_aqua_vm(unit_call_service(), "some_peer_id"); + let local_peer_id = "local_peer_id"; + let mut vm = create_aqua_vm(unit_call_service(), local_peer_id); - let script = String::from( + let script = format!( r#" (par (par - (call "some_peer_id" ("local_service_id" "local_fn_name") [] result_1) + (call "local_peer_id" ("local_service_id" "local_fn_name") [] result_1) (call "remote_peer_id" ("service_id" "fn_name") [] g) ) - (call %current_peer_id% ("local_service_id" "local_fn_name") [] result_2) + (call "{}" ("local_service_id" "local_fn_name") [] result_2) )"#, + local_peer_id, ); let initial_state = json!([ @@ -100,15 +104,15 @@ fn evidence_par_par_call() { serde_json::from_slice(&res.data).expect("stepper should return valid json"); let test_string = String::from("test"); - let right_path = vec![ + let expected_path = vec![ Par(3, 1), Par(1, 1), Call(Executed(Rc::new(JValue::String(test_string.clone())))), - Call(RequestSent(String::from("some_peer_id"))), + Call(RequestSent(local_peer_id.to_string())), Call(Executed(Rc::new(JValue::String(test_string)))), ]; - assert_eq!(resulted_path, right_path); + assert_eq!(resulted_path, expected_path); assert_eq!(res.next_peer_pks, vec![String::from("remote_peer_id")]); } @@ -147,13 +151,13 @@ fn evidence_seq_seq() { serde_json::from_slice(&res.data).expect("stepper should return valid json"); let test_string = String::from("test"); - let right_path = vec![ + let expected_path = vec![ Call(Executed(Rc::new(JValue::String(test_string.clone())))), Call(Executed(Rc::new(JValue::String(test_string.clone())))), Call(Executed(Rc::new(JValue::String(test_string)))), ]; - assert_eq!(resulted_path, right_path); + assert_eq!(resulted_path, expected_path); } #[test] @@ -182,7 +186,7 @@ fn evidence_create_service() { let add_blueprint_response = String::from("add_blueprint response"); let create_response = String::from("create response"); - let call_service: HostExportedFunc = Box::new(move |_, args| -> Option { + let call_service: CallServiceClosure = Box::new(move |_, args| -> Option { let builtin_service = match &args[0] { IValue::String(str) => str, _ => unreachable!(), @@ -227,7 +231,7 @@ fn evidence_create_service() { #[test] fn evidence_par_seq_fold_call() { - let return_numbers_call_service: HostExportedFunc = Box::new(|_, _| -> Option { + let return_numbers_call_service: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![ IValue::S32(0), @@ -271,7 +275,7 @@ fn evidence_par_seq_fold_call() { let res = call_vm!(vm3, "asd", script, "[]", data); let resulted_path: JValue = serde_json::from_slice(&res.data).expect("a valid json"); - let right_json = json!( [ + let expected_json = json!( [ { "par": [21,1] }, { "call": { "executed": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] } }, { "par": [1,18] }, @@ -297,13 +301,13 @@ fn evidence_par_seq_fold_call() { { "call": { "executed": "test" } }, ]); - assert_eq!(resulted_path, right_json); + assert_eq!(resulted_path, expected_json); assert!(res.next_peer_pks.is_empty()); } #[test] fn evidence_par_seq_fold_in_cycle_call() { - let return_numbers_call_service: HostExportedFunc = Box::new(|_, _| -> Option { + let return_numbers_call_service: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![ IValue::S32(0), @@ -346,7 +350,7 @@ fn evidence_par_seq_fold_in_cycle_call() { let resulted_json: JValue = serde_json::from_slice(&data).expect("stepper should return valid json"); - let right_json = json!( [ + let expected_json = json!( [ { "par": [21,1] }, { "call": { "executed": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] } }, { "par": [1,18] }, @@ -372,7 +376,7 @@ fn evidence_par_seq_fold_in_cycle_call() { { "call": { "executed": "test" } }, ]); - assert_eq!(resulted_json, right_json); + assert_eq!(resulted_json, expected_json); } #[test] @@ -410,7 +414,7 @@ fn evidence_seq_par_seq_seq() { let resulted_json: JValue = serde_json::from_slice(&res.data).expect("stepper should return valid json"); - let right_json = json!( [ + let expected_json = json!( [ { "par": [2,2] }, { "call": {"executed" : "test" } }, { "call": {"executed" : "test" } }, @@ -419,6 +423,6 @@ fn evidence_seq_par_seq_seq() { { "call": {"executed" : "test" } }, ]); - assert_eq!(resulted_json, right_json); + assert_eq!(resulted_json, expected_json); assert!(res.next_peer_pks.is_empty()); } diff --git a/stepper-lib/tests/dashboard.rs b/stepper-lib/tests/dashboard.rs index a0402e15..e5636152 100644 --- a/stepper-lib/tests/dashboard.rs +++ b/stepper-lib/tests/dashboard.rs @@ -18,7 +18,7 @@ use aqua_test_utils::call_vm; use aqua_test_utils::create_aqua_vm; use aqua_test_utils::IValue; use aqua_test_utils::Vec1; -use aqua_test_utils::{AquamarineVM, HostExportedFunc}; +use aqua_test_utils::{AquamarineVM, CallServiceClosure}; use std::cell::RefCell; use std::collections::HashSet; @@ -54,7 +54,7 @@ fn client_host_function( known_peers: Vec, client_id: String, relay_id: String, -) -> (HostExportedFunc, Rc>) { +) -> (CallServiceClosure, Rc>) { let all_info = Rc::new(RefCell::new(String::new())); let known_peers = JValue::Array(known_peers.iter().cloned().map(JValue::String).collect::>()); let client_id = JValue::String(client_id); @@ -72,7 +72,7 @@ fn client_host_function( ); let all_info_inner = all_info.clone(); - let host_function: HostExportedFunc = Box::new(move |_, args| -> Option { + let host_function: CallServiceClosure = Box::new(move |_, args| -> Option { let service_name = match &args[0] { IValue::String(str) => str, _ => unreachable!(), @@ -110,7 +110,7 @@ fn peer_host_function( modules: Vec, interfaces: Vec, ident: String, -) -> HostExportedFunc { +) -> CallServiceClosure { let known_peers = JValue::Array(known_peers.into_iter().map(JValue::String).collect()); let blueprints = JValue::Array(blueprints.into_iter().map(JValue::String).collect()); let modules = JValue::Array(modules.into_iter().map(JValue::String).collect()); @@ -159,7 +159,7 @@ fn peer_host_function( } #[rustfmt::skip] -fn create_peer_host_function(peer_id: String, known_peer_ids: Vec) -> HostExportedFunc { +fn create_peer_host_function(peer_id: String, known_peer_ids: Vec) -> CallServiceClosure { let relay_blueprints = (0..=2).map(|id| format!("{}_blueprint_{}", peer_id, id)).collect::>(); let relay_modules = (0..=2).map(|id| format!("{}_module_{}", peer_id, id)).collect::>(); let relay_interfaces = (0..=2).map(|id| format!("{}_interface_{}", peer_id, id)).collect::>(); diff --git a/stepper-lib/tests/data_merge.rs b/stepper-lib/tests/data_merge.rs index 027b484e..17a3c035 100644 --- a/stepper-lib/tests/data_merge.rs +++ b/stepper-lib/tests/data_merge.rs @@ -17,7 +17,7 @@ use aqua_test_utils::call_vm; use aqua_test_utils::create_aqua_vm; use aqua_test_utils::set_variable_call_service; -use aqua_test_utils::HostExportedFunc; +use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::Vec1; @@ -28,13 +28,13 @@ type JValue = serde_json::Value; #[test] fn data_merge() { - let neighborhood_call_service1: HostExportedFunc = Box::new(|_, _| -> Option { + let neighborhood_call_service1: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![IValue::S32(0), IValue::String(String::from("[\"A\", \"B\"]"))]).unwrap(), )) }); - let neighborhood_call_service2: HostExportedFunc = Box::new(|_, _| -> Option { + let neighborhood_call_service2: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![IValue::S32(0), IValue::String(String::from("[\"A\", \"B\"]"))]).unwrap(), )) @@ -45,12 +45,12 @@ fn data_merge() { let script = String::from( r#" - (seq - (call %current_peer_id% ("neighborhood" "") [] neighborhood) - (seq - (seq + (seq + (call %init_peer_id% ("neighborhood" "") [] neighborhood) + (seq + (seq (fold neighborhood i - (par + (par (call i ("add_provider" "") [] void[]) (next i) ) @@ -71,14 +71,15 @@ fn data_merge() { "#, ); - let res1 = call_vm!(vm1, "asd", script.clone(), "[]", "[]"); - let res2 = call_vm!(vm2, "asd", script.clone(), "[]", "[]"); + // little hack here with init_peer_id to execute the first call from both VMs + let res1 = call_vm!(vm1, "A", script.clone(), "[]", "[]"); + let res2 = call_vm!(vm2, "B", script.clone(), "[]", "[]"); let res3 = call_vm!(vm1, "asd", script.clone(), res1.data.clone(), res2.data.clone()); let res4 = call_vm!(vm2, "asd", script, res1.data.clone(), res2.data.clone()); let resulted_json1: JValue = serde_json::from_slice(&res1.data).expect("stepper should return valid json"); - let right_json1 = json!( [ + let expected_json1 = json!( [ { "call": { "executed": ["A", "B"] } }, { "par": [1,2] }, { "call": { "executed": ["A", "B"] } }, @@ -92,12 +93,12 @@ fn data_merge() { { "call": { "request_sent": "A" } }, ]); - assert_eq!(resulted_json1, right_json1); + assert_eq!(resulted_json1, expected_json1); assert_eq!(res1.next_peer_pks, vec![String::from("B")]); let resulted_json2: JValue = serde_json::from_slice(&res2.data).expect("stepper should return valid json"); - let right_json2 = json!( [ + let expected_json2 = json!( [ { "call": { "executed": ["A", "B"] } }, { "par": [1,2] }, { "call": { "request_sent": "B" } }, @@ -110,12 +111,12 @@ fn data_merge() { { "call": { "request_sent": "B" } }, ]); - assert_eq!(resulted_json2, right_json2); + assert_eq!(resulted_json2, expected_json2); assert_eq!(res2.next_peer_pks, vec![String::from("A")]); let resulted_json3: JValue = serde_json::from_slice(&res3.data).expect("stepper should return valid json"); - let right_json3 = json!( [ + let expected_json3 = json!( [ { "call": { "executed": ["A", "B"] } }, { "par": [1,2] }, { "call": { "executed": ["A", "B"] } }, @@ -129,12 +130,12 @@ fn data_merge() { { "call": { "request_sent": "A" } }, ]); - assert_eq!(resulted_json3, right_json3); + assert_eq!(resulted_json3, expected_json3); assert!(res3.next_peer_pks.is_empty()); let resulted_json4: JValue = serde_json::from_slice(&res4.data).expect("stepper should return valid json"); - let right_json4 = json!( [ + let expected_json4 = json!( [ { "call": { "executed": ["A", "B"] } }, { "par": [1,2] }, { "call": { "executed": ["A", "B"] } }, @@ -148,7 +149,7 @@ fn data_merge() { { "call": { "executed": ["A", "B"] } }, ]); - assert_eq!(resulted_json4, right_json4); + assert_eq!(resulted_json4, expected_json4); assert!(res4.next_peer_pks.is_empty()); } @@ -156,7 +157,7 @@ fn data_merge() { fn acc_merge() { env_logger::init(); - let neighborhood_call_service: HostExportedFunc = Box::new(|_, args| -> Option { + let neighborhood_call_service: CallServiceClosure = Box::new(|_, args| -> Option { let args_count = match &args[1] { IValue::String(str) => str, _ => unreachable!(), diff --git a/stepper-lib/tests/join.rs b/stepper-lib/tests/join.rs index d86a7e5f..daf5f88c 100644 --- a/stepper-lib/tests/join.rs +++ b/stepper-lib/tests/join.rs @@ -17,7 +17,7 @@ use aqua_test_utils::call_vm; use aqua_test_utils::create_aqua_vm; use aqua_test_utils::unit_call_service; -use aqua_test_utils::HostExportedFunc; +use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::Vec1; @@ -30,7 +30,7 @@ type JValue = serde_json::Value; fn join_chat() { use std::collections::HashSet; - let members_call_service1: HostExportedFunc = Box::new(|_, _| -> Option { + let members_call_service1: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![ IValue::S32(0), @@ -74,30 +74,30 @@ fn join_chat() { let client_1_res_json: JValue = serde_json::from_slice(&client_1_res.data).expect("stepper should return valid json"); - let client_1_right_json = json!([ + let client_1_expected_json = json!([ { "call": {"request_sent": "A" } }, ]); - assert_eq!(client_1_res_json, client_1_right_json); + assert_eq!(client_1_res_json, client_1_expected_json); assert_eq!(client_1_res.next_peer_pks, vec![String::from("Relay1")]); let relay_1_res = call_vm!(relay_1, "asd", script.clone(), client_1_res.data, "[]"); let relay_1_res_json: JValue = serde_json::from_slice(&relay_1_res.data).expect("stepper should return valid json"); - let relay_1_right_json = json!( [ + let relay_1_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "request_sent": "Relay1" } }, ]); - assert_eq!(relay_1_res_json, relay_1_right_json); + assert_eq!(relay_1_res_json, relay_1_expected_json); assert_eq!(relay_1_res.next_peer_pks, vec![String::from("Remote")]); let remote_res = call_vm!(remote, "asd", script.clone(), relay_1_res.data, "[]"); let remote_res_json: JValue = serde_json::from_slice(&remote_res.data).expect("stepper should return valid json"); - let remote_right_json = json!( [ + let remote_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, @@ -113,14 +113,14 @@ fn join_chat() { "Relay2", }; - assert_eq!(remote_res_json, remote_right_json); + assert_eq!(remote_res_json, remote_expected_json); assert_eq!(remote_res_next_peer_pks, next_peer_pks_right); let relay_1_res = call_vm!(relay_1, "asd", script.clone(), remote_res.data.clone(), "[]"); let relay_1_res_json: JValue = serde_json::from_slice(&relay_1_res.data).expect("stepper should return valid json"); - let relay_1_right_json = json!( [ + let relay_1_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, @@ -131,7 +131,7 @@ fn join_chat() { { "call": { "request_sent" : "Remote" } }, ]); - assert_eq!(relay_1_res_json, relay_1_right_json); + assert_eq!(relay_1_res_json, relay_1_expected_json); assert_eq!(relay_1_res.next_peer_pks, vec![String::from("A")]); let client_1_res = call_vm!(client_1, "asd", script.clone(), relay_1_res.data, "[]"); @@ -139,7 +139,7 @@ fn join_chat() { let client_1_res_json: JValue = serde_json::from_slice(&client_1_res.data).expect("stepper should return valid json"); - let client_1_right_json = json!( [ + let client_1_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, @@ -150,14 +150,14 @@ fn join_chat() { { "call": { "request_sent" : "Remote" } }, ]); - assert_eq!(client_1_res_json, client_1_right_json); + assert_eq!(client_1_res_json, client_1_expected_json); assert_eq!(client_1_res.next_peer_pks, Vec::::new()); let relay_2_res = call_vm!(relay_2, "asd", script.clone(), remote_res.data, "[]"); let relay_2_res_json: JValue = serde_json::from_slice(&relay_2_res.data).expect("stepper should return valid json"); - let relay_2_right_json = json!( [ + let relay_2_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, @@ -168,7 +168,7 @@ fn join_chat() { { "call": { "request_sent" : "Relay2" } }, ]); - assert_eq!(relay_2_res_json, relay_2_right_json); + assert_eq!(relay_2_res_json, relay_2_expected_json); assert_eq!(relay_2_res.next_peer_pks, vec![String::from("B")]); let client_2_res = call_vm!(client_2, "asd", script, relay_2_res.data, "[]"); @@ -176,7 +176,7 @@ fn join_chat() { let client_2_res_json: JValue = serde_json::from_slice(&client_2_res.data).expect("stepper should return valid json"); - let client_2_right_json = json!( [ + let client_2_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, { "call": { "executed" : [["A", "Relay1"], ["B", "Relay2"]]} }, @@ -187,13 +187,13 @@ fn join_chat() { { "call": { "executed" : "test" } }, ]); - assert_eq!(client_2_res_json, client_2_right_json); + assert_eq!(client_2_res_json, client_2_expected_json); assert_eq!(client_2_res.next_peer_pks, Vec::::new()); } #[test] fn join() { - let members_call_service1: HostExportedFunc = Box::new(|_, _| -> Option { + let members_call_service1: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![IValue::S32(0), IValue::String(String::from(r#"[["A"], ["B"]]"#))]).unwrap(), )) @@ -232,7 +232,7 @@ fn join() { let client_1_res_json: JValue = serde_json::from_slice(&client_1_res.data).expect("stepper should return valid json"); - let client_1_right_json = json!( [ + let client_1_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "executed" : [["A"], ["B"]]} }, { "par": [2, 3] }, @@ -243,13 +243,13 @@ fn join() { { "call": { "executed" : "test" } }, ]); - assert_eq!(client_1_res_json, client_1_right_json); + assert_eq!(client_1_res_json, client_1_expected_json); assert_eq!(client_1_res.next_peer_pks, Vec::::new()); } #[test] fn init_peer_id() { - let members_call_service1: HostExportedFunc = Box::new(|_, _| -> Option { + let members_call_service1: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![IValue::S32(0), IValue::String(String::from(r#"[["A"], ["B"]]"#))]).unwrap(), )) @@ -312,7 +312,7 @@ fn init_peer_id() { let client_1_res_json: JValue = serde_json::from_slice(&client_1_res.data).expect("stepper should return valid json"); - let client_1_right_json = json!( [ + let client_1_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "executed" : [["A"], ["B"]]} }, { "par": [2, 3] }, @@ -324,7 +324,7 @@ fn init_peer_id() { { "call": { "request_sent" : "A" } }, ]); - assert_eq!(client_1_res_json, client_1_right_json); + assert_eq!(client_1_res_json, client_1_expected_json); assert_eq!(client_1_res.next_peer_pks, vec![initiator_peer_id.clone()]); let initiator_1_res = call_vm!(initiator, initiator_peer_id, script, client_1_res.data, ""); @@ -332,7 +332,7 @@ fn init_peer_id() { let initiator_1_res_json: JValue = serde_json::from_slice(&initiator_1_res.data).expect("stepper should return valid json"); - let initiator_1_right_json = json!( [ + let initiator_1_expected_json = json!( [ { "call": { "executed" : "test" } }, { "call": { "executed" : [["A"], ["B"]]} }, { "par": [2, 3] }, @@ -344,6 +344,6 @@ fn init_peer_id() { { "call": { "executed" : "test" } }, ]); - assert_eq!(initiator_1_res_json, initiator_1_right_json); + assert_eq!(initiator_1_res_json, initiator_1_expected_json); assert_eq!(initiator_1_res.next_peer_pks, Vec::::new()); } diff --git a/stepper-lib/tests/security_tetraplets.rs b/stepper-lib/tests/security_tetraplets.rs index 1c9512ef..fde479d1 100644 --- a/stepper-lib/tests/security_tetraplets.rs +++ b/stepper-lib/tests/security_tetraplets.rs @@ -16,7 +16,7 @@ use aqua_test_utils::call_vm; use aqua_test_utils::create_aqua_vm; -use aqua_test_utils::HostExportedFunc; +use aqua_test_utils::CallServiceClosure; use aqua_test_utils::IValue; use aqua_test_utils::Vec1; use polyplets::ResolvedTriplet; @@ -27,11 +27,11 @@ use std::rc::Rc; type ArgTetraplets = Vec>; -fn arg_host_function() -> (HostExportedFunc, Rc>) { +fn arg_host_function() -> (CallServiceClosure, Rc>) { let arg_tetraplets = Rc::new(RefCell::new(ArgTetraplets::new())); let arg_tetraplets_inner = arg_tetraplets.clone(); - let host_function: HostExportedFunc = Box::new(move |_, args| -> Option { + let host_function: CallServiceClosure = Box::new(move |_, args| -> Option { let tetraplets = match &args[3] { IValue::String(str) => str, _ => unreachable!(), @@ -51,7 +51,7 @@ fn arg_host_function() -> (HostExportedFunc, Rc>) { #[test] fn simple_fold() { - let return_numbers_call_service: HostExportedFunc = Box::new(|_, _| -> Option { + let return_numbers_call_service: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![ IValue::S32(0), @@ -116,19 +116,19 @@ fn simple_fold() { json_path: String::new(), }; - let right_tetraplets = vec![vec![first_arg_tetraplet], vec![second_arg_tetraplet]]; - let right_tetraplets = Rc::new(RefCell::new(right_tetraplets)); + 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 res = call_vm!(client_vms[i].0, init_peer_id.clone(), script.clone(), "[]", data); data = res.data; - assert_eq!(client_vms[i].1, right_tetraplets); + assert_eq!(client_vms[i].1, expected_tetraplets); } } #[test] fn fold_json_path() { - let return_numbers_call_service: HostExportedFunc = Box::new(|_, _| -> Option { + let return_numbers_call_service: CallServiceClosure = Box::new(|_, _| -> Option { Some(IValue::Record( Vec1::new(vec![ IValue::S32(0), @@ -189,10 +189,10 @@ fn fold_json_path() { json_path: String::new(), }; - let right_tetraplets = vec![vec![first_arg_tetraplet], vec![second_arg_tetraplet]]; - let right_tetraplets = Rc::new(RefCell::new(right_tetraplets)); + let expected_tetraplets = vec![vec![first_arg_tetraplet], vec![second_arg_tetraplet]]; + let expected_tetraplets = Rc::new(RefCell::new(expected_tetraplets)); call_vm!(client_vm, init_peer_id.clone(), script.clone(), "[]", res.data); - assert_eq!(arg_tetraplets, right_tetraplets); + assert_eq!(arg_tetraplets, expected_tetraplets); } use fluence_app_service::AppService; @@ -243,7 +243,7 @@ fn tetraplet_with_wasm_modules() { let services_inner = services.clone(); const ADMIN_PEER_PK: &str = "12D3KooWEXNUbCXooUwHrHBbrmjsrpHXoEphPwbjQXEGyzbqKnE1"; - let host_func: HostExportedFunc = Box::new(move |_, args: Vec| -> Option { + let host_func: CallServiceClosure = Box::new(move |_, args: Vec| -> Option { let service_id = match &args[0] { IValue::String(str) => str, _ => unreachable!(), @@ -281,22 +281,24 @@ fn tetraplet_with_wasm_modules() { )) }); - let script = String::from( + let local_peer_id = "local_peer_id"; + let script = format!( r#" (seq - (call %current_peer_id% ("auth" "is_authorized") [] auth_result) - (call %current_peer_id% ("log_storage" "delete") [auth_result.$.is_authorized "1"]) + (call "{0}" ("auth" "is_authorized") [] auth_result) + (call "{0}" ("log_storage" "delete") [auth_result.$.is_authorized "1"]) ) "#, + local_peer_id, ); - let mut vm = create_aqua_vm(host_func, "some peer_id"); + let mut vm = create_aqua_vm(host_func, local_peer_id); let result = call_vm!(vm, ADMIN_PEER_PK, script, "", ""); let path: CallEvidencePath = serde_json::from_slice(&result.data).unwrap(); - let right_res = EvidenceState::Call(CallResult::Executed(Rc::new(serde_json::Value::String(String::from( + let expected_res = EvidenceState::Call(CallResult::Executed(Rc::new(serde_json::Value::String(String::from( "Ok", ))))); - assert_eq!(path[1], right_res) + assert_eq!(path[1], expected_res) }