Skip to content

Commit

Permalink
new: fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nick1udwig committed Aug 16, 2024
1 parent b0cf224 commit aa64115
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = [
"echo_test",
"fibonacci_test",
]

[profile.release]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
world echo-test-template-dot-os-v0 {
import echo;
world fibonacci-test-template-dot-os-v0 {
import fibonacci;
import tester;
include process-v0;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
[package]
name = "echo_test"
name = "fibonacci_test"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
anyhow = "1.0"
bincode = "1.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.8.3" }
process_macros = { git = "https://github.com/kinode-dao/process_macros", rev = "626e501" }
rmp-serde = "1.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
wit-bindgen = "0.24.0"

[lib]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::kinode::process::echo::{Request as FibRequest, Response as FibResponse};
use crate::kinode::process::fibonacci::{Request as FibRequest, Response as FibResponse};
use crate::kinode::process::tester::{Request as TesterRequest, Response as TesterResponse, RunRequest, FailResponse};

use kinode_process_lib::{await_message, call_init, print_to_terminal, Address, ProcessId, Request, Response};
Expand All @@ -7,7 +7,7 @@ mod tester_lib;

wit_bindgen::generate!({
path: "target/wit",
world: "echo-test-template-dot-os-v0",
world: "fibonacci-test-template-dot-os-v0",
generate_unused_types: true,
additional_derives: [PartialEq, serde::Deserialize, serde::Serialize, process_macros::SerdeJsonInto],
});
Expand All @@ -17,9 +17,9 @@ fn test_number(n: u32, address: &Address) -> anyhow::Result<u64> {
.target(address)
.body(FibRequest::Number(n))
.send_and_await_response(15)?.unwrap();
if response.is_request() { fail!("echo_test"); };
if response.is_request() { fail!("fibonacci_test"); };
let FibResponse::Number(fib_number) = response.body().try_into()? else {
fail!("echo_test");
fail!("fibonacci_test");
};
Ok(fib_number)
}
Expand All @@ -29,9 +29,9 @@ fn test_numbers(n: u32, n_trials: u32, address: &Address) -> anyhow::Result<u64>
.target(address)
.body(FibRequest::Numbers((n, n_trials)))
.send_and_await_response(15)?.unwrap();
if response.is_request() { fail!("echo_test"); };
if response.is_request() { fail!("fibonacci_test"); };
let FibResponse::Numbers((fib_number, _)) = response.body().try_into()? else {
fail!("echo_test");
fail!("fibonacci_test");
};
Ok(fib_number)
}
Expand All @@ -53,20 +53,20 @@ fn handle_message (our: &Address) -> anyhow::Result<()> {
input_node_names: node_names,
..
}) = message.body().try_into()?;
print_to_terminal(0, "echo_test: a");
print_to_terminal(0, "fibonacci_test: a");
assert!(node_names.len() == 1);

let our_fib_address = Address {
node: our.node.clone(),
process: ProcessId::new(Some("echo"), "echo", "template.os"),
process: ProcessId::new(Some("fibonacci"), "fibonacci", "template.os"),
};

let numbers = vec![0, 1, 2, 5, 10, 20, 30, 47];
let expecteds = vec![0, 1, 1, 5, 55, 6_765, 832_040, 2_971_215_073];
for (number, expected) in numbers.iter().zip(expecteds.iter()) {
let result = test_number(number.clone(), &our_fib_address)?;
if &result != expected {
fail!("echo_test");
fail!("fibonacci_test");
}
}

