diff --git a/greeting/Cargo.toml b/greeting/Cargo.toml index 20abcd9..68a1bf0 100644 --- a/greeting/Cargo.toml +++ b/greeting/Cargo.toml @@ -12,4 +12,7 @@ name = "greeting" path = "src/main.rs" [dependencies] -fluence = "0.6.2" +fluence = "0.6.9" + +[dev-dependencies] +fluence-test = "0.1.9" \ No newline at end of file diff --git a/greeting/build.sh b/greeting/build.sh index 2f2ba1b..8867e36 100755 --- a/greeting/build.sh +++ b/greeting/build.sh @@ -3,7 +3,8 @@ set -o errexit -o nounset -o pipefail # This script builds all subprojects and puts all created Wasm modules in one dir cargo update -fce build --release +marine build --release -rm artifacts/* +mkdir -p artifacts +rm -f artifacts/*.wasm cp target/wasm32-wasi/release/greeting.wasm artifacts/ diff --git a/greeting/src/main.rs b/greeting/src/main.rs index bfee80e..112c572 100644 --- a/greeting/src/main.rs +++ b/greeting/src/main.rs @@ -1,5 +1,5 @@ /* - * Copyright 2020 Fluence Labs Limited + * Copyright 2021 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,31 @@ * limitations under the License. */ -use fluence::fce; +use fluence::marine; use fluence::module_manifest; module_manifest!(); pub fn main() {} -#[fce] +#[marine] pub fn greeting(name: String) -> String { 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"); + } +}