1
0
mirror of https://github.com/fluencelabs/marine.git synced 2025-03-15 14:00:50 +00:00

Return JValue from call_json ()

This commit is contained in:
vms 2020-11-05 15:18:48 +03:00 committed by GitHub
parent c8114d48c6
commit d09c5b5d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 925 additions and 1335 deletions

116
Cargo.lock generated

@ -17,9 +17,9 @@ checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
[[package]]
name = "aho-corasick"
version = "0.7.14"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d"
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
dependencies = [
"memchr",
]
@ -35,9 +35,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.33"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c"
checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7"
[[package]]
name = "aquamarine-vm"
@ -132,9 +132,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "blake2b_simd"
version = "0.5.10"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a"
checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"
dependencies = [
"arrayref",
"arrayvec",
@ -250,9 +250,9 @@ checksum = "475bd7aa7680b4ed8f6bb59745e882bcbaeb39326532bb79ffb1716480d9a274"
[[package]]
name = "const_fn"
version = "0.4.2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce90df4c658c62f12d78f7508cf92f9173e5184a539c10bfe54a3107b3ffd0f2"
checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
[[package]]
name = "constant_time_eq"
@ -552,11 +552,11 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "encoding_rs"
version = "0.8.24"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2"
checksum = "801bbab217d7f79c0062f4f7205b5d4427c6d1a7bd7aafdd1475f7c59d62b283"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 1.0.0",
]
[[package]]
@ -648,7 +648,7 @@ dependencies = [
[[package]]
name = "fce"
version = "0.1.9"
version = "0.1.10"
dependencies = [
"boolinator",
"bytes",
@ -681,7 +681,7 @@ dependencies = [
[[package]]
name = "fce-wit-generator"
version = "0.1.9"
version = "0.1.10"
dependencies = [
"fce-wit-parser",
"fluence-sdk-wit 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -694,7 +694,7 @@ dependencies = [
[[package]]
name = "fce-wit-interfaces"
version = "0.1.6"
version = "0.1.7"
dependencies = [
"multimap",
"wasmer-interface-types-fl",
@ -702,7 +702,7 @@ dependencies = [
[[package]]
name = "fce-wit-parser"
version = "0.1.8"
version = "0.1.9"
dependencies = [
"anyhow",
"fce-wit-interfaces",
@ -713,7 +713,7 @@ dependencies = [
[[package]]
name = "fcli"
version = "0.1.10"
version = "0.1.11"
dependencies = [
"anyhow",
"clap",
@ -724,15 +724,6 @@ dependencies = [
"serde_json",
]
[[package]]
name = "fluence"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#a6c587db0b6f22c3d3af81f10b187f148f8e9d30"
dependencies = [
"fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-main 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
name = "fluence"
version = "0.2.8"
@ -743,9 +734,18 @@ dependencies = [
"fluence-sdk-main 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fluence"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#a6c587db0b6f22c3d3af81f10b187f148f8e9d30"
dependencies = [
"fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-main 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
name = "fluence-app-service"
version = "0.1.10"
version = "0.1.11"
dependencies = [
"fluence-faas",
"log",
@ -759,7 +759,7 @@ dependencies = [
[[package]]
name = "fluence-faas"
version = "0.1.10"
version = "0.1.11"
dependencies = [
"cmd_lib",
"env_logger 0.7.1",
@ -780,14 +780,6 @@ dependencies = [
"wasmer-wasi-fl",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#a6c587db0b6f22c3d3af81f10b187f148f8e9d30"
dependencies = [
"fluence-sdk-wit 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.2.8"
@ -798,13 +790,11 @@ dependencies = [
]
[[package]]
name = "fluence-sdk-main"
name = "fluence-sdk-macro"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#a6c587db0b6f22c3d3af81f10b187f148f8e9d30"
dependencies = [
"fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
"log",
"serde",
"fluence-sdk-wit 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
@ -819,9 +809,20 @@ dependencies = [
]
[[package]]
name = "fluence-sdk-wit"
name = "fluence-sdk-main"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#a6c587db0b6f22c3d3af81f10b187f148f8e9d30"
dependencies = [
"fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
"log",
"serde",
]
[[package]]
name = "fluence-sdk-wit"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "560baf91197ded38a99a5c94ff366a3dd971ebf33f5d987ecce31d3dedf86d17"
dependencies = [
"proc-macro2",
"quote",
@ -834,8 +835,7 @@ dependencies = [
[[package]]
name = "fluence-sdk-wit"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "560baf91197ded38a99a5c94ff366a3dd971ebf33f5d987ecce31d3dedf86d17"
source = "git+https://github.com/fluencelabs/rust-sdk#a6c587db0b6f22c3d3af81f10b187f148f8e9d30"
dependencies = [
"proc-macro2",
"quote",
@ -868,7 +868,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "frepl"
version = "0.1.13"
version = "0.1.14"
dependencies = [
"anyhow",
"clap",
@ -1114,9 +1114,9 @@ dependencies = [
[[package]]
name = "hyper"
version = "0.13.8"
version = "0.13.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835"
checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf"
dependencies = [
"bytes",
"futures-channel",
@ -1128,7 +1128,7 @@ dependencies = [
"httparse",
"httpdate",
"itoa",
"pin-project 0.4.27",
"pin-project 1.0.1",
"socket2",
"tokio",
"tower-service",
@ -1711,9 +1711,9 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
name = "ppv-lite86"
version = "0.2.9"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20"
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]]
name = "pretty_assertions"
@ -1874,9 +1874,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.4.1"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b"
checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
dependencies = [
"aho-corasick",
"memchr",
@ -1886,9 +1886,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.20"
version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c"
checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
[[package]]
name = "remove_dir_all"
@ -2294,18 +2294,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.21"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42"
checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.21"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab"
checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56"
dependencies = [
"proc-macro2",
"quote",
@ -2791,9 +2791,9 @@ dependencies = [
[[package]]
name = "wasmer-interface-types-fl"
version = "0.17.10"
version = "0.17.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1de496e366bd1c198942248fc1de4b94e4647b263dd60099d5f7776f0d621656"
checksum = "e916b92f2d315ea27d5ff1d3d6410fe852c51d21bb91a8d1ba7adbf701de7f53"
dependencies = [
"log",
"nom",

@ -11,7 +11,7 @@ name = "aquamarine_vm"
path = "src/lib.rs"
[dependencies]
fluence-faas = { path = "../fluence-faas", version = "0.1.10" }
fluence-faas = { path = "../fluence-faas", version = "0.1.11" }
maplit = "1.0.2"
serde_json = "1.0.57"

@ -1,7 +1,7 @@
[package]
name = "fce-wit-generator"
description = "Fluence FCE interface type helper crate"
version = "0.1.9"
version = "0.1.10"
authors = ["Fluence Labs"]
license = "Apache-2.0"
edition = "2018"
@ -11,11 +11,11 @@ name = "fce_wit_generator"
path = "src/lib.rs"
[dependencies]
fce-wit-parser = { path = "../wit-parser", version = "0.1.8"}
fce-wit-parser = { path = "../wit-parser", version = "0.1.9"}
fluence-sdk-wit = "0.2.8"
walrus = "0.17.0"
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.10" }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.12" }
once_cell = "1.4.0"
serde = { version = "1.0.110", features = ["derive"] }
serde_json = "1.0.56"

@ -19,6 +19,8 @@ use wasmer_wit::types::InterfaceType as IType;
use wasmer_wit::ast::FunctionArg as IFunctionArg;
use once_cell::sync::Lazy;
use std::rc::Rc;
pub(crate) struct ApiExportFuncDescriptor {
pub(crate) name: &'static str,
pub(crate) id: u32,
@ -29,8 +31,8 @@ pub(crate) struct ApiExportFuncDescriptor {
impl ApiExportFuncDescriptor {
pub fn update_interfaces(&self, interfaces: &mut Interfaces<'_>) {
let func_type = wasmer_wit::ast::Type::Function {
arguments: self.arguments.clone(),
output_types: self.output_types.clone(),
arguments: Rc::new(self.arguments.clone()),
output_types: Rc::new(self.output_types.clone()),
};
interfaces.types.push(func_type);

@ -25,6 +25,8 @@ use wasmer_wit::types::InterfaceType as IType;
use wasmer_wit::ast::Interfaces;
use wasmer_wit::types::RecordType;
use std::rc::Rc;
#[derive(PartialEq, Debug, Default)]
pub(crate) struct WITResolver<'a> {
types: std::collections::HashMap<String, usize>,
@ -54,7 +56,7 @@ impl<'a> WITResolver<'a> {
.insert(record_name.to_string(), self.interfaces.types.len());
self.interfaces
.types
.push(Type::Record(RecordType::default()));
.push(Type::Record(Rc::new(RecordType::default())));
self.not_resolved_types_count += 1;
self.interfaces.types.len()
@ -86,14 +88,14 @@ impl<'a> WITResolver<'a> {
match self.types.get(&record.name) {
Some(pos) => {
self.interfaces.types[*pos] = Type::Record(record);
self.interfaces.types[*pos] = Type::Record(Rc::new(record));
self.not_resolved_types_count -= 1;
}
None => {
self.types
.insert(record.name.clone(), self.interfaces.types.len());
self.interfaces.types.push(Type::Record(record));
self.interfaces.types.push(Type::Record(Rc::new(record)));
}
}
}

@ -25,6 +25,8 @@ use fluence_sdk_wit::ParsedType;
use wasmer_wit::interpreter::Instruction;
use wasmer_wit::ast::FunctionArg as IFunctionArg;
use std::rc::Rc;
impl WITGenerator for AstFunctionItem {
fn generate_wit<'a>(&'a self, wit_resolver: &mut WITResolver<'a>) -> Result<()> {
use wasmer_wit::ast::Type;
@ -42,10 +44,13 @@ impl WITGenerator for AstFunctionItem {
})
.collect::<Result<Vec<_>>>()?;
let arguments = Rc::new(arguments);
let output_types = match self.signature.output_type {
Some(ref output_type) => vec![ptype_to_itype_checked(output_type, wit_resolver)?],
None => vec![],
};
let output_types = Rc::new(output_types);
let interfaces = &mut wit_resolver.interfaces;
interfaces.types.push(Type::Function {

@ -27,6 +27,8 @@ use wasmer_wit::ast::FunctionArg as IFunctionArg;
use wasmer_wit::interpreter::Instruction;
use crate::instructions_generator::utils::wtype_to_itype;
use std::rc::Rc;
const HOST_NAMESPACE_NAME: &str = "host";
impl WITGenerator for AstExternModItem {
@ -63,11 +65,13 @@ fn generate_wit_for_import<'a>(
})
})
.collect::<Result<Vec<_>>>()?;
let arguments = Rc::new(arguments);
let output_types = match import.signature.output_type {
Some(ref output_type) => vec![ptype_to_itype_checked(output_type, wit_resolver)?],
None => vec![],
};
let output_types = Rc::new(output_types);
let interfaces = &mut wit_resolver.interfaces;
interfaces.types.push(Type::Function {
@ -82,6 +86,7 @@ fn generate_wit_for_import<'a>(
.map(to_raw_input_types)
.flatten()
.collect::<Vec<_>>();
let raw_inputs = Rc::new(raw_inputs);
let raw_outputs = match import.signature.output_type {
Some(ref output_type) => to_raw_output_type(output_type)
@ -90,6 +95,7 @@ fn generate_wit_for_import<'a>(
.collect(),
None => vec![],
};
let raw_outputs = Rc::new(raw_outputs);
interfaces.types.push(Type::Function {
arguments: raw_inputs.clone(),

@ -1,7 +1,7 @@
[package]
name = "fce-wit-interfaces"
description = "Fluence FCE interface type helper crate"
version = "0.1.6"
version = "0.1.7"
authors = ["Fluence Labs"]
license = "Apache-2.0"
edition = "2018"
@ -11,5 +11,5 @@ name = "fce_wit_interfaces"
path = "src/lib.rs"
[dependencies]
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.10" }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.12" }
multimap = "0.8.1"

@ -23,6 +23,7 @@ use multimap::MultiMap;
use std::iter::Iterator;
use std::collections::HashMap;
use std::rc::Rc;
pub type CoreFunctionType = u32;
pub type AdapterFunctionType = u32;
@ -109,7 +110,7 @@ impl<'a> FCEWITInterfaces<'a> {
self.types.iter()
}
pub fn record_types(&self) -> impl Iterator<Item = (u64, &RecordType)> {
pub fn record_types(&self) -> impl Iterator<Item = (u64, &Rc<RecordType>)> {
self.types.iter().enumerate().filter_map(|(id, t)| match t {
WITAstType::Record(r) => Some((id as u64, r)),
_ => None,

@ -1,7 +1,7 @@
[package]
name = "fce-wit-parser"
description = "Fluence FCE interface type helper crate"
version = "0.1.8"
version = "0.1.9"
authors = ["Fluence Labs"]
license = "Apache-2.0"
edition = "2018"
@ -11,9 +11,9 @@ name = "fce_wit_parser"
path = "src/lib.rs"
[dependencies]
fce-wit-interfaces = { path = "../wit-interfaces", version = "0.1.6" }
fce-wit-interfaces = { path = "../wit-interfaces", version = "0.1.7" }
anyhow = "1.0.31"
walrus = "0.17.0"
wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0"}
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.10" }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.12" }

@ -1,7 +1,7 @@
[package]
name = "fce"
description = "Fluence Compute Engine"
version = "0.1.9"
version = "0.1.10"
authors = ["Fluence Labs"]
license = "Apache-2.0"
edition = "2018"
@ -11,13 +11,13 @@ name = "fce"
path = "src/lib.rs"
[dependencies]
fce-wit-interfaces = { path = "../crates/wit-interfaces", version = "0.1.6" }
fce-wit-parser = { path = "../crates/wit-parser", version = "0.1.8" }
fce-wit-interfaces = { path = "../crates/wit-interfaces", version = "0.1.7" }
fce-wit-parser = { path = "../crates/wit-parser", version = "0.1.9" }
wasmer-runtime = { package = "wasmer-runtime-fl", version = "0.17.0" }
# dynamicfunc-fat-closures allows using state inside DynamicFunc
wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0", features = ["dynamicfunc-fat-closures"] }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.10" }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.12" }
wasmer-wasi = { package = "wasmer-wasi-fl", version = "0.17.0" }
multimap = "0.8.1"

@ -14,17 +14,19 @@
* limitations under the License.
*/
use super::module::FCEModule;
use super::*;
use crate::module::FCEModule;
use crate::module::RecordTypes;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::rc::Rc;
/// Represent FCE module interface.
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct FCEModuleInterface<'a> {
pub record_types: &'a HashMap<u64, IRecordType>,
pub function_signatures: Vec<FCEFunctionSignature<'a>>,
pub record_types: &'a RecordTypes,
pub function_signatures: Vec<FCEFunctionSignature>,
}
/// The base struct of the Fluence Compute Engine.
@ -128,10 +130,7 @@ impl FCE {
}
/// Return record types exported by module with given name.
pub fn module_record_types<S: AsRef<str>>(
&self,
module_name: S,
) -> Option<&HashMap<u64, IRecordType>> {
pub fn module_record_types<S: AsRef<str>>(&self, module_name: S) -> Option<&RecordTypes> {
self.modules
.get(module_name.as_ref())
.map(|module| module.export_record_types())
@ -142,7 +141,7 @@ impl FCE {
&self,
module_name: S,
record_id: u64,
) -> Option<&'_ IRecordType> {
) -> Option<&Rc<IRecordType>> {
self.modules
.get(module_name.as_ref())
.and_then(|module| module.export_record_type_by_id(record_id))

@ -19,6 +19,7 @@ use super::ivalues_lifting::wvalues_to_ivalues;
use super::ivalues_lowering::ivalue_to_wvalues;
use super::utils::itypes_args_to_wtypes;
use super::utils::itypes_output_to_wtypes;
use crate::RecordTypes;
use crate::init_wasm_func_once;
use crate::call_wasm_func;
@ -29,15 +30,13 @@ use wasmer_core::vm::Ctx;
use wasmer_core::typed_func::DynamicFunc;
use wasmer_core::types::Value as WValue;
use wasmer_core::types::FuncSig;
use wasmer_wit::types::RecordType;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
pub(crate) fn create_host_import_func(
descriptor: HostImportDescriptor,
record_types: Rc<HashMap<u64, RecordType>>,
record_types: Rc<RecordTypes>,
) -> DynamicFunc<'static> {
let allocate_func: AllocateFunc = Box::new(RefCell::new(None));
let set_result_ptr_func: SetResultPtrFunc = Box::new(RefCell::new(None));

@ -19,6 +19,7 @@ use super::WType;
use super::WValue;
use super::HostImportError;
use crate::IValue;
use crate::RecordTypes;
use crate::IType;
use super::Result;
@ -27,14 +28,13 @@ use wasmer_core::vm::Ctx;
use wasmer_wit::types::RecordType;
use wasmer_wit::vec1::Vec1;
use std::collections::HashMap;
use std::rc::Rc;
pub(super) fn wvalues_to_ivalues(
ctx: &Ctx,
wvalues: &[WValue],
itypes: &[IType],
record_types: &Rc<HashMap<u64, RecordType>>,
record_types: &Rc<RecordTypes>,
) -> Result<Vec<IValue>> {
let mut result = Vec::new();
let mut wvalue = wvalues.iter();
@ -114,7 +114,7 @@ fn lift_array(
value_type: &IType,
offset: usize,
size: usize,
record_types: &Rc<HashMap<u64, RecordType>>,
record_types: &Rc<RecordTypes>,
) -> Result<Vec<IValue>> {
if size == 0 {
return Ok(vec![]);
@ -211,7 +211,7 @@ fn lift_record(
ctx: &Ctx,
record_type: &RecordType,
offset: usize,
record_types: &Rc<HashMap<u64, RecordType>>,
record_types: &Rc<RecordTypes>,
) -> Result<IValue> {
// TODO: make it export from wasmer-interface-types crate
fn record_size(record_type: &RecordType) -> usize {

@ -45,6 +45,7 @@ pub use module::IValue;
pub use module::IRecordType;
pub use module::IFunctionArg;
pub use module::IType;
pub use module::RecordTypes;
pub use module::FCEFunctionSignature;
pub use module::from_interface_values;
pub use module::to_interface_value;

@ -16,6 +16,7 @@
use super::wit_prelude::*;
use super::{IType, IRecordType, IFunctionArg, IValue, WValue};
use super::RecordTypes;
use crate::Result;
use crate::FCEModuleConfig;
@ -31,6 +32,7 @@ use std::collections::HashMap;
use std::convert::TryInto;
use std::mem::MaybeUninit;
use std::sync::Arc;
use std::rc::Rc;
type WITInterpreter =
Interpreter<WITInstance, WITExport, WITFunction, WITMemory, WITMemoryView<'static>>;
@ -38,8 +40,16 @@ type WITInterpreter =
#[derive(Clone)]
pub(super) struct WITModuleFunc {
interpreter: Arc<WITInterpreter>,
pub(super) arguments: Vec<IFunctionArg>,
pub(super) output_types: Vec<IType>,
pub(super) arguments: Rc<Vec<IFunctionArg>>,
pub(super) output_types: Rc<Vec<IType>>,
}
/// Represent a function type inside FCE module.
#[derive(PartialEq, Eq, Debug, Clone, Hash)]
pub struct FCEFunctionSignature {
pub name: Rc<String>,
pub arguments: Rc<Vec<IFunctionArg>>,
pub outputs: Rc<Vec<IType>>,
}
#[derive(Clone)]
@ -48,14 +58,6 @@ pub(super) struct Callable {
pub(super) wit_module_func: WITModuleFunc,
}
/// Represent a function type inside FCE module.
#[derive(PartialEq, Eq, Debug, Clone, Hash)]
pub struct FCEFunctionSignature<'a> {
pub name: &'a str,
pub arguments: &'a Vec<IFunctionArg>,
pub outputs: &'a Vec<IType>,
}
impl Callable {
pub fn call(&mut self, args: &[IValue]) -> Result<Vec<IValue>> {
use wasmer_wit::interpreter::stack::Stackable;
@ -71,6 +73,17 @@ impl Callable {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default, Hash)]
struct SharedString(pub Rc<String>);
impl std::borrow::Borrow<str> for SharedString {
fn borrow(&self) -> &str {
self.0.as_str()
}
}
type ExportFunctions = HashMap<SharedString, Rc<Callable>>;
pub(crate) struct FCEModule {
// wasmer_instance is needed because WITInstance contains dynamic functions
// that internally keep pointer to it.
@ -93,10 +106,11 @@ pub(crate) struct FCEModule {
host_closures_import_object: ImportObject,
// TODO: replace with dyn Trait
export_funcs: HashMap<String, Arc<Callable>>,
export_funcs: ExportFunctions,
// TODO: save refs instead of copies
record_types: HashMap<u64, IRecordType>,
// TODO: save refs instead copying of a record types HashMap.
/// Record types used in exported functions as arguments or return values.
export_record_types: RecordTypes,
}
impl FCEModule {
@ -125,7 +139,7 @@ impl FCEModule {
};
let export_funcs = Self::instantiate_wit_exports(&wit_instance, &fce_wit)?;
let record_types = Self::extract_export_record_types(&export_funcs, &wit_instance)?;
let export_record_types = Self::extract_export_record_types(&export_funcs, &wit_instance)?;
// call _start to populate the WASI state of the module
#[rustfmt::skip]
@ -139,7 +153,7 @@ impl FCEModule {
host_import_object: raw_imports,
host_closures_import_object,
export_funcs,
record_types,
export_record_types,
})
}
@ -151,26 +165,26 @@ impl FCEModule {
function_name
)))
},
|func| Arc::make_mut(func).call(args),
|func| Rc::make_mut(func).call(args),
)
}
pub(crate) fn get_exports_signatures(&self) -> impl Iterator<Item = FCEFunctionSignature<'_>> {
pub(crate) fn get_exports_signatures(&self) -> impl Iterator<Item = FCEFunctionSignature> + '_ {
self.export_funcs
.iter()
.map(|(func_name, func)| FCEFunctionSignature {
name: func_name.as_str(),
arguments: &func.wit_module_func.arguments,
outputs: &func.wit_module_func.output_types,
name: func_name.0.clone(),
arguments: func.wit_module_func.arguments.clone(),
outputs: func.wit_module_func.output_types.clone(),
})
}
pub(crate) fn export_record_types(&self) -> &HashMap<u64, IRecordType> {
&self.record_types
pub(crate) fn export_record_types(&self) -> &RecordTypes {
&self.export_record_types
}
pub(crate) fn export_record_type_by_id(&self, record_type: u64) -> Option<&IRecordType> {
self.record_types.get(&record_type)
pub(crate) fn export_record_type_by_id(&self, record_type: u64) -> Option<&Rc<IRecordType>> {
self.export_record_types.get(&record_type)
}
pub(crate) fn get_wasi_state(&mut self) -> &wasmer_wasi::state::WasiState {
@ -178,7 +192,7 @@ impl FCEModule {
}
// TODO: change the cloning Callable behaviour after changes of Wasmer API
pub(super) fn get_callable(&self, function_name: &str) -> Result<Arc<Callable>> {
pub(super) fn get_callable(&self, function_name: &str) -> Result<Rc<Callable>> {
match self.export_funcs.get(function_name) {
Some(func) => Ok(func.clone()),
None => Err(FCEError::NoSuchFunction(format!(
@ -220,7 +234,7 @@ impl FCEModule {
.record_types()
.map(|(id, r)| (id, r.clone()))
.collect::<HashMap<_, _>>();
let record_types = std::rc::Rc::new(record_types);
let record_types = Rc::new(record_types);
for (import_name, descriptor) in config.host_imports {
let host_import = create_host_import_func(descriptor, record_types.clone());
@ -239,7 +253,7 @@ impl FCEModule {
fn instantiate_wit_exports(
wit_instance: &Arc<WITInstance>,
wit: &FCEWITInterfaces<'_>,
) -> Result<HashMap<String, Arc<Callable>>> {
) -> Result<ExportFunctions> {
use fce_wit_interfaces::WITAstType;
wit.implementations()
@ -275,13 +289,13 @@ impl FCEModule {
output_types: output_types.clone(),
};
Ok((
export_function_name.to_string(),
Arc::new(Callable {
wit_instance: wit_instance.clone(),
wit_module_func,
}),
))
let shared_string = SharedString(Rc::new(export_function_name.to_string()));
let callable = Rc::new(Callable {
wit_instance: wit_instance.clone(),
wit_module_func,
});
Ok((shared_string, callable))
}
_ => Err(FCEError::IncorrectWIT(format!(
"type with idx = {} isn't a function type",
@ -289,7 +303,7 @@ impl FCEModule {
))),
}
})
.collect::<Result<HashMap<String, Arc<Callable>>>>()
.collect::<Result<ExportFunctions>>()
}
// this function deals only with import functions that have an adaptor implementation
@ -430,13 +444,13 @@ impl FCEModule {
}
fn extract_export_record_types(
export_funcs: &HashMap<String, Arc<Callable>>,
export_funcs: &ExportFunctions,
wit_instance: &Arc<WITInstance>,
) -> Result<HashMap<u64, IRecordType>> {
) -> Result<RecordTypes> {
fn handle_record_type(
record_type_id: u64,
wit_instance: &Arc<WITInstance>,
export_record_types: &mut HashMap<u64, IRecordType>,
export_record_types: &mut RecordTypes,
) -> Result<()> {
use wasmer_wit::interpreter::wasm::structures::Instance;

@ -21,6 +21,8 @@ mod wit_instance;
mod type_converters;
mod fce_module;
pub use wit_instance::RecordTypes;
pub use wasmer_wit::types::InterfaceType as IType;
pub use wasmer_wit::types::RecordType as IRecordType;
pub use wasmer_wit::ast::FunctionArg as IFunctionArg;

@ -22,20 +22,21 @@ use crate::Result;
use wasmer_wit::interpreter::wasm;
use wasmer_core::instance::DynFunc;
use std::sync::Arc;
// use std::sync::Arc;
use std::rc::Rc;
#[derive(Clone)]
enum WITFunctionInner {
Export {
func: Arc<DynFunc<'static>>,
arguments: Vec<IFunctionArg>,
outputs: Vec<IType>,
func: Rc<DynFunc<'static>>,
arguments: Rc<Vec<IFunctionArg>>,
outputs: Rc<Vec<IType>>,
},
Import {
// TODO: use dyn Callable here
callable: Arc<Callable>,
arguments: Vec<IFunctionArg>,
outputs: Vec<IType>,
callable: Rc<Callable>,
arguments: Rc<Vec<IFunctionArg>>,
outputs: Rc<Vec<IType>>,
},
}
@ -67,9 +68,9 @@ impl WITFunction {
.collect::<Vec<_>>();
let inner = WITFunctionInner::Export {
func: Arc::new(dyn_func),
arguments,
outputs,
func: Rc::new(dyn_func),
arguments: Rc::new(arguments),
outputs: Rc::new(outputs),
};
Ok(Self { inner })
@ -79,8 +80,8 @@ impl WITFunction {
pub(super) fn from_import(
wit_module: &FCEModule,
function_name: &str,
arguments: Vec<IFunctionArg>,
outputs: Vec<IType>,
arguments: Rc<Vec<IFunctionArg>>,
outputs: Rc<Vec<IType>>,
) -> Result<Self> {
let callable = wit_module.get_callable(function_name)?;
@ -132,7 +133,7 @@ impl wasm::structures::LocalImport for WITFunction {
.call(&arguments.iter().map(ival_to_wval).collect::<Vec<WValue>>())
.map(|result| result.iter().map(wval_to_ival).collect())
.map_err(|_| ()),
WITFunctionInner::Import { callable, .. } => Arc::make_mut(&mut callable.clone())
WITFunctionInner::Import { callable, .. } => Rc::make_mut(&mut callable.clone())
.call(arguments)
.map_err(|_| ()),
}

@ -26,6 +26,9 @@ use wasmer_wit::interpreter::wasm::structures::{LocalImportIndex, TypedIndex};
use wasmer_core::Instance as WasmerInstance;
use std::collections::HashMap;
use std::rc::Rc;
pub type RecordTypes = HashMap<u64, Rc<IRecordType>>;
/// Contains all import and export functions that could be called from WIT context by call-core.
#[derive(Clone)]
@ -36,7 +39,8 @@ pub(super) struct WITInstance {
/// WIT memories.
memories: Vec<WITMemory>,
record_types_by_id: HashMap<u64, IRecordType>,
/// All record types that instance contains.
record_types_by_id: RecordTypes,
}
impl WITInstance {
@ -146,8 +150,8 @@ impl WITInstance {
memories
}
fn extract_record_types(wit: &FCEWITInterfaces<'_>) -> HashMap<u64, IRecordType> {
let record_types_by_id = wit.types().fold(
fn extract_record_types(wit: &FCEWITInterfaces<'_>) -> RecordTypes {
let (record_types_by_id, _) = wit.types().fold(
(HashMap::new(), 0u64),
|(mut record_types_by_id, id), ty| {
match ty {
@ -160,7 +164,7 @@ impl WITInstance {
},
);
record_types_by_id.0
record_types_by_id
}
}
@ -184,7 +188,7 @@ impl wasm::structures::Instance<WITExport, WITFunction, WITMemory, WITMemoryView
}
}
fn wit_record_by_id(&self, index: u64) -> Option<&IRecordType> {
fn wit_record_by_id(&self, index: u64) -> Option<&Rc<IRecordType>> {
self.record_types_by_id.get(&index)
}
}

@ -1,13 +1,13 @@
[package]
name = "fluence-app-service"
description = "Fluence Application Service"
version = "0.1.10"
version = "0.1.11"
authors = ["Fluence Labs"]
license = "Apache-2.0"
edition = "2018"
[dependencies]
fluence-faas = { path = "../fluence-faas", version = "0.1.10" }
fluence-faas = { path = "../fluence-faas", version = "0.1.11" }
maplit = "1.0.2"
log = "0.4.8"

@ -17,9 +17,9 @@
use crate::Result;
use crate::config::AppServiceConfig;
use super::AppServiceError;
use super::IValue;
use fluence_faas::FluenceFaaS;
use serde_json::Value as JValue;
use std::convert::TryInto;
use std::collections::HashMap;
@ -73,9 +73,9 @@ impl AppService {
pub fn call<S: AsRef<str>>(
&mut self,
func_name: S,
arguments: serde_json::Value,
arguments: JValue,
call_parameters: crate::CallParameters,
) -> Result<Vec<IValue>> {
) -> Result<JValue> {
self.faas
.call_with_json(
&self.facade_module_name,
@ -177,9 +177,9 @@ impl AppService {
&mut self,
module_name: MN,
func_name: FN,
arguments: serde_json::Value,
arguments: JValue,
call_parameters: crate::CallParameters,
) -> Result<Vec<IValue>> {
) -> Result<JValue> {
self.faas
.call_with_json(module_name, func_name, arguments, call_parameters)
.map_err(Into::into)

@ -1,20 +1,20 @@
[package]
name = "fluence-faas"
description = "Fluence FaaS"
version = "0.1.10"
version = "0.1.11"
authors = ["Fluence Labs"]
license = "Apache-2.0"
edition = "2018"
[dependencies]
fce = { path = "../engine", version = "0.1.9" }
fce = { path = "../engine", version = "0.1.10" }
fluence-sdk-main = "=0.2.8"
wasmer-runtime = { package = "wasmer-runtime-fl", version = "0.17.0" }
# dynamicfunc-fat-closures allows using state inside DynamicFunc
wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0", features = ["dynamicfunc-fat-closures"] }
wasmer-wasi = { package = "wasmer-wasi-fl", version = "0.17.0" }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.10" }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.12" }
toml = "0.5.6"
serde = { version = "1.0.111", features = ["derive"] }

@ -16,8 +16,6 @@
use fce::FCEError;
use serde_json::error::Error as SerdeError;
use std::io::Error as IOError;
use std::error::Error;
@ -41,16 +39,17 @@ pub enum FaaSError {
/// Returns when there is no module with such name.
NoSuchModule(String),
/// Not enough arguments provided for FCE call.
/// Provided arguments aren't compatible with a called function signature.
JsonArgumentsDeserializationError(String),
/// An error occurred when incorrect json argument is supplied.
ArgumentDeserializationError(SerdeError),
/// Returned outputs aren't compatible with a called function signature.
JsonOutputSerializationError(String),
/// Errors related to invalid config.
ParseConfigError(toml::de::Error),
/// FCE errors.
EngineError(FCEError),
ParseConfigError(toml::de::Error),
}
impl Error for FaaSError {}
@ -70,7 +69,7 @@ impl std::fmt::Display for FaaSError {
write!(f, r#"module with name "{}" is missing"#, module_name)
}
FaaSError::JsonArgumentsDeserializationError(args) => write!(f, "{}", args),
FaaSError::ArgumentDeserializationError(err_msg) => write!(f, "{:?}", err_msg),
FaaSError::JsonOutputSerializationError(args) => write!(f, "{}", args),
FaaSError::IOError(err_msg) => write!(f, "{}", err_msg),
FaaSError::EngineError(err) => write!(f, "{}", err),
FaaSError::ParseConfigError(err) => write!(f, "{}", err),

@ -15,21 +15,22 @@
*/
use crate::config::FaaSConfig;
use crate::misc::ModulesLoadStrategy;
use crate::faas_interface::FaaSInterface;
use crate::FaaSError;
use crate::Result;
use crate::IValue;
use crate::misc::load_modules_from_fs;
use crate::misc::ModulesLoadStrategy;
use fce::FCE;
use fluence_sdk_main::CallParameters;
use serde_json::Value as JValue;
use std::cell::RefCell;
use std::convert::TryInto;
use std::collections::HashSet;
use std::collections::HashMap;
use std::rc::Rc;
use std::fs;
use std::path::PathBuf;
// TODO: remove and use mutex instead
@ -61,7 +62,7 @@ impl FluenceFaaS {
.modules_dir
.as_ref()
.map_or(Ok(HashMap::new()), |dir| {
Self::load_modules(dir, ModulesLoadStrategy::WasmOnly)
load_modules_from_fs(dir, ModulesLoadStrategy::WasmOnly)
})?;
Self::with_modules::<FaaSConfig>(modules, config)
@ -112,62 +113,12 @@ impl FluenceFaaS {
.modules_dir
.as_ref()
.map_or(Ok(HashMap::new()), |dir| {
Self::load_modules(dir, ModulesLoadStrategy::Named(names))
load_modules_from_fs(dir, ModulesLoadStrategy::Named(names))
})?;
Self::with_modules::<FaaSConfig>(modules, config)
}
/// Loads modules from a directory at a given path. Non-recursive, ignores subdirectories.
fn load_modules(
modules_dir: &PathBuf,
modules: ModulesLoadStrategy<'_>,
) -> Result<HashMap<String, Vec<u8>>> {
use FaaSError::IOError;
let mut dir_entries =
fs::read_dir(modules_dir).map_err(|e| IOError(format!("{:?}: {}", modules_dir, e)))?;
let loaded = dir_entries.try_fold(HashMap::new(), |mut hash_map, entry| {
let entry = entry?;
let path = entry.path();
// Skip directories
if path.is_dir() {
return Ok(hash_map);
}
let module_name = path
.file_name()
.ok_or_else(|| IOError(format!("No file name in path {:?}", path)))?
.to_os_string()
.into_string()
.map_err(|name| IOError(format!("invalid file name: {:?}", name)))?;
if modules.should_load(&module_name.as_ref()) {
let module_bytes = fs::read(path)?;
let module_name = modules.extract_module_name(module_name);
if hash_map.insert(module_name, module_bytes).is_some() {
return Err(FaaSError::ConfigParseError(String::from(
"module {} is duplicated in config",
)));
}
}
Ok(hash_map)
})?;
if modules.required_modules_len() > loaded.len() {
let loaded = loaded.iter().map(|(n, _)| n);
let not_found = modules.missing_modules(loaded);
return Err(FaaSError::ConfigParseError(format!(
"the following modules were not found: {:?}",
not_found
)));
}
Ok(loaded)
}
/// Call a specified function of loaded on a startup module by its name.
pub fn call_with_ivalues<MN: AsRef<str>, FN: AsRef<str>>(
&mut self,
@ -188,34 +139,36 @@ impl FluenceFaaS {
&mut self,
module_name: MN,
func_name: FN,
json_args: serde_json::Value,
json_args: JValue,
call_parameters: fluence_sdk_main::CallParameters,
) -> Result<Vec<IValue>> {
) -> Result<JValue> {
use crate::misc::json_to_ivalues;
use crate::misc::ivalues_to_json;
let module_name = module_name.as_ref();
let func_name = func_name.as_ref();
let iargs = {
// TODO: cache module interface
let module_interface = self
.fce
.module_interface(module_name)
.ok_or_else(|| FaaSError::NoSuchModule(module_name.to_string()))?;
// TODO: cache module interface
let module_interface = self
.fce
.module_interface(module_name)
.ok_or_else(|| FaaSError::NoSuchModule(module_name.to_string()))?;
let func_signature = module_interface
.function_signatures
.iter()
.find(|sign| sign.name == func_name)
.ok_or_else(|| FaaSError::MissingFunctionError(func_name.to_string()))?;
let func_signature = module_interface
.function_signatures
.iter()
.find(|sign| sign.name.as_str() == func_name)
.ok_or_else(|| FaaSError::MissingFunctionError(func_name.to_string()))?;
let record_types = module_interface.record_types;
let record_types = module_interface.record_types.clone();
crate::misc::json_to_ivalues(json_args, func_signature, &record_types)?
};
let iargs = json_to_ivalues(json_args, func_signature, &record_types)?;
let outputs = func_signature.outputs.clone();
self.call_parameters.replace(call_parameters);
self.fce
.call(module_name, func_name, &iargs)
.map_err(Into::into)
let result = self.fce.call(module_name, func_name, &iargs)?;
ivalues_to_json(result, &outputs, &record_types)
}
/// Return all export functions (name and signatures) of loaded modules.

@ -19,12 +19,14 @@ use super::IRecordType;
use crate::FaaSModuleInterface;
use crate::FaaSFunctionSignature;
use fce::RecordTypes;
use serde::Serialize;
use serde::Serializer;
use std::fmt;
use std::collections::HashMap;
use std::collections::HashSet;
use std::rc::Rc;
use itertools::Itertools;
#[derive(Debug, PartialEq, Eq, Clone)]
@ -34,7 +36,7 @@ pub struct FaaSInterface<'a> {
impl<'a> fmt::Display for FaaSInterface<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let type_text_view = |arg_ty: &IType, record_types: &HashMap<u64, IRecordType>| {
let type_text_view = |arg_ty: &IType, record_types: &RecordTypes| {
match arg_ty {
IType::Record(record_type_id) => {
// unwrap is safe because FaaSInterface here is well-formed
@ -88,7 +90,7 @@ impl<'a> fmt::Display for FaaSInterface<'a> {
})
.join(", ");
let outputs = function_signature.outputs;
let outputs = &function_signature.outputs;
if outputs.is_empty() {
writeln!(f, "{})", args)?;
} else if outputs.len() == 1 {
@ -116,9 +118,9 @@ impl<'a> Serialize for FaaSInterface<'a> {
{
#[derive(Serialize)]
pub struct FunctionSignature<'a> {
pub name: &'a str,
pub name: &'a Rc<String>,
pub arguments: Vec<(&'a String, &'a IType)>,
pub output_types: &'a Vec<IType>,
pub output_types: &'a Rc<Vec<IType>>,
}
#[derive(Serialize)]
@ -140,9 +142,9 @@ impl<'a> Serialize for FaaSInterface<'a> {
pub modules: Vec<Module<'a>>,
}
fn serialize_function_signature<'a>(
signature: &'a FaaSFunctionSignature<'_>,
) -> FunctionSignature<'a> {
fn serialize_function_signature(
signature: &FaaSFunctionSignature,
) -> FunctionSignature<'_> {
let arguments = signature
.arguments
.iter()
@ -150,13 +152,13 @@ impl<'a> Serialize for FaaSInterface<'a> {
.collect();
FunctionSignature {
name: signature.name,
name: &signature.name,
arguments,
output_types: signature.outputs,
output_types: &signature.outputs,
}
}
fn serialize_record_type<'a, 'b>(record: (&'a u64, &'b IRecordType)) -> RecordType<'b> {
fn serialize_record_type<'a, 'b>(record: (&'a u64, &'b Rc<IRecordType>)) -> RecordType<'b> {
let fields = record
.1
.fields

@ -0,0 +1,102 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use crate::IValue;
use crate::IType;
use crate::Result;
use crate::errors::FaaSError::JsonOutputSerializationError as OutputDeError;
use fce::RecordTypes;
use serde_json::Value as JValue;
pub(crate) fn ivalues_to_json(
mut ivalues: Vec<IValue>,
outputs: &[IType],
record_types: &RecordTypes,
) -> Result<JValue> {
if outputs.len() != ivalues.len() {
return Err(OutputDeError(format!(
"resulted values {:?} and function signature {:?} aren't compatible",
ivalues, outputs
)));
}
match ivalues.len() {
0 => Ok(JValue::Null),
1 => ivalue_to_json(ivalues.remove(0), outputs.first().unwrap(), record_types),
_ => unimplemented!(
"multi-values aren't supported now - more then one result values aren't possible"
),
}
}
fn ivalue_to_json(ivalue: IValue, output: &IType, record_types: &RecordTypes) -> Result<JValue> {
use serde_json::json;
// clone here needed because binding by-value and by-ref in the same pattern in unstable
match (ivalue, output.clone()) {
(IValue::S8(value), IType::S8) => Ok(json!(value)),
(IValue::S16(value), IType::S16) => Ok(json!(value)),
(IValue::S32(value), IType::S32) => Ok(json!(value)),
(IValue::S64(value), IType::S64) => Ok(json!(value)),
(IValue::U8(value), IType::U8) => Ok(json!(value)),
(IValue::U16(value), IType::U16) => Ok(json!(value)),
(IValue::U32(value), IType::U32) => Ok(json!(value)),
(IValue::U64(value), IType::U64) => Ok(json!(value)),
(IValue::I32(value), IType::I32) => Ok(json!(value)),
(IValue::I64(value), IType::I64) => Ok(json!(value)),
(IValue::F32(value), IType::F32) => Ok(json!(value)),
(IValue::F64(value), IType::F64) => Ok(json!(value)),
(IValue::String(value), IType::String) => Ok(json!(value)),
(IValue::Array(value), IType::Array(array_ty)) => {
let result: Result<Vec<_>> = value
.into_iter()
.map(|v| ivalue_to_json(v, &array_ty, record_types))
.collect();
Ok(JValue::Array(result?))
}
(IValue::Record(field_values), IType::Record(record_id)) => {
let record_type = record_types.get(&record_id).ok_or_else(|| {
OutputDeError(format!(
"record id {} wasn't found in module record types",
record_id
))
})?;
let field_types = &record_type.fields;
if field_values.len() != field_types.len() {
return Err(OutputDeError(format!(
"output record {:?} isn't compatible to output record fields {:?}",
field_values, field_types
)));
}
let field_values = field_values.into_vec();
let mut result = serde_json::Map::with_capacity(field_values.len());
for (field_value, field_type) in field_values.into_iter().zip(field_types.iter()) {
let json_field_value = ivalue_to_json(field_value, &field_type.ty, record_types)?;
result.insert(field_type.name.clone(), json_field_value);
}
Ok(JValue::Object(result))
}
(ivalue, itype) => Err(OutputDeError(format!(
"value {:?} is incompatible to type {:?}",
ivalue, itype
))),
}
}

@ -17,21 +17,21 @@
use crate::IValue;
use crate::IType;
use crate::Result;
use crate::FaaSError;
use crate::FaaSError::JsonArgumentsDeserializationError as ArgDeError;
use serde_json::Value as SerdeValue;
use fce::RecordTypes;
use serde_json::Value as JValue;
use wasmer_wit::vec1::Vec1;
use wasmer_wit::types::RecordType;
use std::collections::HashMap;
pub(crate) fn json_to_ivalues(
json_args: serde_json::Value,
func_signature: &crate::FaaSFunctionSignature<'_>,
record_types: &HashMap<u64, RecordType>,
json_args: JValue,
func_signature: &crate::FaaSFunctionSignature,
record_types: &RecordTypes,
) -> Result<Vec<IValue>> {
let ivalues = match json_args {
SerdeValue::Object(json_map) => json_map_to_ivalues(
JValue::Object(json_map) => json_map_to_ivalues(
json_map,
func_signature
.arguments
@ -39,37 +39,37 @@ pub(crate) fn json_to_ivalues(
.map(|arg| (&arg.name, &arg.ty)),
&record_types,
)?,
SerdeValue::Array(json_array) => json_array_to_ivalues(
JValue::Array(json_array) => json_array_to_ivalues(
json_array,
func_signature.arguments.iter().map(|arg| &arg.ty),
&record_types,
)?,
SerdeValue::String(json_string) => json_string_to_ivalue(json_string, func_signature)?,
json_bool @ SerdeValue::Bool(_) => json_bool_to_ivalue(json_bool, func_signature)?,
json_number @ SerdeValue::Number(_) => json_number_to_ivalue(json_number, func_signature)?,
SerdeValue::Null => json_null_to_ivalue(func_signature)?,
JValue::String(json_string) => json_string_to_ivalue(json_string, func_signature)?,
json_bool @ JValue::Bool(_) => json_bool_to_ivalue(json_bool, func_signature)?,
json_number @ JValue::Number(_) => json_number_to_ivalue(json_number, func_signature)?,
JValue::Null => json_null_to_ivalue(func_signature)?,
};
Ok(ivalues)
}
fn json_map_to_ivalues<'a, 'b>(
mut json_map: serde_json::Map<String, SerdeValue>,
mut json_map: serde_json::Map<String, JValue>,
signature: impl Iterator<Item = (&'a String, &'a IType)>,
record_types: &'b HashMap<u64, RecordType>,
record_types: &'b RecordTypes,
) -> Result<Vec<IValue>> {
let mut iargs = Vec::new();
for (arg_name, arg_type) in signature {
let json_value = json_map
.remove(arg_name)
.ok_or_else(|| FaaSError::MissingArgumentError(arg_name.clone()))?;
.ok_or_else(|| ArgDeError(format!("missing argument with name {}", arg_name)))?;
let iarg = json_value_to_ivalue(json_value, arg_type, record_types)?;
iargs.push(iarg);
}
if !json_map.is_empty() {
return Err(FaaSError::JsonArgumentsDeserializationError(format!(
return Err(ArgDeError(format!(
"function requires {} arguments, {} provided",
iargs.len(),
iargs.len() + json_map.len()
@ -80,12 +80,12 @@ fn json_map_to_ivalues<'a, 'b>(
}
fn json_array_to_ivalues<'a, 'b>(
mut json_array: Vec<SerdeValue>,
mut json_array: Vec<JValue>,
signature: impl Iterator<Item = &'a IType> + std::iter::ExactSizeIterator,
record_types: &'b HashMap<u64, RecordType>,
record_types: &'b RecordTypes,
) -> Result<Vec<IValue>> {
if json_array.len() != signature.len() {
return Err(FaaSError::JsonArgumentsDeserializationError(format!(
return Err(ArgDeError(format!(
"function requires {} arguments, {} provided",
signature.len(),
json_array.len()
@ -106,10 +106,10 @@ fn json_array_to_ivalues<'a, 'b>(
fn json_string_to_ivalue(
json_string: String,
func_signature: &fce::FCEFunctionSignature<'_>,
func_signature: &fce::FCEFunctionSignature,
) -> Result<Vec<IValue>> {
if func_signature.arguments.len() != 1 || func_signature.arguments[0].ty != IType::String {
return Err(FaaSError::JsonArgumentsDeserializationError(format!(
return Err(ArgDeError(format!(
"the called function has the following signature: {:?}, but only one string argument is provided",
func_signature
)));
@ -119,11 +119,11 @@ fn json_string_to_ivalue(
}
fn json_bool_to_ivalue(
json_bool: SerdeValue,
func_signature: &fce::FCEFunctionSignature<'_>,
json_bool: JValue,
func_signature: &fce::FCEFunctionSignature,
) -> Result<Vec<IValue>> {
if func_signature.arguments.len() != 1 {
return Err(FaaSError::JsonArgumentsDeserializationError(format!(
return Err(ArgDeError(format!(
"the called function has the following signature: {:?}, but only one bool argument is provided",
func_signature
)));
@ -137,11 +137,11 @@ fn json_bool_to_ivalue(
}
fn json_number_to_ivalue(
json_number: SerdeValue,
func_signature: &fce::FCEFunctionSignature<'_>,
json_number: JValue,
func_signature: &fce::FCEFunctionSignature,
) -> Result<Vec<IValue>> {
if func_signature.arguments.len() != 1 {
return Err(FaaSError::JsonArgumentsDeserializationError(format!(
return Err(ArgDeError(format!(
"the called function has the following signature: {:?}, but only one number argument is provided",
func_signature
)));
@ -154,9 +154,9 @@ fn json_number_to_ivalue(
)?])
}
fn json_null_to_ivalue(func_signature: &fce::FCEFunctionSignature<'_>) -> Result<Vec<IValue>> {
fn json_null_to_ivalue(func_signature: &fce::FCEFunctionSignature) -> Result<Vec<IValue>> {
if !func_signature.arguments.is_empty() {
return Err(FaaSError::JsonArgumentsDeserializationError(format!(
return Err(ArgDeError(format!(
"the called function has the following signature: {:?}, but no arguments is provided",
func_signature
)));
@ -166,80 +166,50 @@ fn json_null_to_ivalue(func_signature: &fce::FCEFunctionSignature<'_>) -> Result
}
fn json_value_to_ivalue(
json_value: SerdeValue,
json_value: JValue,
ty: &IType,
record_types: &HashMap<u64, RecordType>,
record_types: &RecordTypes,
) -> Result<IValue> {
// TODO: get rid of copy-past
macro_rules! to_ivalue(
($json_value:expr, $ty:ident) => {
{
let value = serde_json::from_value($json_value).map_err(|e| {
ArgDeError(format!(
"error {:?} occurred while deserialize output result to a json value",
e
))
})?;
Ok(IValue::$ty(value))
}
}
);
match ty {
IType::S8 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::S8(value))
}
IType::S16 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::S16(value))
}
IType::S32 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::S32(value))
}
IType::S64 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::S64(value))
}
IType::U8 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::U8(value))
}
IType::U16 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::U16(value))
}
IType::U32 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::U32(value))
}
IType::U64 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::U64(value))
}
IType::F32 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::F32(value))
}
IType::F64 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::F64(value))
}
IType::String => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::String(value))
}
IType::S8 => to_ivalue!(json_value, S8),
IType::S16 => to_ivalue!(json_value, S16),
IType::S32 => to_ivalue!(json_value, S32),
IType::S64 => to_ivalue!(json_value, S64),
IType::U8 => to_ivalue!(json_value, U8),
IType::U16 => to_ivalue!(json_value, U16),
IType::U32 => to_ivalue!(json_value, U32),
IType::U64 => to_ivalue!(json_value, U64),
IType::F32 => to_ivalue!(json_value, F32),
IType::F64 => to_ivalue!(json_value, F64),
IType::String => to_ivalue!(json_value, String),
IType::Array(value_type) => {
let value = match json_value {
SerdeValue::Array(json_array) => {
let mut iargs = Vec::with_capacity(json_array.len());
JValue::Array(json_array) => {
let iargs: Result<Vec<_>> = json_array
.into_iter()
.map(|json_value| {
json_value_to_ivalue(json_value, value_type, record_types)
})
.collect();
for json_value in json_array {
let iarg = json_value_to_ivalue(json_value, value_type, record_types)?;
iargs.push(iarg);
}
Ok(iargs)
Ok(iargs?)
}
_ => Err(FaaSError::JsonArgumentsDeserializationError(format!(
_ => Err(ArgDeError(format!(
"expected array of {:?} types, got {:?}",
value_type, json_value
))),
@ -247,41 +217,31 @@ fn json_value_to_ivalue(
Ok(IValue::Array(value))
}
IType::I32 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::I32(value))
}
IType::I64 => {
let value = serde_json::from_value(json_value)
.map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::I64(value))
}
IType::I32 => to_ivalue!(json_value, I32),
IType::I64 => to_ivalue!(json_value, I64),
IType::Record(record_type_id) => {
let value = json_record_type_to_ivalue(json_value, record_type_id, &record_types)?;
Ok(IValue::Record(value))
}
IType::Anyref => Err(FaaSError::JsonArgumentsDeserializationError(String::from(
"anyrefs aren't supported now",
))),
IType::Anyref => Err(ArgDeError(String::from("anyrefs aren't supported now"))),
}
}
#[allow(clippy::ptr_arg)]
fn json_record_type_to_ivalue(
json_value: SerdeValue,
json_value: JValue,
record_type_id: &u64,
record_types: &HashMap<u64, RecordType>,
record_types: &RecordTypes,
) -> Result<Vec1<IValue>> {
let record_type = record_types.get(record_type_id).ok_or_else(|| {
FaaSError::JsonArgumentsDeserializationError(format!(
ArgDeError(format!(
"record with type id `{}` wasn't found",
record_type_id
))
})?;
match json_value {
SerdeValue::Object(json_map) => Ok(Vec1::new(json_map_to_ivalues(
JValue::Object(json_map) => Ok(Vec1::new(json_map_to_ivalues(
json_map,
record_type
.fields
@ -290,13 +250,13 @@ fn json_record_type_to_ivalue(
record_types,
)?)
.unwrap()),
SerdeValue::Array(json_array) => Ok(Vec1::new(json_array_to_ivalues(
JValue::Array(json_array) => Ok(Vec1::new(json_array_to_ivalues(
json_array,
record_type.fields.iter().map(|field| (&field.ty)),
record_types,
)?)
.unwrap()),
_ => Err(FaaSError::JsonArgumentsDeserializationError(format!(
_ => Err(ArgDeError(format!(
"record with type id `{}` should be encoded as array or map of fields",
record_type_id
))),

@ -14,14 +14,17 @@
* limitations under the License.
*/
mod ivalues_to_json;
mod json_to_ivalues;
mod log_utf8_string_impl;
mod modules_load_strategy;
mod utils;
pub(crate) use ivalues_to_json::ivalues_to_json;
pub(crate) use json_to_ivalues::json_to_ivalues;
pub(crate) use modules_load_strategy::ModulesLoadStrategy;
pub(crate) use utils::create_host_import;
pub(crate) use utils::make_fce_config;
pub(crate) use utils::load_modules_from_fs;
pub(self) use log_utf8_string_impl::log_utf8_string_closure;

@ -14,8 +14,10 @@
* limitations under the License.
*/
use crate::config::FaaSModuleConfig;
use super::log_utf8_string_closure;
use crate::Result;
use crate::config::FaaSModuleConfig;
use crate::errors::FaaSError;
use fce::FCEModuleConfig;
use fce::HostImportDescriptor;
@ -28,6 +30,7 @@ use wasmer_wit::types::InterfaceType as IType;
use std::collections::HashMap;
use std::cell::RefCell;
use std::path::PathBuf;
use std::rc::Rc;
use std::ops::Deref;
@ -80,7 +83,7 @@ pub(crate) fn make_fce_config(
module_name: String,
faas_module_config: Option<FaaSModuleConfig>,
call_parameters: Rc<RefCell<fluence_sdk_main::CallParameters>>,
) -> crate::Result<FCEModuleConfig> {
) -> Result<FCEModuleConfig> {
let mut fce_module_config = FCEModuleConfig::default();
let faas_module_config = match faas_module_config {
@ -135,3 +138,55 @@ pub(crate) fn make_fce_config(
Ok(fce_module_config)
}
use crate::misc::ModulesLoadStrategy;
/// Loads modules from a directory at a given path. Non-recursive, ignores subdirectories.
pub(crate) fn load_modules_from_fs(
modules_dir: &PathBuf,
modules: ModulesLoadStrategy<'_>,
) -> Result<HashMap<String, Vec<u8>>> {
use FaaSError::IOError;
let mut dir_entries =
std::fs::read_dir(modules_dir).map_err(|e| IOError(format!("{:?}: {}", modules_dir, e)))?;
let loaded = dir_entries.try_fold(HashMap::new(), |mut hash_map, entry| {
let entry = entry?;
let path = entry.path();
// Skip directories
if path.is_dir() {
return Ok(hash_map);
}
let module_name = path
.file_name()
.ok_or_else(|| IOError(format!("No file name in path {:?}", path)))?
.to_os_string()
.into_string()
.map_err(|name| IOError(format!("invalid file name: {:?}", name)))?;
if modules.should_load(&module_name.as_ref()) {
let module_bytes = std::fs::read(path)?;
let module_name = modules.extract_module_name(module_name);
if hash_map.insert(module_name, module_bytes).is_some() {
return Err(FaaSError::ConfigParseError(String::from(
"module {} is duplicated in config",
)));
}
}
Ok(hash_map)
})?;
if modules.required_modules_len() > loaded.len() {
let loaded = loaded.iter().map(|(n, _)| n);
let not_found = modules.missing_modules(loaded);
return Err(FaaSError::ConfigParseError(format!(
"the following modules were not found: {:?}",
not_found
)));
}
Ok(loaded)
}

@ -14,14 +14,17 @@
* limitations under the License.
*/
mod utils;
use fluence_faas::FluenceFaaS;
use fluence_faas::IValue;
use fluence_faas::IType;
use pretty_assertions::assert_eq;
use once_cell::sync::Lazy;
use serde_json::json;
use std::rc::Rc;
static ARG_CONFIG: Lazy<fluence_faas::TomlFaaSConfig> = Lazy::new(|| {
let mut arguments_passing_config =
fluence_faas::TomlFaaSConfig::load("./tests/wasm_tests/arguments_passing/Config.toml")
@ -50,9 +53,9 @@ pub fn get_interfaces() {
let string_type_outputs = vec![IType::String];
let string_type_sign = fluence_faas::FaaSFunctionSignature {
name: "string_type",
arguments: &string_type_arguments,
outputs: &string_type_outputs,
name: Rc::new(String::from("string_type")),
arguments: Rc::new(string_type_arguments),
outputs: Rc::new(string_type_outputs),
};
let bytearray_type_arguments = vec![fluence_faas::IFunctionArg {
@ -62,9 +65,9 @@ pub fn get_interfaces() {
let bytearray_type_outputs = vec![IType::Array(Box::new(IType::U8))];
let bytearray_type_sign = fluence_faas::FaaSFunctionSignature {
name: "bytearray_type",
arguments: &bytearray_type_arguments,
outputs: &bytearray_type_outputs,
name: Rc::new(String::from("bytearray_type")),
arguments: Rc::new(bytearray_type_arguments),
outputs: Rc::new(bytearray_type_outputs),
};
let i32_type_arguments = vec![fluence_faas::IFunctionArg {
@ -74,9 +77,9 @@ pub fn get_interfaces() {
let i32_type_outputs = vec![IType::S32];
let i32_type_sign = fluence_faas::FaaSFunctionSignature {
name: "i32_type",
arguments: &i32_type_arguments,
outputs: &i32_type_outputs,
name: Rc::new(String::from("i32_type")),
arguments: Rc::new(i32_type_arguments),
outputs: Rc::new(i32_type_outputs),
};
let i64_type_arguments = vec![fluence_faas::IFunctionArg {
@ -87,9 +90,9 @@ pub fn get_interfaces() {
let i64_type_outputs = vec![IType::S64];
let i64_type_sign = fluence_faas::FaaSFunctionSignature {
name: "i64_type",
arguments: &i64_type_arguments,
outputs: &i64_type_outputs,
name: Rc::new(String::from("i64_type")),
arguments: Rc::new(i64_type_arguments),
outputs: Rc::new(i64_type_outputs),
};
let u32_type_arguments = vec![fluence_faas::IFunctionArg {
@ -99,9 +102,9 @@ pub fn get_interfaces() {
let u32_type_outputs = vec![IType::U32];
let u32_type_sign = fluence_faas::FaaSFunctionSignature {
name: "u32_type",
arguments: &u32_type_arguments,
outputs: &u32_type_outputs,
name: Rc::new(String::from("u32_type")),
arguments: Rc::new(u32_type_arguments),
outputs: Rc::new(u32_type_outputs),
};
let u64_type_arguments = vec![fluence_faas::IFunctionArg {
@ -111,9 +114,9 @@ pub fn get_interfaces() {
let u64_type_outputs = vec![IType::U64];
let u64_type_sign = fluence_faas::FaaSFunctionSignature {
name: "u64_type",
arguments: &u64_type_arguments,
outputs: &u64_type_outputs,
name: Rc::new(String::from("u64_type")),
arguments: Rc::new(u64_type_arguments),
outputs: Rc::new(u64_type_outputs),
};
let f32_type_arguments = vec![fluence_faas::IFunctionArg {
@ -123,9 +126,9 @@ pub fn get_interfaces() {
let f32_type_outputs = vec![IType::F32];
let f32_type_sign = fluence_faas::FaaSFunctionSignature {
name: "f32_type",
arguments: &f32_type_arguments,
outputs: &f32_type_outputs,
name: Rc::new(String::from("f32_type")),
arguments: Rc::new(f32_type_arguments),
outputs: Rc::new(f32_type_outputs),
};
let f64_type_arguments = vec![fluence_faas::IFunctionArg {
@ -135,18 +138,18 @@ pub fn get_interfaces() {
let f64_type_outputs = vec![IType::F64];
let f64_type_sign = fluence_faas::FaaSFunctionSignature {
name: "f64_type",
arguments: &f64_type_arguments,
outputs: &f64_type_outputs,
name: Rc::new(String::from("f64_type")),
arguments: Rc::new(f64_type_arguments),
outputs: Rc::new(f64_type_outputs),
};
let empty_type_arguments = vec![];
let empty_type_outputs = vec![IType::String];
let empty_type_sign = fluence_faas::FaaSFunctionSignature {
name: "empty_type",
arguments: &empty_type_arguments,
outputs: &empty_type_outputs,
name: Rc::new(String::from("empty_type")),
arguments: Rc::new(empty_type_arguments),
outputs: Rc::new(empty_type_outputs),
};
let bool_type_arguments = vec![fluence_faas::IFunctionArg {
@ -156,9 +159,9 @@ pub fn get_interfaces() {
let bool_type_outputs = vec![IType::I32];
let bool_type_sign = fluence_faas::FaaSFunctionSignature {
name: "bool_type",
arguments: &bool_type_arguments,
outputs: &bool_type_outputs,
name: Rc::new(String::from("bool_type")),
arguments: Rc::new(bool_type_arguments),
outputs: Rc::new(bool_type_outputs),
};
let all_types_arguments = vec![
@ -214,9 +217,9 @@ pub fn get_interfaces() {
let all_types_outputs = vec![IType::Array(Box::new(IType::U8))];
let all_types_sign = fluence_faas::FaaSFunctionSignature {
name: "all_types",
arguments: &all_types_arguments,
outputs: &all_types_outputs,
name: Rc::new(String::from("all_types")),
arguments: Rc::new(all_types_arguments),
outputs: Rc::new(all_types_outputs),
};
let functions = vec![
@ -282,79 +285,46 @@ pub fn all_types() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"all_types",
json!({
"arg_0": 0,
"arg_1": 1,
"arg_2": 2,
"arg_3": 3,
"arg_4": 4,
"arg_5": 5,
"arg_6": 6,
"arg_7": 7,
"arg_8": 8.1,
"arg_9": 9.1,
"arg_10": "fluence",
"arg_11": vec! [0x13, 0x37],
}),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke all_types: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(
vec![
0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0,
0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 99,
101, 19, 55, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7,
0, 0, 0, 0, 0, 0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108,
117, 101, 110, 99, 101, 19, 55
]
.iter()
.map(|v| IValue::U8(*v))
.collect::<Vec<_>>()
)]
);
let right_result = json!([
0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0,
65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 99, 101, 19, 55,
0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0,
65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 99, 101, 19, 55
]);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"all_types",
json!([
0,
1,
2,
3,
4,
5,
6,
7,
8.1,
9.1,
"fluence",
vec![0x13, 0x37]
]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke all_types: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(
vec![
0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0,
0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 99,
101, 19, 55, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7,
0, 0, 0, 0, 0, 0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108,
117, 101, 110, 99, 101, 19, 55
]
.iter()
.map(|v| IValue::U8(*v))
.collect::<Vec<_>>()
)]
);
let faas_arg = json!({
"arg_0": 0,
"arg_1": 1,
"arg_2": 2,
"arg_3": 3,
"arg_4": 4,
"arg_5": 5,
"arg_6": 6,
"arg_7": 7,
"arg_8": 8.1,
"arg_9": 9.1,
"arg_10": "fluence",
"arg_11": vec! [0x13, 0x37],
});
let result3 = call_faas!(faas, "arguments_passing_pure", "all_types", faas_arg);
assert_eq!(result3, right_result);
let faas_arg = json!([
0,
1,
2,
3,
4,
5,
6,
7,
8.1,
9.1,
"fluence",
vec![0x13, 0x37]
]);
let result4 = call_faas!(faas, "arguments_passing_pure", "all_types", faas_arg);
assert_eq!(result4, right_result);
}
#[test]
@ -378,25 +348,17 @@ pub fn i32_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"i32_type",
json!({ "arg": 1 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e));
assert_eq!(result3, vec![IValue::S32(3)]);
let right_result = json!(3);
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"i32_type",
json!({ "arg": 1 })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"i32_type",
json!(1),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e));
assert_eq!(result4, vec![IValue::S32(3)]);
let result4 = call_faas!(faas, "arguments_passing_pure", "i32_type", json!(1));
assert_eq!(result4, right_result);
}
#[test]
@ -420,25 +382,17 @@ pub fn i64_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"i64_type",
json!({ "arg": 1 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i64_type: {:?}", e));
assert_eq!(result3, vec![IValue::S64(3)]);
let right_result = json!(3);
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"i64_type",
json!({ "arg": 1 })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"i64_type",
json!(1),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i64_type: {:?}", e));
assert_eq!(result4, vec![IValue::S64(3)]);
let result4 = call_faas!(faas, "arguments_passing_pure", "i64_type", json!(1));
assert_eq!(result4, right_result);
}
#[test]
@ -462,25 +416,17 @@ pub fn u32_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"u32_type",
json!({ "arg": 1 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u32_type: {:?}", e));
assert_eq!(result3, vec![IValue::U32(3)]);
let right_result = json!(3);
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"u32_type",
json!({ "arg": 1 })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"u32_type",
json!(1),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u32_type: {:?}", e));
assert_eq!(result4, vec![IValue::U32(3)]);
let result4 = call_faas!(faas, "arguments_passing_pure", "u32_type", json!(1));
assert_eq!(result4, right_result);
}
#[test]
@ -504,25 +450,17 @@ pub fn u64_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"u64_type",
json!({ "arg": 1 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u64_type: {:?}", e));
assert_eq!(result3, vec![IValue::U64(3)]);
let right_result = json!(3);
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"u64_type",
json!({ "arg": 1 })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"u64_type",
json!(1),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u64_type: {:?}", e));
assert_eq!(result4, vec![IValue::U64(3)]);
let result4 = call_faas!(faas, "arguments_passing_pure", "u64_type", json!(1));
assert_eq!(result4, right_result);
}
#[test]
@ -546,25 +484,17 @@ pub fn f32_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"f32_type",
json!({ "arg": 1.0 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f32_type: {:?}", e));
assert_eq!(result3, vec![IValue::F32(3.0)]);
let right_result = json!(3.0);
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"f32_type",
json!({ "arg": 1.0 })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"f32_type",
json!(1.0),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f32_type: {:?}", e));
assert_eq!(result4, vec![IValue::F32(3.0)]);
let result4 = call_faas!(faas, "arguments_passing_pure", "f32_type", json!(1.0));
assert_eq!(result4, right_result);
}
#[test]
@ -588,25 +518,17 @@ pub fn f64_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"f64_type",
json!({ "arg": 1.0 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e));
assert_eq!(result3, vec![IValue::F64(3.0)]);
let right_result = json!(3.0);
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"f64_type",
json!({ "arg": 1.0 })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"f64_type",
json!(1.0),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e));
assert_eq!(result4, vec![IValue::F64(3.0)]);
let result4 = call_faas!(faas, "arguments_passing_pure", "f64_type", json!(1.0));
assert_eq!(result4, right_result);
}
#[test]
@ -630,35 +552,22 @@ pub fn string_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"string_type",
json!({ "arg": "Fluence" }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke string_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::String(String::from(
"Fluence_Fluence_Fluence_Fluence"
))]
let right_result = json!("Fluence_Fluence_Fluence_Fluence");
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"string_type",
json!({ "arg": "Fluence" })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"string_type",
json!("Fluence"),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke string_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::String(String::from(
"Fluence_Fluence_Fluence_Fluence"
))]
let result4 = call_faas!(
faas,
"arguments_passing_pure",
"string_type",
json!("Fluence")
);
assert_eq!(result4, right_result);
}
#[test]
@ -682,41 +591,22 @@ pub fn bytearray_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"bytearray_type",
json!({ "arg": [0x13, 0x37] }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::U8(0x13),
IValue::U8(0x37),
IValue::U8(1),
IValue::U8(1)
])]
let right_result = json!([0x13, 0x37, 1, 1]);
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"bytearray_type",
json!({ "arg": [0x13, 0x37] })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"bytearray_type",
json!([[0x13, 0x37]]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::U8(0x13),
IValue::U8(0x37),
IValue::U8(1),
IValue::U8(1)
])]
let result4 = call_faas!(
faas,
"arguments_passing_pure",
"bytearray_type",
json!([[0x13, 0x37]])
);
assert_eq!(result4, right_result);
}
#[test]
@ -740,25 +630,17 @@ pub fn bool_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"bool_type",
json!({ "arg": 0 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bool_type: {:?}", e));
assert_eq!(result3, vec![IValue::I32(1)]);
let right_result = json!(1);
let result3 = call_faas!(
faas,
"arguments_passing_pure",
"bool_type",
json!({ "arg": 0 })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arguments_passing_pure",
"bool_type",
json!(0),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bool_type: {:?}", e));
assert_eq!(result4, vec![IValue::I32(1)]);
let result4 = call_faas!(faas, "arguments_passing_pure", "bool_type", json!(0));
assert_eq!(result4, right_result);
}
#[test]
@ -766,35 +648,15 @@ pub fn empty_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas
.call_with_json(
"arguments_passing_pure",
"empty_type",
json!({}),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(result1, vec![IValue::String(String::from("success"))]);
let right_result = json!("success");
let result1 = call_faas!(faas, "arguments_passing_pure", "empty_type", json!({}));
assert_eq!(result1, right_result);
let result2 = faas
.call_with_json(
"arguments_passing_pure",
"empty_type",
json!([]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(result2, vec![IValue::String(String::from("success"))]);
let result2 = call_faas!(faas, "arguments_passing_pure", "empty_type", json!([]));
assert_eq!(result2, right_result);
let result3 = faas
.call_with_json(
"arguments_passing_pure",
"empty_type",
json!([]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(result3, vec![IValue::String(String::from("success"))]);
let result3 = call_faas!(faas, "arguments_passing_pure", "empty_type", json!([]));
assert_eq!(result3, right_result);
let result4 = faas.call_with_json(
"arguments_passing_pure",

@ -14,13 +14,16 @@
* limitations under the License.
*/
mod utils;
use fluence_faas::FluenceFaaS;
use fluence_faas::IValue;
use fluence_faas::IType;
use once_cell::sync::Lazy;
use serde_json::json;
use std::rc::Rc;
static ARG_CONFIG: Lazy<fluence_faas::TomlFaaSConfig> = Lazy::new(|| {
let mut arrays_passing_config =
fluence_faas::TomlFaaSConfig::load("./tests/wasm_tests/arrays_passing/Config.toml")
@ -48,9 +51,9 @@ pub fn get_interfaces() {
let byte_type_outputs = vec![IType::Array(Box::new(IType::U8))];
let byte_type_sign = fluence_faas::FaaSFunctionSignature {
name: "byte_type",
arguments: &byte_type_arguments,
outputs: &byte_type_outputs,
name: Rc::new(String::from("byte_type")),
arguments: Rc::new(byte_type_arguments),
outputs: Rc::new(byte_type_outputs),
};
let inner_arrays_1_arguments = vec![fluence_faas::IFunctionArg {
@ -64,9 +67,9 @@ pub fn get_interfaces() {
))))];
let inner_arrays_1_sign = fluence_faas::FaaSFunctionSignature {
name: "inner_arrays_1",
arguments: &inner_arrays_1_arguments,
outputs: &inner_arrays_1_outputs,
name: Rc::new(String::from("inner_arrays_1")),
arguments: Rc::new(inner_arrays_1_arguments),
outputs: Rc::new(inner_arrays_1_outputs),
};
// save it until record will be refactored in the future
@ -95,9 +98,9 @@ pub fn get_interfaces() {
let string_type_outputs = vec![IType::Array(Box::new(IType::String))];
let string_type_sign = fluence_faas::FaaSFunctionSignature {
name: "string_type",
arguments: &string_type_arguments,
outputs: &string_type_outputs,
name: Rc::new(String::from("string_type")),
arguments: Rc::new(string_type_arguments),
outputs: Rc::new(string_type_outputs),
};
let i32_type_arguments = vec![fluence_faas::IFunctionArg {
@ -107,9 +110,9 @@ pub fn get_interfaces() {
let i32_type_outputs = vec![IType::Array(Box::new(IType::S32))];
let i32_type_sign = fluence_faas::FaaSFunctionSignature {
name: "i32_type",
arguments: &i32_type_arguments,
outputs: &i32_type_outputs,
name: Rc::new(String::from("i32_type")),
arguments: Rc::new(i32_type_arguments),
outputs: Rc::new(i32_type_outputs),
};
let i64_type_arguments = vec![fluence_faas::IFunctionArg {
@ -120,9 +123,9 @@ pub fn get_interfaces() {
let i64_type_outputs = vec![IType::Array(Box::new(IType::S64))];
let i64_type_sign = fluence_faas::FaaSFunctionSignature {
name: "i64_type",
arguments: &i64_type_arguments,
outputs: &i64_type_outputs,
name: Rc::new(String::from("i64_type")),
arguments: Rc::new(i64_type_arguments),
outputs: Rc::new(i64_type_outputs),
};
let u32_type_arguments = vec![fluence_faas::IFunctionArg {
@ -132,9 +135,9 @@ pub fn get_interfaces() {
let u32_type_outputs = vec![IType::Array(Box::new(IType::U32))];
let u32_type_sign = fluence_faas::FaaSFunctionSignature {
name: "u32_type",
arguments: &u32_type_arguments,
outputs: &u32_type_outputs,
name: Rc::new(String::from("u32_type")),
arguments: Rc::new(u32_type_arguments),
outputs: Rc::new(u32_type_outputs),
};
let u64_type_arguments = vec![fluence_faas::IFunctionArg {
@ -144,9 +147,9 @@ pub fn get_interfaces() {
let u64_type_outputs = vec![IType::Array(Box::new(IType::U64))];
let u64_type_sign = fluence_faas::FaaSFunctionSignature {
name: "u64_type",
arguments: &u64_type_arguments,
outputs: &u64_type_outputs,
name: Rc::new(String::from("u64_type")),
arguments: Rc::new(u64_type_arguments),
outputs: Rc::new(u64_type_outputs),
};
let f32_type_arguments = vec![fluence_faas::IFunctionArg {
@ -156,9 +159,9 @@ pub fn get_interfaces() {
let f32_type_outputs = vec![IType::Array(Box::new(IType::F32))];
let f32_type_sign = fluence_faas::FaaSFunctionSignature {
name: "f32_type",
arguments: &f32_type_arguments,
outputs: &f32_type_outputs,
name: Rc::new(String::from("f32_type")),
arguments: Rc::new(f32_type_arguments),
outputs: Rc::new(f32_type_outputs),
};
let f64_type_arguments = vec![fluence_faas::IFunctionArg {
@ -168,18 +171,18 @@ pub fn get_interfaces() {
let f64_type_outputs = vec![IType::Array(Box::new(IType::F64))];
let f64_type_sign = fluence_faas::FaaSFunctionSignature {
name: "f64_type",
arguments: &f64_type_arguments,
outputs: &f64_type_outputs,
name: Rc::new(String::from("f64_type")),
arguments: Rc::new(f64_type_arguments),
outputs: Rc::new(f64_type_outputs),
};
let empty_type_arguments = vec![];
let empty_type_outputs = vec![IType::Array(Box::new(IType::String))];
let empty_type_sign = fluence_faas::FaaSFunctionSignature {
name: "empty_type",
arguments: &empty_type_arguments,
outputs: &empty_type_outputs,
name: Rc::new(String::from("empty_type")),
arguments: Rc::new(empty_type_arguments),
outputs: Rc::new(empty_type_outputs),
};
/*
@ -227,12 +230,12 @@ pub fn get_interfaces() {
let pure_module_functions: HashSet<_> = pure_module_interface
.function_signatures
.iter()
.filter(|f| f.name != "inner_arrays_2")
.filter(|f| f.name.as_str() != "inner_arrays_2")
.collect();
let effector_module_functions: HashSet<_> = effector_module_interface
.function_signatures
.iter()
.filter(|f| f.name != "inner_arrays_2")
.filter(|f| f.name.as_str() != "inner_arrays_2")
.collect();
let functions: HashSet<_> = functions.iter().collect();
@ -246,6 +249,8 @@ pub fn i32_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let right_result = json!([0, 1, 2, 3, 4, 0, 2]);
let result1 = faas
.call_with_json(
"arrays_passing_pure",
@ -254,18 +259,7 @@ pub fn i32_type() {
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e));
assert_eq!(
result1,
vec![IValue::Array(vec![
IValue::S32(0),
IValue::S32(1),
IValue::S32(2),
IValue::S32(3),
IValue::S32(4),
IValue::S32(0),
IValue::S32(2)
])]
);
assert_eq!(result1, right_result);
let result2 = faas
.call_with_json(
@ -275,19 +269,9 @@ pub fn i32_type() {
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e));
assert_eq!(
result2,
vec![IValue::Array(vec![
IValue::S32(0),
IValue::S32(1),
IValue::S32(2),
IValue::S32(3),
IValue::S32(4),
IValue::S32(0),
IValue::S32(2)
])]
);
assert_eq!(result2, right_result);
let right_result = json!([1, 0, 1, 2, 3, 4, 0, 2]);
let result3 = faas
.call_with_json(
"arrays_passing_pure",
@ -296,19 +280,7 @@ pub fn i32_type() {
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::S32(1),
IValue::S32(0),
IValue::S32(1),
IValue::S32(2),
IValue::S32(3),
IValue::S32(4),
IValue::S32(0),
IValue::S32(2)
])]
);
assert_eq!(result3, right_result);
}
#[test]
@ -322,6 +294,8 @@ pub fn i64_type() {
let result2 = faas.call_with_json("arrays_passing_pure", "i64_type", json!([]), <_>::default());
assert!(result2.is_err());
let right_result = json!([1, 0, 1, 2, 3, 4, 1, 1]);
let result3 = faas
.call_with_json(
"arrays_passing_pure",
@ -330,19 +304,7 @@ pub fn i64_type() {
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i64_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::S64(1),
IValue::S64(0),
IValue::S64(1),
IValue::S64(2),
IValue::S64(3),
IValue::S64(4),
IValue::S64(1),
IValue::S64(1)
])]
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
@ -352,19 +314,7 @@ pub fn i64_type() {
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i64_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::S64(1),
IValue::S64(0),
IValue::S64(1),
IValue::S64(2),
IValue::S64(3),
IValue::S64(4),
IValue::S64(1),
IValue::S64(1)
])]
);
assert_eq!(result4, right_result);
}
#[test]
@ -378,43 +328,18 @@ pub fn u32_type() {
let result2 = faas.call_with_json("arrays_passing_pure", "u32_type", json!([]), <_>::default());
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"u32_type",
json!({ "arg": [1] }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u32_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::U32(1),
IValue::U32(0),
IValue::U32(13),
IValue::U32(37),
IValue::U32(2),
])]
);
let right_result = json!([1, 0, 13, 37, 2]);
let result4 = faas
.call_with_json(
"arrays_passing_pure",
"u32_type",
json!([[1]]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u32_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::U32(1),
IValue::U32(0),
IValue::U32(13),
IValue::U32(37),
IValue::U32(2),
])]
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"u32_type",
json!({ "arg": [1] })
);
assert_eq!(result3, right_result);
let result4 = call_faas!(faas, "arrays_passing_pure", "u32_type", json!([[1]]));
assert_eq!(result4, right_result);
}
#[test]
@ -428,47 +353,18 @@ pub fn u64_type() {
let result2 = faas.call_with_json("arrays_passing_pure", "u64_type", json!([]), <_>::default());
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"u64_type",
json!({ "arg": [1] }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u64_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::U64(1),
IValue::U64(0),
IValue::U64(1),
IValue::U64(2),
IValue::U64(3),
IValue::U64(4),
IValue::U64(2),
])]
);
let right_result = json!([1, 0, 1, 2, 3, 4, 2]);
let result4 = faas
.call_with_json(
"arrays_passing_pure",
"u64_type",
json!([[1]]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u64_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::U64(1),
IValue::U64(0),
IValue::U64(1),
IValue::U64(2),
IValue::U64(3),
IValue::U64(4),
IValue::U64(2),
])]
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"u64_type",
json!({ "arg": [1] })
);
assert_eq!(result3, right_result);
let result4 = call_faas!(faas, "arrays_passing_pure", "u64_type", json!([[1]]));
assert_eq!(result4, right_result);
}
#[test]
@ -482,41 +378,18 @@ pub fn f64_type_() {
let result2 = faas.call_with_json("arrays_passing_pure", "f32_type", json!([]), <_>::default());
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"f64_type",
json!({ "arg": [1.0] }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::F64(1.0),
IValue::F64(0.0),
IValue::F64(13.37),
IValue::F64(1.0),
])]
);
let right_result = json!([1.0, 0.0, 13.37, 1.0]);
let result4 = faas
.call_with_json(
"arrays_passing_pure",
"f64_type",
json!([[1.0]]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::F64(1.0),
IValue::F64(0.0),
IValue::F64(13.37),
IValue::F64(1.0),
])]
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"f64_type",
json!({ "arg": [1.0] })
);
assert_eq!(result3, right_result);
let result4 = call_faas!(faas, "arrays_passing_pure", "f64_type", json!([[1.0]]));
assert_eq!(result4, right_result);
}
#[test]
@ -531,25 +404,18 @@ pub fn f64_type() {
let result2 = faas.call_with_json("arrays_passing_pure", "f64_type", json!([]), <_>::default());
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"f64_type",
json!({ "arg": 1.0 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e));
assert_eq!(result3, vec![IValue::F64(3.0)]);
let right_result = json!([3.0]);
let result4 = faas
.call_with_json(
"arrays_passing_pure",
"f64_type",
json!(1.0),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e));
assert_eq!(result4, vec![IValue::F64(3.0)]);
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"f64_type",
json!({ "arg": 1.0 })
);
assert_eq!(result3, right_result);
let result4 = call_faas!(faas, "arrays_passing_pure", "f64_type", json!(1.0));
assert_eq!(result4, right_result);
}
#[test]
@ -573,41 +439,23 @@ pub fn string_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"string_type",
json!({ "arg": ["Fluence"] }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke string_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::String(String::from("Fluence")),
IValue::String(String::from("fce")),
IValue::String(String::from("from effector")),
IValue::String(String::from("test")),
])]
);
let right_result = json!(["Fluence", "fce", "from effector", "test"]);
let result4 = faas
.call_with_json(
"arrays_passing_pure",
"string_type",
json!([["Fluence"]]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke string_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::String(String::from("Fluence")),
IValue::String(String::from("fce")),
IValue::String(String::from("from effector")),
IValue::String(String::from("test")),
])]
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"string_type",
json!({ "arg": ["Fluence"] })
);
assert_eq!(result3, right_result);
let result4 = call_faas!(
faas,
"arrays_passing_pure",
"string_type",
json!([["Fluence"]])
);
assert_eq!(result4, right_result);
}
#[test]
@ -631,43 +479,22 @@ pub fn byte_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"byte_type",
json!({ "arg": [0x13, 0x37] }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::U8(0x13),
IValue::U8(0x37),
IValue::U8(0),
IValue::U8(1),
IValue::U8(2),
])]
let right_result = json!([0x13, 0x37, 0, 1, 2]);
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"byte_type",
json!({ "arg": [0x13, 0x37] })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arrays_passing_pure",
"byte_type",
json!([[0x13, 0x37]]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::U8(0x13),
IValue::U8(0x37),
IValue::U8(0),
IValue::U8(1),
IValue::U8(2),
])]
let result4 = call_faas!(
faas,
"arrays_passing_pure",
"byte_type",
json!([[0x13, 0x37]])
);
assert_eq!(result4, right_result);
}
#[test]
@ -691,83 +518,30 @@ pub fn inner_arrays_1_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"inner_arrays_1",
json!({ "arg": [[[[0x13, 0x37]]]] }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::U8(0x13),
IValue::U8(0x37),
])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![IValue::U8(
0
),])])]),
IValue::Array(vec![]),
IValue::Array(vec![IValue::Array(vec![])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::U8(1),
IValue::U8(2),
IValue::U8(3),
IValue::U8(4),
IValue::U8(5),
IValue::U8(6),
IValue::U8(7),
IValue::U8(8),
IValue::U8(9),
IValue::U8(10),
])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![IValue::U8(
2
),])])]),
]),]
let right_result = json!([
[[[0x13, 0x37]]],
[[[0]]],
[],
[[]],
[[[]]],
[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]],
[[[2]]]
]);
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"inner_arrays_1",
json!({ "arg": [[[[0x13, 0x37]]]] })
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
"arrays_passing_pure",
"inner_arrays_1",
json!([[[[[0x13, 0x37]]]]]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::U8(0x13),
IValue::U8(0x37),
])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![IValue::U8(
0
),])])]),
IValue::Array(vec![]),
IValue::Array(vec![IValue::Array(vec![])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::U8(1),
IValue::U8(2),
IValue::U8(3),
IValue::U8(4),
IValue::U8(5),
IValue::U8(6),
IValue::U8(7),
IValue::U8(8),
IValue::U8(9),
IValue::U8(10),
])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![IValue::U8(
2
),])])]),
]),]
let result4 = call_faas!(
faas,
"arrays_passing_pure",
"inner_arrays_1",
json!([[[[[0x13, 0x37]]]]])
);
assert_eq!(result4, right_result);
}
#[test]
@ -791,133 +565,55 @@ pub fn inner_arrays_2_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"inner_arrays_2",
json!({ "arg": [[[[[0, [[1]]]]]]] }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::Record(
fce::vec1::Vec1::new(vec![
IValue::S32(0),
IValue::Array(vec![IValue::Array(vec![IValue::U8(1)])])
])
.unwrap()
)
])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::Record(
fce::vec1::Vec1::new(vec![
IValue::S32(0),
IValue::Array(vec![IValue::Array(vec![IValue::U8(1)])])
])
.unwrap()
),
IValue::Record(
fce::vec1::Vec1::new(vec![IValue::S32(0), IValue::Array(vec![]),]).unwrap()
)
])])]),
IValue::Array(vec![]),
IValue::Array(vec![IValue::Array(vec![])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::Record(
fce::vec1::Vec1::new(vec![
IValue::S32(0),
IValue::Array(vec![IValue::Array(vec![
IValue::U8(1),
IValue::U8(2),
IValue::U8(3),
IValue::U8(4),
])])
])
.unwrap()
),
])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::Record(
fce::vec1::Vec1::new(vec![
IValue::S32(1),
IValue::Array(vec![IValue::Array(vec![IValue::U8(2)])])
])
.unwrap()
),
IValue::Record(
fce::vec1::Vec1::new(vec![IValue::S32(0), IValue::Array(vec![])]).unwrap()
)
])])]),
]),]
);
let right_result = json!([
[[[{
"field_0": 0,
"field_1": [[1]]
}]]],
[[[
{
"field_0": 0,
"field_1": [[1]]
},
{
"field_0": 0,
"field_1": []
},
]]],
[],
[[]],
[[[]]],
[[[{
"field_0": 0,
"field_1": [[1,2,3,4]]
}]]],
[[[
{
"field_0": 1,
"field_1": [[2]]
},
{
"field_0": 0,
"field_1": []
},
]]],
]);
let result4 = faas
.call_with_json(
"arrays_passing_pure",
"inner_arrays_2",
json!([[[[[{"field_0": 0, "field_1": [[1]]}]]]]]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::Record(
fce::vec1::Vec1::new(vec![
IValue::S32(0),
IValue::Array(vec![IValue::Array(vec![IValue::U8(1)])])
])
.unwrap()
)
])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::Record(
fce::vec1::Vec1::new(vec![
IValue::S32(0),
IValue::Array(vec![IValue::Array(vec![IValue::U8(1)])])
])
.unwrap()
),
IValue::Record(
fce::vec1::Vec1::new(vec![IValue::S32(0), IValue::Array(vec![]),]).unwrap()
)
])])]),
IValue::Array(vec![]),
IValue::Array(vec![IValue::Array(vec![])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::Record(
fce::vec1::Vec1::new(vec![
IValue::S32(0),
IValue::Array(vec![IValue::Array(vec![
IValue::U8(1),
IValue::U8(2),
IValue::U8(3),
IValue::U8(4),
])])
])
.unwrap()
),
])])]),
IValue::Array(vec![IValue::Array(vec![IValue::Array(vec![
IValue::Record(
fce::vec1::Vec1::new(vec![
IValue::S32(1),
IValue::Array(vec![IValue::Array(vec![IValue::U8(2)])])
])
.unwrap()
),
IValue::Record(
fce::vec1::Vec1::new(vec![IValue::S32(0), IValue::Array(vec![])]).unwrap()
)
])])]),
]),]
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"inner_arrays_2",
json!({ "arg": [[[[[0, [[1]]]]]]] })
);
assert_eq!(result3, right_result);
let result4 = call_faas!(
faas,
"arrays_passing_pure",
"inner_arrays_2",
json!([[[[[{"field_0": 0, "field_1": [[1]]}]]]]])
);
assert_eq!(result4, right_result);
}
#[test]
@ -942,20 +638,18 @@ pub fn bool_type() {
);
assert!(result2.is_err());
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"bool_type",
json!({ "arg": 0 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bool_type: {:?}", e));
assert_eq!(result3, vec![IValue::I32(1)]);
let right_result = json!(1);
let result4 = faas
.call_with_json("arrays_passing_pure", "bool_type", json!(0), <_>::default())
.unwrap_or_else(|e| panic!("can't invoke bool_type: {:?}", e));
assert_eq!(result4, vec![IValue::I32(1)]);
let result3 = call_faas!(
faas,
"arrays_passing_pure",
"bool_type",
json!({ "arg": 0 })
);
assert_eq!(result3, right_result);
let result4 = call_faas!(faas, "arrays_passing_pure", "bool_type", json!(0));
assert_eq!(result4, right_result);
}
#[test]
@ -963,50 +657,15 @@ pub fn empty_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas
.call_with_json(
"arrays_passing_pure",
"empty_type",
json!({}),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(
result1,
vec![IValue::Array(vec![IValue::String(String::from(
"from effector"
))])]
);
let right_result = json!(["from effector"]);
let result1 = call_faas!(faas, "arrays_passing_pure", "empty_type", json!({}));
assert_eq!(result1, right_result);
let result2 = faas
.call_with_json(
"arrays_passing_pure",
"empty_type",
json!([]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(
result2,
vec![IValue::Array(vec![IValue::String(String::from(
"from effector"
))])]
);
let result2 = call_faas!(faas, "arrays_passing_pure", "empty_type", json!([]));
assert_eq!(result2, right_result);
let result3 = faas
.call_with_json(
"arrays_passing_pure",
"empty_type",
json!([]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(
result3,
vec![IValue::Array(vec![IValue::String(String::from(
"from effector"
))])]
);
let result3 = call_faas!(faas, "arrays_passing_pure", "empty_type", json!([]));
assert_eq!(result3, right_result);
let result4 = faas.call_with_json(
"arrays_passing_pure",

@ -20,6 +20,8 @@ use fluence_faas::IValue;
use pretty_assertions::assert_eq;
use std::rc::Rc;
#[test]
pub fn greeting() {
let greeting_config_path = "../examples/greeting/Config.toml";
@ -79,9 +81,9 @@ pub fn get_interfaces() {
let output_types = vec![fluence_faas::IType::String];
let greeting_sign = fluence_faas::FaaSFunctionSignature {
name: "greeting",
arguments: &arguments,
outputs: &output_types,
name: Rc::new(String::from("greeting")),
arguments: Rc::new(arguments),
outputs: Rc::new(output_types),
};
let record_types = std::collections::HashMap::new();

@ -38,6 +38,22 @@ pub fn records() {
.call_with_ivalues("records_pure", "invoke", &[], <_>::default())
.unwrap_or_else(|e| panic!("can't invoke pure: {:?}", e));
let right_result = json!({
"field_0": 1,
"field_1": 1,
"field_2": 2,
"field_3": 3,
"field_4": 4,
"field_5": 5,
"field_6": 6,
"field_7": 7,
"field_8": 8,
"field_9": 9.0,
"field_10": 10.0,
"field_11": "field_11",
"field_12": [0x13, 0x37],
});
assert_eq!(
result1,
vec![IValue::Record(
@ -86,27 +102,7 @@ pub fn records() {
)
.unwrap_or_else(|e| panic!("can't invoke pure: {:?}", e));
assert_eq!(
result2,
vec![IValue::Record(
wasmer_wit::vec1::Vec1::new(vec![
IValue::I32(1),
IValue::S8(1),
IValue::S16(2),
IValue::S32(3),
IValue::S64(4),
IValue::U8(5),
IValue::U16(6),
IValue::U32(7),
IValue::U64(8),
IValue::F32(9.0),
IValue::F64(10.0),
IValue::String(String::from("field_11")),
IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
])
.unwrap()
)]
);
assert_eq!(result2, right_result);
let result3 = faas
.call_with_json(
@ -120,27 +116,7 @@ pub fn records() {
)
.unwrap_or_else(|e| panic!("can't invoke pure: {:?}", e));
assert_eq!(
result3,
vec![IValue::Record(
wasmer_wit::vec1::Vec1::new(vec![
IValue::I32(1),
IValue::S8(1),
IValue::S16(2),
IValue::S32(3),
IValue::S64(4),
IValue::U8(5),
IValue::U16(6),
IValue::U32(7),
IValue::U64(8),
IValue::F32(9.0),
IValue::F64(10.0),
IValue::String(String::from("field_11")),
IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
])
.unwrap()
)]
);
assert_eq!(result3, right_result);
let result4 = faas
.call_with_json(
@ -166,27 +142,7 @@ pub fn records() {
)
.unwrap_or_else(|e| panic!("can't invoke pure: {:?}", e));
assert_eq!(
result4,
vec![IValue::Record(
wasmer_wit::vec1::Vec1::new(vec![
IValue::I32(1),
IValue::S8(1),
IValue::S16(2),
IValue::S32(3),
IValue::S64(4),
IValue::U8(5),
IValue::U16(6),
IValue::U32(7),
IValue::U64(8),
IValue::F32(9.0),
IValue::F64(10.0),
IValue::String(String::from("field_11")),
IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
])
.unwrap()
)]
);
assert_eq!(result4, right_result);
let result5 = faas
.call_with_json(
@ -197,27 +153,7 @@ pub fn records() {
)
.unwrap_or_else(|e| panic!("can't invoke pure: {:?}", e));
assert_eq!(
result5,
vec![IValue::Record(
wasmer_wit::vec1::Vec1::new(vec![
IValue::I32(1),
IValue::S8(1),
IValue::S16(2),
IValue::S32(3),
IValue::S64(4),
IValue::U8(5),
IValue::U16(6),
IValue::U32(7),
IValue::U64(8),
IValue::F32(9.0),
IValue::F64(10.0),
IValue::String(String::from("field_11")),
IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
])
.unwrap()
)]
);
assert_eq!(result5, right_result);
}
#[test]
@ -258,22 +194,19 @@ fn inner_records() {
)
.unwrap_or_else(|e| panic!("can't invoke inner_records_pure: {:?}", e));
assert_eq!(
result,
vec![IValue::Record(
wasmer_wit::vec1::Vec1::new(vec![
IValue::Record(wasmer_wit::vec1::Vec1::new(vec![IValue::S32(1),]).unwrap()),
IValue::Record(
wasmer_wit::vec1::Vec1::new(vec![
IValue::S32(1),
IValue::String(String::new()),
IValue::Array(vec![IValue::U8(1)]),
IValue::Record(wasmer_wit::vec1::Vec1::new(vec![IValue::S32(1),]).unwrap())
])
.unwrap()
),
])
.unwrap()
)]
);
let right_result = json!({
"test_record_0": {
"field_0": 1
},
"test_record_1": {
"field_0": 1,
"field_1": "",
"field_2": vec![1],
"test_record_0": {
"field_0": 1
}
}
});
assert_eq!(result, right_result);
}

@ -0,0 +1,24 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#[macro_export]
macro_rules! call_faas {
($faas:expr, $module_name:expr, $func_name:expr, $args:expr) => {
$faas
.call_with_json($module_name, $func_name, $args, <_>::default())
.unwrap_or_else(|e| panic!("faas failed with {:?}", e))
};
}

@ -1,7 +1,7 @@
[package]
name = "fcli"
description = "Fluence FCE command line tool"
version = "0.1.10"
version = "0.1.11"
authors = ["Fluence Labs"]
repository = "https://github.com/fluencelabs/fce/tools/cli"
license = "Apache-2.0"
@ -12,8 +12,8 @@ name = "fce"
path = "src/main.rs"
[dependencies]
fce-wit-generator = { path = "../../crates/wit-generator", version = "0.1.9" }
fce-wit-parser = { path = "../../crates/wit-parser", version = "0.1.8" }
fce-wit-generator = { path = "../../crates/wit-generator", version = "0.1.10" }
fce-wit-parser = { path = "../../crates/wit-parser", version = "0.1.9" }
anyhow = "1.0.31"
clap = "2.33.1"

@ -1,7 +1,7 @@
[package]
name = "frepl"
description = "Fluence FCE REPL intended for testing purposes"
version = "0.1.13"
version = "0.1.14"
authors = ["Fluence Labs"]
repository = "https://github.com/fluencelabs/fce/tools/repl"
license = "Apache-2.0"
@ -12,7 +12,7 @@ name = "fce-repl"
path = "src/main.rs"
[dependencies]
fluence-app-service = { path = "../../fluence-app-service", version = "0.1.9", features = ["raw-module-api"] }
fluence-app-service = { path = "../../fluence-app-service", version = "0.1.10", features = ["raw-module-api"] }
anyhow = "1.0.31"
clap = "2.33.1"