Expand All @@ -75,7 +75,7 @@ fn handle_message (our: &Address) -> anyhow::Result<()> {
for (number, expected) in numbers.iter().zip(expecteds.iter()) {
let result = test_numbers(number.clone(), 5, &our_fib_address)?;
if &result != expected {
fail!("echo_test");
fail!("fibonacci_test");
}
}

Expand All @@ -95,9 +95,9 @@ fn init(our: Address) {
match handle_message(&our) {
Ok(()) => {},
Err(e) => {
print_to_terminal(0, format!("echo_test: error: {e:?}").as_str());
print_to_terminal(0, format!("fibonacci_test: error: {e:?}").as_str());

fail!("echo_test");
fail!("fibonacci_test");
},
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "echo Test",
"description": "A test for echo.",
"name": "fibonacci Test",
"description": "A test for fibonacci.",
"image": "",
"properties": {
"package_name": "echo_test",
"package_name": "fibonacci_test",
"current_version": "0.1.0",
"publisher": "template.os",
"mirrors": [],
Expand All @@ -12,7 +12,7 @@
},
"wit_version": 0,
"dependencies": [
"echo:template.os",
"fibonacci:template.os",
"tester:sys"
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[
{
"process_name": "echo_test",
"process_wasm_path": "/echo_test.wasm",
"process_name": "fibonacci_test",
"process_wasm_path": "/fibonacci_test.wasm",
"on_exit": "Restart",
"request_networking": false,
"request_capabilities": [
"echo:echo:template.os"
"fibonacci:fibonacci:template.os"
],
"grant_capabilities": [
"echo:echo:template.os"
"fibonacci:fibonacci:template.os"
],
"public": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setup_packages = [
{ path = "..", run = true }
]
setup_scripts = []
test_package_paths = ["echo_test"]
test_package_paths = ["fibonacci_test"]
test_scripts = []
timeout_secs = 5
fakechain_router = 8545
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = [
"echo_test",
"fibonacci_test",
]

[profile.release]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
world echo-test-template-dot-os-v0 {
import echo;
world fibonacci-test-template-dot-os-v0 {
import fibonacci;
import tester;
include process-v0;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
[package]
name = "echo_test"
name = "fibonacci_test"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
anyhow = "1.0"
bincode = "1.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.8.3" }
process_macros = { git = "https://github.com/kinode-dao/process_macros", rev = "626e501" }
rmp-serde = "1.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
wit-bindgen = "0.24.0"

[lib]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::kinode::process::echo::{Request as FibRequest, Response as FibResponse};
use crate::kinode::process::fibonacci::{Request as FibRequest, Response as FibResponse};
use crate::kinode::process::tester::{Request as TesterRequest, Response as TesterResponse, RunRequest, FailResponse};

use kinode_process_lib::{await_message, call_init, print_to_terminal, Address, ProcessId, Request, Response};
Expand All @@ -7,7 +7,7 @@ mod tester_lib;

wit_bindgen::generate!({
path: "target/wit",
world: "echo-test-template-dot-os-v0",
world: "fibonacci-test-template-dot-os-v0",
generate_unused_types: true,
additional_derives: [PartialEq, serde::Deserialize, serde::Serialize, process_macros::SerdeJsonInto],
});
Expand All @@ -17,9 +17,9 @@ fn test_number(n: u32, address: &Address) -> anyhow::Result<u64> {
.target(address)
.body(FibRequest::Number(n))
.send_and_await_response(15)?.unwrap();
if response.is_request() { fail!("echo_test"); };
if response.is_request() { fail!("fibonacci_test"); };
let FibResponse::Number(fib_number) = response.body().try_into()? else {
fail!("echo_test");
fail!("fibonacci_test");
};
Ok(fib_number)
}
Expand All @@ -29,9 +29,9 @@ fn test_numbers(n: u32, n_trials: u32, address: &Address) -> anyhow::Result<u64>
.target(address)
.body(FibRequest::Numbers((n, n_trials)))
.send_and_await_response(15)?.unwrap();
if response.is_request() { fail!("echo_test"); };
if response.is_request() { fail!("fibonacci_test"); };
let FibResponse::Numbers((fib_number, _)) = response.body().try_into()? else {
fail!("echo_test");
fail!("fibonacci_test");
};
Ok(fib_number)
}
Expand All @@ -53,20 +53,20 @@ fn handle_message (our: &Address) -> anyhow::Result<()> {
input_node_names: node_names,
..
}) = message.body().try_into()?;
print_to_terminal(0, "echo_test: a");
print_to_terminal(0, "fibonacci_test: a");
assert!(node_names.len() == 1);

let our_fib_address = Address {
node: our.node.clone(),
process: ProcessId::new(Some("echo"), "echo", "template.os"),
process: ProcessId::new(Some("fibonacci"), "fibonacci", "template.os"),
};

let numbers = vec![0, 1, 2, 5, 10, 20, 30, 47];
let expecteds = vec![0, 1, 1, 5, 55, 6_765, 832_040, 2_971_215_073];
for (number, expected) in numbers.iter().zip(expecteds.iter()) {
let result = test_number(number.clone(), &our_fib_address)?;
if &result != expected {
fail!("echo_test");
fail!("fibonacci_test");
}
}

Expand All @@ -75,7 +75,7 @@ fn handle_message (our: &Address) -> anyhow::Result<()> {
for (number, expected) in numbers.iter().zip(expecteds.iter()) {
let result = test_numbers(number.clone(), 5, &our_fib_address)?;
if &result != expected {
fail!("echo_test");
fail!("fibonacci_test");
}
}

Expand All @@ -95,9 +95,9 @@ fn init(our: Address) {
match handle_message(&our) {
Ok(()) => {},
Err(e) => {
print_to_terminal(0, format!("echo_test: error: {e:?}").as_str());
print_to_terminal(0, format!("fibonacci_test: error: {e:?}").as_str());

fail!("echo_test");
fail!("fibonacci_test");
},
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "echo Test",
"description": "A test for echo.",
"name": "fibonacci Test",
"description": "A test for fibonacci.",
"image": "",
"properties": {
"package_name": "echo_test",
"package_name": "fibonacci_test",
"current_version": "0.1.0",
"publisher": "template.os",
"mirrors": [],
Expand All @@ -12,7 +12,7 @@
},
"wit_version": 0,
"dependencies": [
"echo:template.os",
"fibonacci:template.os",
"tester:sys"
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[
{
"process_name": "echo_test",
"process_wasm_path": "/echo_test.wasm",
"process_name": "fibonacci_test",
"process_wasm_path": "/fibonacci_test.wasm",
"on_exit": "Restart",
"request_networking": false,
"request_capabilities": [
"echo:echo:template.os"
"fibonacci:fibonacci:template.os"
],
"grant_capabilities": [
"echo:echo:template.os"
"fibonacci:fibonacci:template.os"
],
"public": true
}
Expand Down
2 changes: 1 addition & 1 deletion src/new/templates/python/no-ui/fibonacci/test/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setup_packages = [
{ path = "..", run = true }
]
setup_scripts = []
test_package_paths = ["echo_test"]
test_package_paths = ["fibonacci_test"]
test_scripts = []
timeout_secs = 5
fakechain_router = 8545
Expand Down

0 comments on commit aa64115

Please sign in to comment.