Add marine tests examples (#85)

This commit is contained in:
Mike Voronov 2021-05-13 00:02:33 +03:00 committed by GitHub
parent 5a832018b4
commit fa38bc4025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 340 additions and 21 deletions

301
Cargo.lock generated
View File

@ -192,6 +192,7 @@ name = "call_parameters"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence", "fluence",
"fluence-test",
] ]
[[package]] [[package]]
@ -441,8 +442,18 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858"
dependencies = [ dependencies = [
"darling_core", "darling_core 0.10.2",
"darling_macro", "darling_macro 0.10.2",
]
[[package]]
name = "darling"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c"
dependencies = [
"darling_core 0.12.4",
"darling_macro 0.12.4",
] ]
[[package]] [[package]]
@ -459,13 +470,38 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "darling_core"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"syn",
]
[[package]] [[package]]
name = "darling_macro" name = "darling_macro"
version = "0.10.2" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [ dependencies = [
"darling_core", "darling_core 0.10.2",
"quote",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a"
dependencies = [
"darling_core 0.12.4",
"quote", "quote",
"syn", "syn",
] ]
@ -476,7 +512,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0" checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0"
dependencies = [ dependencies = [
"darling", "darling 0.10.2",
"derive_builder_core", "derive_builder_core",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -489,7 +525,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef" checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef"
dependencies = [ dependencies = [
"darling", "darling 0.10.2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn",
@ -678,7 +714,23 @@ dependencies = [
name = "fluence-app-service" name = "fluence-app-service"
version = "0.7.2" version = "0.7.2"
dependencies = [ dependencies = [
"fluence-faas", "fluence-faas 0.7.2",
"log",
"maplit",
"serde",
"serde_derive",
"serde_json",
"toml",
"wasmer-wasi-fl",
]
[[package]]
name = "fluence-app-service"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3b1d2c199d6bc140c9ec5ffa323ebd34ac134fb37828bbfd7aeed0339cab78"
dependencies = [
"fluence-faas 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log", "log",
"maplit", "maplit",
"serde", "serde",
@ -698,8 +750,8 @@ dependencies = [
"fluence-sdk-main", "fluence-sdk-main",
"itertools 0.9.0", "itertools 0.9.0",
"log", "log",
"marine-runtime", "marine-runtime 0.5.0",
"marine-utils", "marine-utils 0.2.0",
"once_cell", "once_cell",
"pretty_assertions", "pretty_assertions",
"safe-transmute", "safe-transmute",
@ -714,6 +766,31 @@ dependencies = [
"wasmer-wasi-fl", "wasmer-wasi-fl",
] ]
[[package]]
name = "fluence-faas"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9421599c5540e50f3854a0a48702c31408ac1cfb06314fe391792daa3a9d800b"
dependencies = [
"cmd_lib",
"fluence",
"fluence-sdk-main",
"itertools 0.9.0",
"log",
"marine-runtime 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"marine-utils 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-transmute",
"serde",
"serde_derive",
"serde_json",
"thiserror",
"toml",
"wasmer-interface-types-fl",
"wasmer-runtime-core-fl",
"wasmer-runtime-fl",
"wasmer-wasi-fl",
]
[[package]] [[package]]
name = "fluence-it-types" name = "fluence-it-types"
version = "0.3.0" version = "0.3.0"
@ -737,6 +814,33 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "fluence-sdk-wit"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eab3ed39703b72e0e52bce9e1760746c73f65a5694c8da4dec751d3bfdec15b8"
dependencies = [
"proc-macro2",
"quote",
"serde",
"serde_json",
"syn",
"uuid",
]
[[package]]
name = "fluence-test"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7be0d7928e5e6a74a8e303b7f539116fdb4043f5788f78e9eaf32c53700c4c18"
dependencies = [
"fluence-app-service 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"marine-test-macro",
"serde",
"serde_json",
"uuid",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@ -1342,15 +1446,15 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]] [[package]]
name = "marine" name = "marine"
version = "0.6.0" version = "0.6.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"check-latest", "check-latest",
"clap", "clap",
"exitfailure", "exitfailure",
"marine-it-generator", "marine-it-generator 0.5.1",
"marine-it-parser", "marine-it-parser 0.6.0",
"marine-module-info-parser", "marine-module-info-parser 0.1.0",
"semver 0.11.0", "semver 0.11.0",
"serde", "serde",
"serde_json", "serde_json",
@ -1361,11 +1465,29 @@ dependencies = [
[[package]] [[package]]
name = "marine-it-generator" name = "marine-it-generator"
version = "0.5.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245d4971ee68559236cdd34e6d57ae769dab68c6c9ed4d390f14ae5830880c8f"
dependencies = [
"cargo_toml",
"fluence-sdk-wit",
"it-lilo",
"marine-it-parser 0.5.0",
"once_cell",
"serde",
"serde_json",
"thiserror",
"walrus",
"wasmer-interface-types-fl",
]
[[package]]
name = "marine-it-generator"
version = "0.5.1"
dependencies = [ dependencies = [
"cargo_toml", "cargo_toml",
"it-lilo", "it-lilo",
"marine-it-parser", "marine-it-parser 0.6.0",
"marine-macro-impl", "marine-macro-impl",
"once_cell", "once_cell",
"serde", "serde",
@ -1375,6 +1497,16 @@ dependencies = [
"wasmer-interface-types-fl", "wasmer-interface-types-fl",
] ]
[[package]]
name = "marine-it-interfaces"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97c533789e72808630cc35b5d14d286382236282525f82ddce8fb47eb9d659e8"
dependencies = [
"multimap",
"wasmer-interface-types-fl",
]
[[package]] [[package]]
name = "marine-it-interfaces" name = "marine-it-interfaces"
version = "0.4.0" version = "0.4.0"
@ -1383,12 +1515,29 @@ dependencies = [
"wasmer-interface-types-fl", "wasmer-interface-types-fl",
] ]
[[package]]
name = "marine-it-parser"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e59c7067a18b9e4aebe67bee033638fae97d6fe4fb00f70f9a509eb5d03d1c5d"
dependencies = [
"anyhow",
"marine-it-interfaces 0.3.0",
"nom",
"semver 0.11.0",
"serde",
"thiserror",
"walrus",
"wasmer-interface-types-fl",
"wasmer-runtime-core-fl",
]
[[package]] [[package]]
name = "marine-it-parser" name = "marine-it-parser"
version = "0.6.0" version = "0.6.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"marine-it-interfaces", "marine-it-interfaces 0.4.0",
"nom", "nom",
"semver 0.11.0", "semver 0.11.0",
"serde", "serde",
@ -1435,6 +1584,22 @@ dependencies = [
"wasmer-runtime-core-fl", "wasmer-runtime-core-fl",
] ]
[[package]]
name = "marine-module-info-parser"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "003017e314cebb5c774569a4257f5eca82106cff170b124c6712f2fcd3ceefef"
dependencies = [
"anyhow",
"chrono",
"fluence-sdk-main",
"semver 0.11.0",
"serde",
"thiserror",
"walrus",
"wasmer-runtime-core-fl",
]
[[package]] [[package]]
name = "marine-runtime" name = "marine-runtime"
version = "0.5.0" version = "0.5.0"
@ -1444,11 +1609,11 @@ dependencies = [
"bytes 0.5.6", "bytes 0.5.6",
"it-lilo", "it-lilo",
"log", "log",
"marine-it-generator", "marine-it-generator 0.5.1",
"marine-it-interfaces", "marine-it-interfaces 0.4.0",
"marine-it-parser", "marine-it-parser 0.6.0",
"marine-module-info-parser", "marine-module-info-parser 0.1.0",
"marine-utils", "marine-utils 0.2.0",
"multimap", "multimap",
"once_cell", "once_cell",
"parity-wasm", "parity-wasm",
@ -1465,6 +1630,35 @@ dependencies = [
"wasmer-wasi-fl", "wasmer-wasi-fl",
] ]
[[package]]
name = "marine-runtime"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8722580724555bf87a1128780f7dd3f700bbc6add690d1efe7e7fc736edf1a1"
dependencies = [
"anyhow",
"boolinator",
"it-lilo",
"log",
"marine-it-generator 0.4.0",
"marine-it-interfaces 0.3.0",
"marine-it-parser 0.5.0",
"marine-module-info-parser 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"marine-utils 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"multimap",
"once_cell",
"parity-wasm",
"paste",
"pwasm-utils",
"semver 0.11.0",
"serde",
"thiserror",
"wasmer-interface-types-fl",
"wasmer-runtime-core-fl",
"wasmer-runtime-fl",
"wasmer-wasi-fl",
]
[[package]] [[package]]
name = "marine-sqlite-connector" name = "marine-sqlite-connector"
version = "0.4.1" version = "0.4.1"
@ -1474,6 +1668,35 @@ dependencies = [
"fluence", "fluence",
] ]
[[package]]
name = "marine-test-macro"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "709eebc4ee6c8e6aa49066ab066c9f137d9cf164f298f578a67bfb11a0508f65"
dependencies = [
"marine-test-macro-impl",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "marine-test-macro-impl"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2432fd5233a088981c79324668b76f3ee2ae6d313d4522b5490226e5e7827ce"
dependencies = [
"darling 0.12.4",
"fluence-app-service 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"marine-it-parser 0.5.0",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
"thiserror",
]
[[package]] [[package]]
name = "marine-timestamp-macro" name = "marine-timestamp-macro"
version = "0.6.2" version = "0.6.2"
@ -1488,6 +1711,12 @@ dependencies = [
name = "marine-utils" name = "marine-utils"
version = "0.2.0" version = "0.2.0"
[[package]]
name = "marine-utils"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dc5838acba84ce4d802d672afd0814fae0ae7098021ae5b06d975e70d09f812"
[[package]] [[package]]
name = "matches" name = "matches"
version = "0.1.8" version = "0.1.8"
@ -1606,7 +1835,7 @@ dependencies = [
"check-latest", "check-latest",
"clap", "clap",
"env_logger 0.7.1", "env_logger 0.7.1",
"fluence-app-service", "fluence-app-service 0.7.2",
"fluence-sdk-main", "fluence-sdk-main",
"itertools 0.9.0", "itertools 0.9.0",
"log", "log",
@ -1927,6 +2156,29 @@ dependencies = [
"output_vt100", "output_vt100",
] ]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.26" version = "1.0.26"
@ -2495,6 +2747,12 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "subtle" name = "subtle"
version = "2.4.0" version = "2.4.0"
@ -3082,6 +3340,7 @@ name = "wasm-greeting"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence", "fluence",
"fluence-test",
] ]
[[package]] [[package]]

View File

@ -11,3 +11,6 @@ path = "src/main.rs"
[dependencies] [dependencies]
fluence = "0.6.4" fluence = "0.6.4"
[dev-dependencies]
fluence-test = "0.1.7"

View File

@ -38,3 +38,40 @@ pub fn call_parameters() -> String {
cp.tetraplets cp.tetraplets
) )
} }
#[cfg(test)]
mod tests {
use fluence_test::marine_test;
use fluence_test::CallParameters;
use fluence_test::SecurityTetraplet;
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts")]
fn empty_string() {
let init_peer_id = "init_peer_id";
let service_id = "service_id";
let service_creator_peer_id = "service_creator_peer_id";
let host_id = "host_id";
let particle_id = "particle_id";
let mut tetraplet = SecurityTetraplet::default();
tetraplet.function_name = "some_func_name".to_string();
tetraplet.json_path = "some_json_path".to_string();
let tetraplets = vec![vec![tetraplet]];
let cp = CallParameters {
init_peer_id: init_peer_id.to_string(),
service_id: service_id.to_string(),
service_creator_peer_id: service_creator_peer_id.to_string(),
host_id: host_id.to_string(),
particle_id: particle_id.to_string(),
tetraplets: tetraplets.clone(),
};
let actual = call_parameters.call_parameters_cp(cp);
let expected = format!(
"{}\n{}\n{}\n{}\n{}\n{:?}",
init_peer_id, service_id, service_creator_peer_id, host_id, particle_id, tetraplets
);
assert_eq!(actual, expected);
}
}

View File

@ -13,3 +13,6 @@ path = "src/main.rs"
[dependencies] [dependencies]
fluence = "0.6.4" fluence = "0.6.4"
[dev-dependencies]
fluence-test = "0.1.7"

View File

@ -25,3 +25,20 @@ pub fn main() {}
pub fn greeting(name: String) -> String { pub fn greeting(name: String) -> String {
format!("Hi, {}", name) format!("Hi, {}", name)
} }
#[cfg(test)]
mod tests {
use fluence_test::marine_test;
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts")]
fn empty_string() {
let actual = greeting.greeting(String::new());
assert_eq!(actual, "Hi, ");
}
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts")]
fn non_empty_string() {
let actual = greeting.greeting("name".to_string());
assert_eq!(actual, "Hi, name");
}
}