From 34873b804ff2e5a40cf657a5c53b62388fffceba Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Tue, 22 Apr 2025 10:39:52 -0400 Subject: [PATCH 01/11] compiles, tests not working rn --- src/main.rs | 2 +- src/new/mod.rs | 5 +- .../templates/rust/no-ui/hypr-echo/.gitignore | 9 + .../templates/rust/no-ui/hypr-echo/Cargo.toml | 11 + .../rust/no-ui/hypr-echo/hypr-echo/Cargo.toml | 33 +++ .../rust/no-ui/hypr-echo/hypr-echo/src/lib.rs | 71 +++++++ .../rust/no-ui/hypr-echo/metadata.json | 19 ++ .../rust/no-ui/hypr-echo/pkg/manifest.json | 21 ++ .../hypr-echo/test/hypr-echo-test/Cargo.toml | 10 + .../hypr-echo-test/hypr-echo-test/Cargo.toml | 25 +++ .../hypr-echo-test/hypr-echo-test/src/lib.rs | 37 ++++ .../hypr-echo-test/src/tester_lib.rs | 197 ++++++++++++++++++ .../test/hypr-echo-test/metadata.json | 22 ++ .../test/hypr-echo-test/pkg/manifest.json | 17 ++ .../rust/no-ui/hypr-echo/test/tests.toml | 22 ++ 15 files changed, 499 insertions(+), 2 deletions(-) create mode 100644 src/new/templates/rust/no-ui/hypr-echo/.gitignore create mode 100644 src/new/templates/rust/no-ui/hypr-echo/Cargo.toml create mode 100644 src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml create mode 100644 src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs create mode 100644 src/new/templates/rust/no-ui/hypr-echo/metadata.json create mode 100644 src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json create mode 100644 src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/Cargo.toml create mode 100644 src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml create mode 100644 src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/lib.rs create mode 100644 src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/tester_lib.rs create mode 100644 src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/metadata.json create mode 100644 src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json create mode 100644 src/new/templates/rust/no-ui/hypr-echo/test/tests.toml diff --git a/src/main.rs b/src/main.rs index a49c9139..0b5a8b34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1066,7 +1066,7 @@ async fn make_app(current_dir: &std::ffi::OsString) -> Result { .short('t') .long("template") .help("Template to create") - .value_parser(["blank", "chat", "echo", "fibonacci", "file-transfer"]) + .value_parser(["blank", "chat", "echo", "fibonacci", "file-transfer", "hypr-echo"]) .default_value("chat") ) .arg(Arg::new("UI") diff --git a/src/new/mod.rs b/src/new/mod.rs index 1b5f1e82..fe332146 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -23,6 +23,7 @@ pub enum Template { Echo, Fibonacci, FileTransfer, + HyprEcho, } impl Language { @@ -44,6 +45,7 @@ impl Template { Template::Echo => "echo", Template::Fibonacci => "fibonacci", Template::FileTransfer => "file-transfer", + Template::HyprEcho => "hypr-echo", } .to_string() } @@ -68,7 +70,8 @@ impl From<&String> for Template { "echo" => Template::Echo, "fibonacci" => Template::Fibonacci, "file-transfer" => Template::FileTransfer, - _ => panic!("kit: template must be 'blank', 'chat', 'echo', or 'fibonacci'; not '{s}'"), + "hypr-echo" => Template::HyprEcho, + _ => panic!("kit: template must be 'blank', 'chat', 'echo', 'fibonacci', or 'hypr-echo'; not '{s}'"), } } } diff --git a/src/new/templates/rust/no-ui/hypr-echo/.gitignore b/src/new/templates/rust/no-ui/hypr-echo/.gitignore new file mode 100644 index 00000000..b2a2ce0f --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/.gitignore @@ -0,0 +1,9 @@ +api +*swp +**/target +pkg/*.wasm +pkg/*.zip +pkg/ui +crates/ +caller-utils/ +**/.DS_Store \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hypr-echo/Cargo.toml b/src/new/templates/rust/no-ui/hypr-echo/Cargo.toml new file mode 100644 index 00000000..f2551454 --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/Cargo.toml @@ -0,0 +1,11 @@ +[profile.release] +lto = true +opt-level = "s" +panic = "abort" + +[workspace] +members = [ + "hypr-echo", + "test/hypr-echo-test/hypr-echo-test", +] +resolver = "2" diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml new file mode 100644 index 00000000..a357d882 --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml @@ -0,0 +1,33 @@ +[dependencies] +anyhow = "1.0.97" +process_macros = "0.1" +rmp-serde = "1.3.0" +serde_json = "1.0" +wit-bindgen = "0.36.0" + + +[dependencies.hyperprocess_macro] +git = "https://github.com/hyperware-ai/hyperprocess-macro" +rev = "47400ab" + +[dependencies.hyperware_app_common] +git = "https://github.com/hyperware-ai/hyperprocess-macro" +rev = "47400ab" + +[dependencies.serde] +features = ["derive"] +version = "1.0" + +[features] +simulation-mode = [] + +[lib] +crate-type = ["cdylib"] + +[package] +edition = "2021" +name = "hypr-echo" +version = "0.1.0" + +[package.metadata.component] +package = "hyperware:process" diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs new file mode 100644 index 00000000..343f24f9 --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs @@ -0,0 +1,71 @@ +use serde::{Serialize, Deserialize}; +use hyperware_process_lib::{ + LazyLoadBlob, + http::server::{WsMessageType, send_ws_push} +}; +use hyperprocess_macro::hyperprocess; + +#[derive(Default, Debug, serde::Serialize, serde::Deserialize)] +pub struct HyprEchoState {} + +#[derive(Serialize, Deserialize, Debug)] +pub struct HyprEchoReq { + payload: String, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct HyprEchoResp { + payload: String, +} + +#[hyperprocess( + name = "HyprEcho", + ui = None, + endpoints = vec![ + Binding::Http { + path: "/api", + config: HttpBindingConfig::new(false, false, false, None), + }, + Binding::Ws { + path: "/ws", + config: WsBindingConfig::new(false, false, false), + } + ], + save_config = SaveOptions::Never, // Changed as state is removed + wit_world = "hypr-echo-template-dot-os-v0" +)] + + +impl HyprEchoState { + // Initialize the process, every application needs an init function + #[init] + async fn initialize(&mut self) { + println!("init HyprEcho"); + } + + // Endpoint accepting both local, remote Hyperware requests, and HTTP requests + #[local] + #[remote] + #[http] + async fn echo(&self, req: HyprEchoReq) -> HyprEchoResp { + if req.payload == "echo" { + HyprEchoResp { payload: "echo".to_string() } + } else { + HyprEchoResp { payload: "don't talk to me".to_string() } + } + } + + // Endpoint accepting WebSocket requests + #[ws] + fn ws_echo(&mut self, channel_id: u32, _message_type: WsMessageType, _blob: LazyLoadBlob) { + // Respond with "echo" + send_ws_push( + channel_id, + WsMessageType::Text, + LazyLoadBlob { + mime: Some("application/json".to_string()), + bytes: serde_json::to_vec("Echo from server").unwrap(), + }, + ); + } +} diff --git a/src/new/templates/rust/no-ui/hypr-echo/metadata.json b/src/new/templates/rust/no-ui/hypr-echo/metadata.json new file mode 100644 index 00000000..a7a078d2 --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/metadata.json @@ -0,0 +1,19 @@ +{ + "name": "hypr-echo", + "description": "Template process for app framework.", + "image": "", + "properties": { + "package_name": "hypr-echo", + "current_version": "0.1.0", + "publisher": "template.os", + "mirrors": [], + "code_hashes": { + "0.1.0": "" + }, + "wit_version": 1, + "dependencies": [ + ] + }, + "external_url": "https://hyperware.ai", + "animation_url": "" +} diff --git a/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json b/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json new file mode 100644 index 00000000..54a6163d --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json @@ -0,0 +1,21 @@ +[ + { + "process_name": "hypr-echo", + "process_wasm_path": "/hypr-echo.wasm", + "on_exit": "Restart", + "request_networking": true, + "request_capabilities": [ + "http-server:distro:sys", + "http-client:distro:sys", + "vfs:distro:sys", + "homepage:homepage:sys" + ], + "grant_capabilities": [ + "http-server:distro:sys", + "http-client:distro:sys", + "vfs:distro:sys", + "homepage:homepage:sys" + ], + "public": false + } +] diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/Cargo.toml b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/Cargo.toml new file mode 100644 index 00000000..33760e0c --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/Cargo.toml @@ -0,0 +1,10 @@ +[workspace] +resolver = "2" +members = [ + "hypr-echo-test", +] + +[profile.release] +panic = "abort" +opt-level = "s" +lto = true \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml new file mode 100644 index 00000000..5f25b4fb --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "hypr-echo-test" +version = "0.1.0" +edition = "2021" +publish = false + +[dependencies] +anyhow = "1.0" +bincode = "1.3" +hyperware_process_lib = { version = "1.0.4" } +process_macros = "0.1.0" +hyperware_app_common = { git = "https://github.com/hyperware-ai/hyperprocess-macro" } +rmp-serde = "1.1" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +thiserror = "1.0" +url = "2.5.3" +rand = "0.8" +wit-bindgen = "0.36.0" + +[lib] +crate-type = ["cdylib"] + +[package.metadata.component] +package = "hyperware:process" diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/lib.rs b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/lib.rs new file mode 100644 index 00000000..47d74fd5 --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/lib.rs @@ -0,0 +1,37 @@ +use crate::hyperware::process::tester::{FailResponse, Response as TesterResponse}; +use caller_utils::hyperprocess::*; +mod tester_lib; + +use hyperware_app_common::SendResult; + +async_test_suite!( + "test-hypr-echo-template-dot-os-v0", + + test_basic_math: async { + if 2 + 2 != 4 { + fail!("wrong result"); + } + Ok(()) + }, + + // Test local add call + test_local_add_call: async { + let address: Address = ("hypr-echo.os", "hypr-echo", "hypr-echo", "template.os").into(); + let value = "World".to_string(); + // Pass only the value, matching the generated stub signature + let result = add_to_state_local_rpc(&address, value).await; + print_to_terminal(0, &format!("add_to_state_local_rpc result: {:?}", result)); + // Assuming the call should succeed + Ok(()) + }, + + // Test local get call + test_local_get_call: async { + let address: Address = ("hypr-echo.os", "hypr-echo", "hypr-echo", "template.os").into(); + let result = get_state_local_rpc(&address).await; + print_to_terminal(0, &format!("get_state_local_rpc result: {:?}", result)); + // Assuming the call should succeed + + Ok(()) + }, +); \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/tester_lib.rs b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/tester_lib.rs new file mode 100644 index 00000000..9bf7fe75 --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/tester_lib.rs @@ -0,0 +1,197 @@ +#[allow(unused_imports)] +use crate::hyperware::process::tester::{FailResponse, Response as TesterResponse}; +use hyperware_process_lib::Response; +use hyperware_app_common::SendResult; + +#[macro_export] +macro_rules! fail { + ($test:expr) => { + Response::new() + .body(TesterResponse::Run(Err(FailResponse { + test: $test.into(), + file: file!().into(), + line: line!(), + column: column!(), + }))) + .send() + .unwrap(); + panic!("") + }; + ($test:expr, $file:expr, $line:expr, $column:expr) => { + Response::new() + .body(TesterResponse::Run(Err(FailResponse { + test: $test.into(), + file: $file.into(), + line: $line, + column: $column, + }))) + .send() + .unwrap(); + panic!("") + }; +} + +#[macro_export] +macro_rules! async_test_suite { + ($wit_world:expr, $($test_name:ident: async $test_body:block),* $(,)?) => { + wit_bindgen::generate!({ + path: "target/wit", + world: $wit_world, + generate_unused_types: true, + additional_derives: [PartialEq, serde::Deserialize, serde::Serialize, process_macros::SerdeJsonInto], + }); + + use hyperware_process_lib::{ + await_message, call_init, print_to_terminal, Address, Response + }; + + $( + async fn $test_name() -> anyhow::Result<()> { + $test_body + } + )* + + async fn run_all_tests() -> anyhow::Result<()> { + $( + print_to_terminal(0, concat!("Running test: ", stringify!($test_name))); + match $test_name().await { + Ok(()) => { + print_to_terminal(0, concat!("Test passed: ", stringify!($test_name))); + }, + Err(e) => { + print_to_terminal(0, &format!("Test failed: {} - {:?}", stringify!($test_name), e)); + return Err(e); + } + } + )* + + print_to_terminal(0, "All tests passed!"); + Ok(()) + } + + call_init!(init); + fn init(_our: Address) { + print_to_terminal(0, "Starting test suite..."); + + // Flag to track if tests have been triggered and started + let mut tests_triggered = false; + + // Main event loop + loop { + // Poll tasks to advance the executor + hyperware_app_common::APP_CONTEXT.with(|ctx| { + ctx.borrow_mut().executor.poll_all_tasks(); + }); + + // First, process any messages to handle RPC responses + match await_message() { + Ok(message) => { + match message { + hyperware_process_lib::Message::Response {body, context, ..} => { + // Handle responses to unblock waiting futures + let correlation_id = context + .as_deref() + .map(|bytes| String::from_utf8_lossy(bytes).to_string()) + .unwrap_or_else(|| "no context".to_string()); + + print_to_terminal(0, &format!("Received response with ID: {}", correlation_id)); + + hyperware_app_common::RESPONSE_REGISTRY.with(|registry| { + let mut registry_mut = registry.borrow_mut(); + registry_mut.insert(correlation_id, body); + }); + }, + hyperware_process_lib::Message::Request { .. } => { + // The first request triggers test execution + if !tests_triggered { + tests_triggered = true; + print_to_terminal(0, "Received initial request, starting tests..."); + + // Start the test suite + hyperware_app_common::hyper! { + match run_all_tests().await { + Ok(()) => { + // All tests passed - send success response + print_to_terminal(0, "Tests completed successfully!"); + Response::new() + .body(TesterResponse::Run(Ok(()))) + .send() + .unwrap_or_else(|e| { + print_to_terminal(0, &format!("Failed to send success response: {:?}", e)); + }); + }, + Err(e) => { + // Tests failed - send failure response + print_to_terminal(0, &format!("Test suite failed: {:?}", e)); + crate::fail!(&format!("Test failure: {:?}", e)); + } + } + } + } + // No response here - response is sent when tests complete + } + } + }, + Err(e) => { + // Handle send errors to unblock futures that are waiting for responses + if let hyperware_process_lib::SendError { + kind, + context: Some(context), + .. + } = &e + { + if let Ok(correlation_id) = String::from_utf8(context.to_vec()) { + let error_response = serde_json::to_vec(kind).unwrap(); + + hyperware_app_common::RESPONSE_REGISTRY.with(|registry| { + let mut registry_mut = registry.borrow_mut(); + registry_mut.insert(correlation_id, error_response); + }); + } + } + + print_to_terminal(0, &format!("Message error: {:?}", e)); + } + } + } + } + }; +} + +/// Helper function to test remote RPC calls +/// +/// This function handles: +/// 1. Checking if the call was successful +/// 2. Validating the returned value against an expected value +/// 3. Handling error cases with appropriate failure messages +/// +/// Returns the actual value if successful, allowing it to be used in subsequent operations +pub async fn test_remote_call( + call_future: F, + expected_value: T, + error_msg: &str, +) -> anyhow::Result +where + T: std::cmp::PartialEq + std::fmt::Debug + Clone, + F: std::future::Future>, +{ + let result = call_future.await; + + match result { + SendResult::Success(actual) => { + if actual != expected_value { + fail!(format!("{}: expected {:?}, got {:?}", error_msg, expected_value, actual)); + } + // Return the actual value + Ok(actual) + } + _ => { + fail!(match result { + SendResult::Timeout => "timeout", + SendResult::Offline => "offline", + SendResult::DeserializationError(_) => "deserialization error", + _ => "unknown error", + }); + } + } +} \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/metadata.json b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/metadata.json new file mode 100644 index 00000000..676fccdf --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/metadata.json @@ -0,0 +1,22 @@ +{ + "name": "HyprEcho Test", + "description": "A test showcasing the hyperware app framework.", + "image": "", + "properties": { + "package_name": "hypr-echo-test", + "current_version": "0.1.0", + "publisher": "template.os", + "mirrors": [], + "code_hashes": { + "0.1.0": "" + }, + "wit_version": 1, + "dependencies": [ + "hypr-echo:template.os", + "tester:sys" + ] + }, + "external_url": "", + "animation_url": "" +} + diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json new file mode 100644 index 00000000..15f62fb3 --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json @@ -0,0 +1,17 @@ +[ + { + "process_name": "hypr-echo-test", + "process_wasm_path": "/hypr-echo-test.wasm", + "on_exit": "None", + "request_networking": true, + "request_capabilities": [ + "hypr-echo:hypr-echo:template.os", + "http-client:distro:sys" + ], + "grant_capabilities": [ + "hypr-echo:hypr-echo:template.os", + "http-client:distro:sys" + ], + "public": true + } +] \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/tests.toml b/src/new/templates/rust/no-ui/hypr-echo/test/tests.toml new file mode 100644 index 00000000..fb74cd14 --- /dev/null +++ b/src/new/templates/rust/no-ui/hypr-echo/test/tests.toml @@ -0,0 +1,22 @@ +runtime = { FetchVersion = "latest" } +persist_home = false +runtime_build_release = false +always_print_node_output = false + + +[[tests]] +dependency_package_paths = [".."] +setup_packages = [{ path = "..", run = true }] +setup_scripts = [] +test_package_paths = ["hypr-echo-test"] +test_scripts = [] +timeout_secs = 35 +fakechain_router = 8545 +hyperapp = true + + +[[tests.nodes]] +port = 8080 +home = "home/hypr-echo-test" +fake_node_name = "hypr-echo.os" +runtime_verbosity = 2 From e222f2805acb6fb6da7fecfcdbeed2d2d120a9d5 Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:58:31 -0400 Subject: [PATCH 02/11] alphabeticized the 'request_capabilities' --- .../templates/rust/no-ui/hypr-echo/pkg/manifest.json | 12 ++++++------ .../hypr-echo/test/hypr-echo-test/pkg/manifest.json | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json b/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json index 54a6163d..1f84275d 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json +++ b/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json @@ -5,16 +5,16 @@ "on_exit": "Restart", "request_networking": true, "request_capabilities": [ - "http-server:distro:sys", + "homepage:homepage:sys", "http-client:distro:sys", - "vfs:distro:sys", - "homepage:homepage:sys" + "http-server:distro:sys", + "vfs:distro:sys" ], "grant_capabilities": [ - "http-server:distro:sys", + "homepage:homepage:sys", "http-client:distro:sys", - "vfs:distro:sys", - "homepage:homepage:sys" + "http-server:distro:sys", + "vfs:distro:sys" ], "public": false } diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json index 15f62fb3..90ef3129 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json +++ b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json @@ -5,12 +5,12 @@ "on_exit": "None", "request_networking": true, "request_capabilities": [ - "hypr-echo:hypr-echo:template.os", - "http-client:distro:sys" + "http-client:distro:sys", + "hypr-echo:hypr-echo:template.os" ], "grant_capabilities": [ - "hypr-echo:hypr-echo:template.os", - "http-client:distro:sys" + "http-client:distro:sys", + "hypr-echo:hypr-echo:template.os" ], "public": true } From eb8bb2bd9e8f36e1b3b74bf806cfd79dd522b76f Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:18:45 -0400 Subject: [PATCH 03/11] mimick behavior with regular echo template --- .../rust/no-ui/hypr-echo/hypr-echo/src/lib.rs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs index 343f24f9..4ec055d5 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs +++ b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs @@ -43,28 +43,28 @@ impl HyprEchoState { println!("init HyprEcho"); } - // Endpoint accepting both local, remote Hyperware requests, and HTTP requests - #[local] - #[remote] - #[http] - async fn echo(&self, req: HyprEchoReq) -> HyprEchoResp { - if req.payload == "echo" { - HyprEchoResp { payload: "echo".to_string() } - } else { - HyprEchoResp { payload: "don't talk to me".to_string() } - } - } +// Endpoint accepting both local, remote Hyperware requests, and HTTP requests +#[local] +#[remote] +#[http] +async fn echo(&self, req: HyprEchoReq) -> HyprEchoResp { + // Print the received request, similar to the example snippet + println!("got {:?}", req); + // Return a fixed "Ack" response, mapped to the HyprEchoResp structure + HyprEchoResp { payload: "Ack".to_string() } +} // Endpoint accepting WebSocket requests #[ws] - fn ws_echo(&mut self, channel_id: u32, _message_type: WsMessageType, _blob: LazyLoadBlob) { + fn ws_echo(&mut self, channel_id: u32, message_type: WsMessageType, blob: LazyLoadBlob) { + println!("got: type={:?}, blob={:?}", message_type, blob); // Respond with "echo" send_ws_push( channel_id, WsMessageType::Text, LazyLoadBlob { mime: Some("application/json".to_string()), - bytes: serde_json::to_vec("Echo from server").unwrap(), + bytes: serde_json::to_vec("Ack").unwrap(), }, ); } From 50a8f106d0c16d46be35d1868e408a3ecb3cbc79 Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:21:30 -0400 Subject: [PATCH 04/11] removed unecessary comments --- src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs index 4ec055d5..afc5e6b5 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs +++ b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs @@ -31,7 +31,7 @@ pub struct HyprEchoResp { config: WsBindingConfig::new(false, false, false), } ], - save_config = SaveOptions::Never, // Changed as state is removed + save_config = SaveOptions::Never, wit_world = "hypr-echo-template-dot-os-v0" )] @@ -48,9 +48,7 @@ impl HyprEchoState { #[remote] #[http] async fn echo(&self, req: HyprEchoReq) -> HyprEchoResp { - // Print the received request, similar to the example snippet println!("got {:?}", req); - // Return a fixed "Ack" response, mapped to the HyprEchoResp structure HyprEchoResp { payload: "Ack".to_string() } } @@ -58,7 +56,7 @@ async fn echo(&self, req: HyprEchoReq) -> HyprEchoResp { #[ws] fn ws_echo(&mut self, channel_id: u32, message_type: WsMessageType, blob: LazyLoadBlob) { println!("got: type={:?}, blob={:?}", message_type, blob); - // Respond with "echo" + send_ws_push( channel_id, WsMessageType::Text, From af25db3497462de1e61a49d7dfbcfd4adb1d9eff Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:45:41 -0400 Subject: [PATCH 05/11] made type conventions better --- .../rust/no-ui/hypr-echo/hypr-echo/src/lib.rs | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs index afc5e6b5..59631d4b 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs +++ b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs @@ -9,13 +9,14 @@ use hyperprocess_macro::hyperprocess; pub struct HyprEchoState {} #[derive(Serialize, Deserialize, Debug)] -pub struct HyprEchoReq { - payload: String, +pub struct Argument { + header: String, + body: String, } #[derive(Serialize, Deserialize, Debug)] -pub struct HyprEchoResp { - payload: String, +pub struct ReturnValue { + result: String, } #[hyperprocess( @@ -35,7 +36,6 @@ pub struct HyprEchoResp { wit_world = "hypr-echo-template-dot-os-v0" )] - impl HyprEchoState { // Initialize the process, every application needs an init function #[init] @@ -43,27 +43,28 @@ impl HyprEchoState { println!("init HyprEcho"); } -// Endpoint accepting both local, remote Hyperware requests, and HTTP requests -#[local] -#[remote] -#[http] -async fn echo(&self, req: HyprEchoReq) -> HyprEchoResp { - println!("got {:?}", req); - HyprEchoResp { payload: "Ack".to_string() } -} + // Endpoint accepting both local, remote Hyperware requests, and HTTP requests + #[local] + #[remote] + #[http] + async fn echo(&self, arg: Argument) -> ReturnValue { + println!("header: {:?}, body: {:?}", arg.header, arg.body); + + ReturnValue { result: "Ack".to_string() } + } // Endpoint accepting WebSocket requests #[ws] - fn ws_echo(&mut self, channel_id: u32, message_type: WsMessageType, blob: LazyLoadBlob) { + async fn ws_echo(&mut self, channel_id: u32, message_type: WsMessageType, blob: LazyLoadBlob) { println!("got: type={:?}, blob={:?}", message_type, blob); - - send_ws_push( - channel_id, - WsMessageType::Text, - LazyLoadBlob { - mime: Some("application/json".to_string()), - bytes: serde_json::to_vec("Ack").unwrap(), - }, - ); + + send_ws_push( + channel_id, + WsMessageType::Text, + LazyLoadBlob { + mime: Some("application/json".to_string()), + bytes: serde_json::to_vec("Ack").unwrap(), + }, + ); } } From a487bee94e30cafcf70ca6ab40036c625413c4f5 Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:03:26 -0400 Subject: [PATCH 06/11] streamlined imports (got rid of unused, fixed imports for serde in a type for clarity) --- .../templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml | 4 +--- .../templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs | 2 +- .../test/hypr-echo-test/hypr-echo-test/Cargo.toml | 9 ++------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml index a357d882..44ee8604 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml +++ b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml @@ -1,7 +1,5 @@ [dependencies] -anyhow = "1.0.97" -process_macros = "0.1" -rmp-serde = "1.3.0" +process_macros = "0.1" serde_json = "1.0" wit-bindgen = "0.36.0" diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs index 59631d4b..5cb07a8c 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs +++ b/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs @@ -5,7 +5,7 @@ use hyperware_process_lib::{ }; use hyperprocess_macro::hyperprocess; -#[derive(Default, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Default, Debug, Serialize, Deserialize)] pub struct HyprEchoState {} #[derive(Serialize, Deserialize, Debug)] diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml index 5f25b4fb..7c8b7bd4 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml +++ b/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml @@ -6,16 +6,11 @@ publish = false [dependencies] anyhow = "1.0" -bincode = "1.3" -hyperware_process_lib = { version = "1.0.4" } -process_macros = "0.1.0" hyperware_app_common = { git = "https://github.com/hyperware-ai/hyperprocess-macro" } -rmp-serde = "1.1" +hyperware_process_lib = { git = "https://github.com/hyperware-ai/hyperprocess-macro" } +process_macros = "0.1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -thiserror = "1.0" -url = "2.5.3" -rand = "0.8" wit-bindgen = "0.36.0" [lib] From 9017221024353b2ddfdc5c80864cd809ee408be9 Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:29:21 -0400 Subject: [PATCH 07/11] Changed names --- .../no-ui/{hypr-echo => hyperapp-echo}/.gitignore | 0 .../no-ui/{hypr-echo => hyperapp-echo}/Cargo.toml | 4 ++-- .../hyperapp-echo}/Cargo.toml | 2 +- .../hyperapp-echo}/src/lib.rs | 15 +++++++++------ .../{hypr-echo => hyperapp-echo}/metadata.json | 6 +++--- .../pkg/manifest.json | 4 ++-- .../test/hyperapp-echo-test}/Cargo.toml | 2 +- .../hyper-app-echo-test}/Cargo.toml | 2 +- .../hyper-app-echo-test}/src/lib.rs | 6 +++--- .../hyper-app-echo-test}/src/tester_lib.rs | 0 .../test/hyperapp-echo-test}/metadata.json | 0 .../test/hyperapp-echo-test}/pkg/manifest.json | 8 ++++---- .../{hypr-echo => hyperapp-echo}/test/tests.toml | 4 ++-- 13 files changed, 28 insertions(+), 25 deletions(-) rename src/new/templates/rust/no-ui/{hypr-echo => hyperapp-echo}/.gitignore (100%) rename src/new/templates/rust/no-ui/{hypr-echo => hyperapp-echo}/Cargo.toml (59%) rename src/new/templates/rust/no-ui/{hypr-echo/hypr-echo => hyperapp-echo/hyperapp-echo}/Cargo.toml (95%) rename src/new/templates/rust/no-ui/{hypr-echo/hypr-echo => hyperapp-echo/hyperapp-echo}/src/lib.rs (83%) rename src/new/templates/rust/no-ui/{hypr-echo => hyperapp-echo}/metadata.json (70%) rename src/new/templates/rust/no-ui/{hypr-echo => hyperapp-echo}/pkg/manifest.json (82%) rename src/new/templates/rust/no-ui/{hypr-echo/test/hypr-echo-test => hyperapp-echo/test/hyperapp-echo-test}/Cargo.toml (79%) rename src/new/templates/rust/no-ui/{hypr-echo/test/hypr-echo-test/hypr-echo-test => hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test}/Cargo.toml (94%) rename src/new/templates/rust/no-ui/{hypr-echo/test/hypr-echo-test/hypr-echo-test => hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test}/src/lib.rs (78%) rename src/new/templates/rust/no-ui/{hypr-echo/test/hypr-echo-test/hypr-echo-test => hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test}/src/tester_lib.rs (100%) rename src/new/templates/rust/no-ui/{hypr-echo/test/hypr-echo-test => hyperapp-echo/test/hyperapp-echo-test}/metadata.json (100%) rename src/new/templates/rust/no-ui/{hypr-echo/test/hypr-echo-test => hyperapp-echo/test/hyperapp-echo-test}/pkg/manifest.json (55%) rename src/new/templates/rust/no-ui/{hypr-echo => hyperapp-echo}/test/tests.toml (85%) diff --git a/src/new/templates/rust/no-ui/hypr-echo/.gitignore b/src/new/templates/rust/no-ui/hyperapp-echo/.gitignore similarity index 100% rename from src/new/templates/rust/no-ui/hypr-echo/.gitignore rename to src/new/templates/rust/no-ui/hyperapp-echo/.gitignore diff --git a/src/new/templates/rust/no-ui/hypr-echo/Cargo.toml b/src/new/templates/rust/no-ui/hyperapp-echo/Cargo.toml similarity index 59% rename from src/new/templates/rust/no-ui/hypr-echo/Cargo.toml rename to src/new/templates/rust/no-ui/hyperapp-echo/Cargo.toml index f2551454..614cee7d 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/Cargo.toml +++ b/src/new/templates/rust/no-ui/hyperapp-echo/Cargo.toml @@ -5,7 +5,7 @@ panic = "abort" [workspace] members = [ - "hypr-echo", - "test/hypr-echo-test/hypr-echo-test", + "hyperapp-echo", + "test/hyperapp-echo-test/hyperapp-echo-test", ] resolver = "2" diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml b/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/Cargo.toml similarity index 95% rename from src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml rename to src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/Cargo.toml index 44ee8604..81b1ddaf 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/Cargo.toml +++ b/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/Cargo.toml @@ -24,7 +24,7 @@ crate-type = ["cdylib"] [package] edition = "2021" -name = "hypr-echo" +name = "hyperapp-echo" version = "0.1.0" [package.metadata.component] diff --git a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs b/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs similarity index 83% rename from src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs rename to src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs index 5cb07a8c..a38c67b0 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/hypr-echo/src/lib.rs +++ b/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs @@ -1,12 +1,14 @@ use serde::{Serialize, Deserialize}; use hyperware_process_lib::{ LazyLoadBlob, - http::server::{WsMessageType, send_ws_push} + http::server::{WsMessageType, send_ws_push}, + homepage::add_to_homepage, }; use hyperprocess_macro::hyperprocess; + #[derive(Default, Debug, Serialize, Deserialize)] -pub struct HyprEchoState {} +pub struct HyperappEchoState {} #[derive(Serialize, Deserialize, Debug)] pub struct Argument { @@ -20,7 +22,7 @@ pub struct ReturnValue { } #[hyperprocess( - name = "HyprEcho", + name = "HyperappEcho", ui = None, endpoints = vec![ Binding::Http { @@ -33,14 +35,15 @@ pub struct ReturnValue { } ], save_config = SaveOptions::Never, - wit_world = "hypr-echo-template-dot-os-v0" + wit_world = "hyperapp-echo-template-dot-os-v0" )] -impl HyprEchoState { +impl HyperappEchoState { // Initialize the process, every application needs an init function #[init] async fn initialize(&mut self) { - println!("init HyprEcho"); + println!("init HyperappEcho"); + add_to_homepage("HyperappEcho", Some(ICON), Some(""), None); } // Endpoint accepting both local, remote Hyperware requests, and HTTP requests diff --git a/src/new/templates/rust/no-ui/hypr-echo/metadata.json b/src/new/templates/rust/no-ui/hyperapp-echo/metadata.json similarity index 70% rename from src/new/templates/rust/no-ui/hypr-echo/metadata.json rename to src/new/templates/rust/no-ui/hyperapp-echo/metadata.json index a7a078d2..a099da80 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/metadata.json +++ b/src/new/templates/rust/no-ui/hyperapp-echo/metadata.json @@ -1,9 +1,9 @@ { - "name": "hypr-echo", - "description": "Template process for app framework.", + "name": "Hyperapp Echo", + "description": "Echo process for Hyperapp framework.", "image": "", "properties": { - "package_name": "hypr-echo", + "package_name": "hyperapp-echo", "current_version": "0.1.0", "publisher": "template.os", "mirrors": [], diff --git a/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json b/src/new/templates/rust/no-ui/hyperapp-echo/pkg/manifest.json similarity index 82% rename from src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json rename to src/new/templates/rust/no-ui/hyperapp-echo/pkg/manifest.json index 1f84275d..9f8c6d73 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/pkg/manifest.json +++ b/src/new/templates/rust/no-ui/hyperapp-echo/pkg/manifest.json @@ -1,7 +1,7 @@ [ { - "process_name": "hypr-echo", - "process_wasm_path": "/hypr-echo.wasm", + "process_name": "hyperapp-echo", + "process_wasm_path": "/hyperapp-echo.wasm", "on_exit": "Restart", "request_networking": true, "request_capabilities": [ diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/Cargo.toml b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/Cargo.toml similarity index 79% rename from src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/Cargo.toml rename to src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/Cargo.toml index 33760e0c..06be6286 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/Cargo.toml +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" members = [ - "hypr-echo-test", + "hyperapp-echo-test", ] [profile.release] diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/Cargo.toml similarity index 94% rename from src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml rename to src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/Cargo.toml index 7c8b7bd4..e88dcc54 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/Cargo.toml +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "hypr-echo-test" +name = "hyperapp-echo-test" version = "0.1.0" edition = "2021" publish = false diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/lib.rs b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/lib.rs similarity index 78% rename from src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/lib.rs rename to src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/lib.rs index 47d74fd5..15426489 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/lib.rs +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/lib.rs @@ -5,7 +5,7 @@ mod tester_lib; use hyperware_app_common::SendResult; async_test_suite!( - "test-hypr-echo-template-dot-os-v0", + "test-hyperapp-echo-template-dot-os-v0", test_basic_math: async { if 2 + 2 != 4 { @@ -16,7 +16,7 @@ async_test_suite!( // Test local add call test_local_add_call: async { - let address: Address = ("hypr-echo.os", "hypr-echo", "hypr-echo", "template.os").into(); + let address: Address = ("hyperapp-echo.os", "hyperapp-echo", "hyperapp-echo", "template.os").into(); let value = "World".to_string(); // Pass only the value, matching the generated stub signature let result = add_to_state_local_rpc(&address, value).await; @@ -27,7 +27,7 @@ async_test_suite!( // Test local get call test_local_get_call: async { - let address: Address = ("hypr-echo.os", "hypr-echo", "hypr-echo", "template.os").into(); + let address: Address = ("hyperapp-echo.os", "hyperapp-echo", "hyperapp-echo", "template.os").into(); let result = get_state_local_rpc(&address).await; print_to_terminal(0, &format!("get_state_local_rpc result: {:?}", result)); // Assuming the call should succeed diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/tester_lib.rs b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/tester_lib.rs similarity index 100% rename from src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/hypr-echo-test/src/tester_lib.rs rename to src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/tester_lib.rs diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/metadata.json b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/metadata.json similarity index 100% rename from src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/metadata.json rename to src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/metadata.json diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/pkg/manifest.json similarity index 55% rename from src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json rename to src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/pkg/manifest.json index 90ef3129..5634e8c3 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/test/hypr-echo-test/pkg/manifest.json +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/pkg/manifest.json @@ -1,16 +1,16 @@ [ { - "process_name": "hypr-echo-test", - "process_wasm_path": "/hypr-echo-test.wasm", + "process_name": "hyperapp-echo-test", + "process_wasm_path": "/hyperapp-echo-test.wasm", "on_exit": "None", "request_networking": true, "request_capabilities": [ "http-client:distro:sys", - "hypr-echo:hypr-echo:template.os" + "hyperapp-echo:hyperapp-echo:template.os" ], "grant_capabilities": [ "http-client:distro:sys", - "hypr-echo:hypr-echo:template.os" + "hyperapp-echo:hyperapp-echo:template.os" ], "public": true } diff --git a/src/new/templates/rust/no-ui/hypr-echo/test/tests.toml b/src/new/templates/rust/no-ui/hyperapp-echo/test/tests.toml similarity index 85% rename from src/new/templates/rust/no-ui/hypr-echo/test/tests.toml rename to src/new/templates/rust/no-ui/hyperapp-echo/test/tests.toml index fb74cd14..f7ff0995 100644 --- a/src/new/templates/rust/no-ui/hypr-echo/test/tests.toml +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/tests.toml @@ -17,6 +17,6 @@ hyperapp = true [[tests.nodes]] port = 8080 -home = "home/hypr-echo-test" -fake_node_name = "hypr-echo.os" +home = "home/hyperapp-echo-test" +fake_node_name = "hyperapp-echo.os" runtime_verbosity = 2 From 829d953efff5a5709ce71f3f2807bf683d7c8dd6 Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:36:10 -0400 Subject: [PATCH 08/11] Updated template naming convetions --- src/main.rs | 2 +- src/new/mod.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0b5a8b34..6a1b6dc1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1066,7 +1066,7 @@ async fn make_app(current_dir: &std::ffi::OsString) -> Result { .short('t') .long("template") .help("Template to create") - .value_parser(["blank", "chat", "echo", "fibonacci", "file-transfer", "hypr-echo"]) + .value_parser(["blank", "chat", "echo", "fibonacci", "file-transfer", "hyperapp-echo"]) .default_value("chat") ) .arg(Arg::new("UI") diff --git a/src/new/mod.rs b/src/new/mod.rs index fe332146..eefb9c08 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -23,7 +23,7 @@ pub enum Template { Echo, Fibonacci, FileTransfer, - HyprEcho, + HyperappEcho, } impl Language { @@ -45,7 +45,7 @@ impl Template { Template::Echo => "echo", Template::Fibonacci => "fibonacci", Template::FileTransfer => "file-transfer", - Template::HyprEcho => "hypr-echo", + Template::HyperappEcho => "hyperapp-echo", } .to_string() } @@ -70,8 +70,8 @@ impl From<&String> for Template { "echo" => Template::Echo, "fibonacci" => Template::Fibonacci, "file-transfer" => Template::FileTransfer, - "hypr-echo" => Template::HyprEcho, - _ => panic!("kit: template must be 'blank', 'chat', 'echo', 'fibonacci', or 'hypr-echo'; not '{s}'"), + "hyperapp-echo" => Template::HyperappEcho, + _ => panic!("kit: template must be 'blank', 'chat', 'echo', 'fibonacci', or 'hyperapp-echo'; not '{s}'"), } } } From bc18f24c54a1cf63a6565af2b2b2c870c8e92a06 Mon Sep 17 00:00:00 2001 From: Gohlub <62673775+Gohlub@users.noreply.github.com> Date: Thu, 24 Apr 2025 21:32:51 -0400 Subject: [PATCH 09/11] Got tests to Work! along with some other small bug fixes --- src/new/mod.rs | 9 + .../rust/no-ui/hyperapp-echo/.gitignore | 1 + .../hyperapp-echo/hyperapp-echo/src/lib.rs | 24 +-- .../rust/no-ui/hyperapp-echo/metadata.json | 1 + .../hyperapp-echo-test-template-dot-os-v0.wit | 5 + .../hyper-app-echo-test/src/lib.rs | 37 ---- .../Cargo.toml | 11 +- .../hyperapp-echo-test/src/lib.rs | 88 ++++++++++ .../src/tester_lib.rs | 159 +++++++++--------- .../test/hyperapp-echo-test/metadata.json | 6 +- .../rust/no-ui/hyperapp-echo/test/tests.toml | 8 +- 11 files changed, 206 insertions(+), 143 deletions(-) create mode 100644 src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/api/hyperapp-echo-test-template-dot-os-v0.wit delete mode 100644 src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/lib.rs rename src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/{hyper-app-echo-test => hyperapp-echo-test}/Cargo.toml (62%) create mode 100644 src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/src/lib.rs rename src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/{hyper-app-echo-test => hyperapp-echo-test}/src/tester_lib.rs (57%) diff --git a/src/new/mod.rs b/src/new/mod.rs index eefb9c08..9fa4a19b 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -318,6 +318,15 @@ pub fn execute( ); let ui_prefix = format!("{}/{}/", ui_infix, template.to_string()); let test_prefix = format!("test/{}/", template.to_string()); + + + println!("DEBUG: PATH_TO_CONTENT keys related to hyperapp-echo:"); + for (path, _) in PATH_TO_CONTENT.iter() { + if path.contains("hyperapp-echo") { + println!(" {}", path); + } + } + let mut path_to_content: HashMap = PATH_TO_CONTENT .iter() .filter_map(|(path, content)| { diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/.gitignore b/src/new/templates/rust/no-ui/hyperapp-echo/.gitignore index b2a2ce0f..e0f310c9 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/.gitignore +++ b/src/new/templates/rust/no-ui/hyperapp-echo/.gitignore @@ -1,4 +1,5 @@ api +!test/hyperapp-echo-test/api *swp **/target pkg/*.wasm diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs b/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs index a38c67b0..d126a45a 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs +++ b/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs @@ -1,9 +1,4 @@ use serde::{Serialize, Deserialize}; -use hyperware_process_lib::{ - LazyLoadBlob, - http::server::{WsMessageType, send_ws_push}, - homepage::add_to_homepage, -}; use hyperprocess_macro::hyperprocess; @@ -18,7 +13,7 @@ pub struct Argument { #[derive(Serialize, Deserialize, Debug)] pub struct ReturnValue { - result: String, + response: String, } #[hyperprocess( @@ -43,7 +38,6 @@ impl HyperappEchoState { #[init] async fn initialize(&mut self) { println!("init HyperappEcho"); - add_to_homepage("HyperappEcho", Some(ICON), Some(""), None); } // Endpoint accepting both local, remote Hyperware requests, and HTTP requests @@ -53,21 +47,7 @@ impl HyperappEchoState { async fn echo(&self, arg: Argument) -> ReturnValue { println!("header: {:?}, body: {:?}", arg.header, arg.body); - ReturnValue { result: "Ack".to_string() } + ReturnValue { response: "Ack".to_string() } } - // Endpoint accepting WebSocket requests - #[ws] - async fn ws_echo(&mut self, channel_id: u32, message_type: WsMessageType, blob: LazyLoadBlob) { - println!("got: type={:?}, blob={:?}", message_type, blob); - - send_ws_push( - channel_id, - WsMessageType::Text, - LazyLoadBlob { - mime: Some("application/json".to_string()), - bytes: serde_json::to_vec("Ack").unwrap(), - }, - ); - } } diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/metadata.json b/src/new/templates/rust/no-ui/hyperapp-echo/metadata.json index a099da80..b63ff4c2 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/metadata.json +++ b/src/new/templates/rust/no-ui/hyperapp-echo/metadata.json @@ -12,6 +12,7 @@ }, "wit_version": 1, "dependencies": [ + "hyperapp-echo:template.os" ] }, "external_url": "https://hyperware.ai", diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/api/hyperapp-echo-test-template-dot-os-v0.wit b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/api/hyperapp-echo-test-template-dot-os-v0.wit new file mode 100644 index 00000000..ff00f125 --- /dev/null +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/api/hyperapp-echo-test-template-dot-os-v0.wit @@ -0,0 +1,5 @@ +world hyperapp-echo-test-template-dot-os-v0 { + import hyperapp-echo; + import tester; + include process-v1; +} \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/lib.rs b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/lib.rs deleted file mode 100644 index 15426489..00000000 --- a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/lib.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::hyperware::process::tester::{FailResponse, Response as TesterResponse}; -use caller_utils::hyperprocess::*; -mod tester_lib; - -use hyperware_app_common::SendResult; - -async_test_suite!( - "test-hyperapp-echo-template-dot-os-v0", - - test_basic_math: async { - if 2 + 2 != 4 { - fail!("wrong result"); - } - Ok(()) - }, - - // Test local add call - test_local_add_call: async { - let address: Address = ("hyperapp-echo.os", "hyperapp-echo", "hyperapp-echo", "template.os").into(); - let value = "World".to_string(); - // Pass only the value, matching the generated stub signature - let result = add_to_state_local_rpc(&address, value).await; - print_to_terminal(0, &format!("add_to_state_local_rpc result: {:?}", result)); - // Assuming the call should succeed - Ok(()) - }, - - // Test local get call - test_local_get_call: async { - let address: Address = ("hyperapp-echo.os", "hyperapp-echo", "hyperapp-echo", "template.os").into(); - let result = get_state_local_rpc(&address).await; - print_to_terminal(0, &format!("get_state_local_rpc result: {:?}", result)); - // Assuming the call should succeed - - Ok(()) - }, -); \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/Cargo.toml b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/Cargo.toml similarity index 62% rename from src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/Cargo.toml rename to src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/Cargo.toml index e88dcc54..5b0b6481 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/Cargo.toml +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/Cargo.toml @@ -4,15 +4,22 @@ version = "0.1.0" edition = "2021" publish = false +[dependencies.caller-utils] +path = "../../../target/caller-utils" + +[dependencies.hyperware_app_common] +git = "https://github.com/hyperware-ai/hyperprocess-macro" +rev = "b6ad495" + [dependencies] anyhow = "1.0" -hyperware_app_common = { git = "https://github.com/hyperware-ai/hyperprocess-macro" } -hyperware_process_lib = { git = "https://github.com/hyperware-ai/hyperprocess-macro" } +hyperware_process_lib = { git = "https://github.com/hyperware-ai/process_lib", features = ["logging"], rev = "b7c9d27" } process_macros = "0.1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" wit-bindgen = "0.36.0" + [lib] crate-type = ["cdylib"] diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/src/lib.rs b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/src/lib.rs new file mode 100644 index 00000000..be99297f --- /dev/null +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/src/lib.rs @@ -0,0 +1,88 @@ +// Import necessary types and functions explicitly from caller_utils +use caller_utils::{Argument, ReturnValue}; // Import types directly (via path dependency) +use caller_utils::hyperapp_echo::{echo_local_rpc, echo_remote_rpc}; // Import RPC functions + +// Add this import here, as fail! is expanded in this file +use crate::hyperware::process::tester::{FailResponse, Response as TesterResponse}; + +mod tester_lib; + +async_test_suite!( + "hyperapp-echo-test-template-dot-os-v0", + + test_basic_math: async { + if 2 + 2 != 4 { + fail!("wrong result"); + } + Ok(()) + }, + + // Test local echo RPC call + test_echo_local_rpc: async { + // Define the target process address + let address: Address = ("hyperapp-echo.os", "hyperapp-echo", "hyperapp-echo", "template.os").into(); + // Define the argument for the echo function + let arg = Argument { + header: "LocalTestHeader".to_string(), + body: "LocalTestBody".to_string(), + }; + // Define the expected return value + let expected_return = ReturnValue { + response: "Ack".to_string(), + }; + + match echo_local_rpc(&address, arg).await { + Ok(actual_value) => { + // Compare the 'response' field directly + if actual_value.response != expected_return.response { + // fail! macro uses FailResponse/TesterResponse imported above + fail!(format!( + "echo_local_rpc unexpected result: expected {:?}, got {:?}", + expected_return, actual_value // Keep original structs for error message + )); + } + // If the result matches, the test passes for this step + Ok(()) + } + Err(e) => { + // Use fail! macro if the RPC call itself returned an error + fail!(format!("echo_local_rpc failed: {:?}", e)); + } + } + }, + + // Test remote echo RPC call + test_echo_remote_rpc: async { + // Define the target process address + let address: Address = ("hyperapp-echo.os", "hyperapp-echo", "hyperapp-echo", "template.os").into(); + // Define the argument for the echo function + let arg = Argument { + header: "RemoteTestHeader".to_string(), + body: "RemoteTestBody".to_string(), + }; + // Define the expected return value + let expected_return = ReturnValue { + response: "Ack".to_string(), + }; + + // Call the remote echo RPC stub + match echo_remote_rpc(&address, arg).await { + Ok(actual_value) => { + // Compare the 'response' field directly + if actual_value.response != expected_return.response { + // fail! macro uses FailResponse/TesterResponse imported above + fail!(format!( + "echo_remote_rpc unexpected result: expected {:?}, got {:?}", + expected_return, actual_value // Keep original structs for error message + )); + } + // If the result matches, the test passes for this step + Ok(()) + } + Err(e) => { + // Use fail! macro if the RPC call itself returned an error + fail!(format!("echo_remote_rpc failed: {:?}", e)); + } + } + }, +); \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/tester_lib.rs b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/src/tester_lib.rs similarity index 57% rename from src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/tester_lib.rs rename to src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/src/tester_lib.rs index 9bf7fe75..1ce18437 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyper-app-echo-test/src/tester_lib.rs +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/hyperapp-echo-test/src/tester_lib.rs @@ -1,13 +1,10 @@ -#[allow(unused_imports)] -use crate::hyperware::process::tester::{FailResponse, Response as TesterResponse}; -use hyperware_process_lib::Response; -use hyperware_app_common::SendResult; - #[macro_export] macro_rules! fail { ($test:expr) => { - Response::new() - .body(TesterResponse::Run(Err(FailResponse { + // Use the unified hyperware_process_lib::Response now available via Cargo.toml + hyperware_process_lib::Response::new() + // Use the types from the macro invocation site (src/lib.rs) + .body(TesterResponse::Run(Err(FailResponse { test: $test.into(), file: file!().into(), line: line!(), @@ -18,8 +15,10 @@ macro_rules! fail { panic!("") }; ($test:expr, $file:expr, $line:expr, $column:expr) => { - Response::new() - .body(TesterResponse::Run(Err(FailResponse { + // Use the unified hyperware_process_lib::Response now available via Cargo.toml + hyperware_process_lib::Response::new() + // Use the types from the macro invocation site (src/lib.rs) + .body(TesterResponse::Run(Err(FailResponse { test: $test.into(), file: $file.into(), line: $line, @@ -35,15 +34,18 @@ macro_rules! fail { macro_rules! async_test_suite { ($wit_world:expr, $($test_name:ident: async $test_body:block),* $(,)?) => { wit_bindgen::generate!({ - path: "target/wit", + path: "../target/wit", world: $wit_world, generate_unused_types: true, additional_derives: [PartialEq, serde::Deserialize, serde::Serialize, process_macros::SerdeJsonInto], }); - use hyperware_process_lib::{ - await_message, call_init, print_to_terminal, Address, Response + // Use items from the unified hyperware_process_lib now available via Cargo.toml + use hyperware_process_lib::{ + await_message, call_init, print_to_terminal, Address, Message, Response, SendError }; + // Use items from the hyperware_app_common now available via Cargo.toml + use hyperware_app_common::{APP_CONTEXT, RESPONSE_REGISTRY, hyper}; $( async fn $test_name() -> anyhow::Result<()> { @@ -79,24 +81,25 @@ macro_rules! async_test_suite { // Main event loop loop { // Poll tasks to advance the executor - hyperware_app_common::APP_CONTEXT.with(|ctx| { + APP_CONTEXT.with(|ctx| { ctx.borrow_mut().executor.poll_all_tasks(); }); // First, process any messages to handle RPC responses match await_message() { Ok(message) => { + // Message should resolve from the `use` statement above match message { - hyperware_process_lib::Message::Response {body, context, ..} => { - // Handle responses to unblock waiting futures + Message::Response {body, context, ..} => { + // Handle responses to unblock waiting futures let correlation_id = context .as_deref() .map(|bytes| String::from_utf8_lossy(bytes).to_string()) .unwrap_or_else(|| "no context".to_string()); - print_to_terminal(0, &format!("Received response with ID: {}", correlation_id)); + print_to_terminal(0, &format!("Received response with ID: {}", correlation_id)); - hyperware_app_common::RESPONSE_REGISTRY.with(|registry| { + RESPONSE_REGISTRY.with(|registry| { let mut registry_mut = registry.borrow_mut(); registry_mut.insert(correlation_id, body); }); @@ -105,26 +108,25 @@ macro_rules! async_test_suite { // The first request triggers test execution if !tests_triggered { tests_triggered = true; - print_to_terminal(0, "Received initial request, starting tests..."); + print_to_terminal(0, "Received initial request, starting tests..."); - // Start the test suite - hyperware_app_common::hyper! { + hyper! { match run_all_tests().await { Ok(()) => { - // All tests passed - send success response - print_to_terminal(0, "Tests completed successfully!"); - Response::new() - .body(TesterResponse::Run(Ok(()))) + print_to_terminal(0, "Tests completed successfully!"); + // Response should resolve from the `use` statement above + // TesterResponse needs to resolve from the macro invocation site (src/lib.rs) + Response::new() + .body(TesterResponse::Run(Ok(()))) .send() .unwrap_or_else(|e| { - print_to_terminal(0, &format!("Failed to send success response: {:?}", e)); + print_to_terminal(0, &format!("Failed to send success response: {:?}", e)); }); }, Err(e) => { - // Tests failed - send failure response - print_to_terminal(0, &format!("Test suite failed: {:?}", e)); - crate::fail!(&format!("Test failure: {:?}", e)); - } + print_to_terminal(0, &format!("Test suite failed: {:?}", e)); + // fail! macro uses types imported in src/lib.rs + crate::fail!(&format!("Test failure: {:?}", e)); } } } } @@ -133,65 +135,66 @@ macro_rules! async_test_suite { } }, Err(e) => { - // Handle send errors to unblock futures that are waiting for responses - if let hyperware_process_lib::SendError { - kind, - context: Some(context), - .. - } = &e - { - if let Ok(correlation_id) = String::from_utf8(context.to_vec()) { + // Handle send errors to unblock futures that are waiting for responses + // SendError should resolve from the `use` statement above + if let SendError { + kind, + context: Some(context), + .. + } = &e + { + if let Ok(correlation_id) = String::from_utf8(context.clone()) { let error_response = serde_json::to_vec(kind).unwrap(); - - hyperware_app_common::RESPONSE_REGISTRY.with(|registry| { + + RESPONSE_REGISTRY.with(|registry| { let mut registry_mut = registry.borrow_mut(); registry_mut.insert(correlation_id, error_response); }); } } - - print_to_terminal(0, &format!("Message error: {:?}", e)); + + print_to_terminal(0, &format!("Message error: {:?}", e)); } } } } }; } - -/// Helper function to test remote RPC calls -/// -/// This function handles: -/// 1. Checking if the call was successful -/// 2. Validating the returned value against an expected value -/// 3. Handling error cases with appropriate failure messages -/// -/// Returns the actual value if successful, allowing it to be used in subsequent operations -pub async fn test_remote_call( - call_future: F, - expected_value: T, - error_msg: &str, -) -> anyhow::Result -where - T: std::cmp::PartialEq + std::fmt::Debug + Clone, - F: std::future::Future>, -{ - let result = call_future.await; +// TODO: SendResult does not exist anymore +// Helper function to test remote RPC calls +// +// This function handles: +// 1. Checking if the call was successful +// 2. Validating the returned value against an expected value +// 3. Handling error cases with appropriate failure messages +// +// Returns the actual value if successful, allowing it to be used in subsequent operations +// pub async fn test_remote_call( +// call_future: F, +// expected_value: T, +// error_msg: &str, +// ) -> anyhow::Result +// where +// T: std::cmp::PartialEq + std::fmt::Debug + Clone, +// F: std::future::Future>, +// { +// let result = call_future.await; - match result { - SendResult::Success(actual) => { - if actual != expected_value { - fail!(format!("{}: expected {:?}, got {:?}", error_msg, expected_value, actual)); - } - // Return the actual value - Ok(actual) - } - _ => { - fail!(match result { - SendResult::Timeout => "timeout", - SendResult::Offline => "offline", - SendResult::DeserializationError(_) => "deserialization error", - _ => "unknown error", - }); - } - } -} \ No newline at end of file +// match result { +// SendResult::Success(actual) => { +// if actual != expected_value { +// fail!(format!("{}: expected {:?}, got {:?}", error_msg, expected_value, actual)); +// } +// // Return the actual value +// Ok(actual) +// } +// _ => { +// fail!(match result { +// SendResult::Timeout => "timeout", +// SendResult::Offline => "offline", +// SendResult::DeserializationError(_) => "deserialization error", +// _ => "unknown error", +// }); +// } +// } +// } \ No newline at end of file diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/metadata.json b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/metadata.json index 676fccdf..e7bf7ba1 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/metadata.json +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/hyperapp-echo-test/metadata.json @@ -1,9 +1,9 @@ { - "name": "HyprEcho Test", + "name": "Hyperapp Echo Test", "description": "A test showcasing the hyperware app framework.", "image": "", "properties": { - "package_name": "hypr-echo-test", + "package_name": "hyperapp-echo-test", "current_version": "0.1.0", "publisher": "template.os", "mirrors": [], @@ -12,7 +12,7 @@ }, "wit_version": 1, "dependencies": [ - "hypr-echo:template.os", + "hyperapp-echo:template.os", "tester:sys" ] }, diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/test/tests.toml b/src/new/templates/rust/no-ui/hyperapp-echo/test/tests.toml index f7ff0995..a193d864 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/test/tests.toml +++ b/src/new/templates/rust/no-ui/hyperapp-echo/test/tests.toml @@ -8,7 +8,7 @@ always_print_node_output = false dependency_package_paths = [".."] setup_packages = [{ path = "..", run = true }] setup_scripts = [] -test_package_paths = ["hypr-echo-test"] +test_package_paths = ["hyperapp-echo-test"] test_scripts = [] timeout_secs = 35 fakechain_router = 8545 @@ -18,5 +18,11 @@ hyperapp = true [[tests.nodes]] port = 8080 home = "home/hyperapp-echo-test" +fake_node_name = "host.os" +runtime_verbosity = 2 + +[[tests.nodes]] +port = 8081 +home = "home/hyperapp-echo-test" fake_node_name = "hyperapp-echo.os" runtime_verbosity = 2 From 489b772800fb70109bbec6c253f974450b2a9b73 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 25 Apr 2025 01:33:16 +0000 Subject: [PATCH 10/11] Format Rust code using rustfmt --- src/new/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/new/mod.rs b/src/new/mod.rs index 9fa4a19b..234658a2 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -319,14 +319,13 @@ pub fn execute( let ui_prefix = format!("{}/{}/", ui_infix, template.to_string()); let test_prefix = format!("test/{}/", template.to_string()); - println!("DEBUG: PATH_TO_CONTENT keys related to hyperapp-echo:"); for (path, _) in PATH_TO_CONTENT.iter() { if path.contains("hyperapp-echo") { println!(" {}", path); } } - + let mut path_to_content: HashMap = PATH_TO_CONTENT .iter() .filter_map(|(path, content)| { From 321f2526665538e614bdffd9df233005d6c12348 Mon Sep 17 00:00:00 2001 From: hosted-fornet Date: Mon, 5 May 2025 17:10:33 -0700 Subject: [PATCH 11/11] new: tweak hyperapp-echo --- src/new/mod.rs | 10 +--------- .../rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs | 2 +- .../rust/no-ui/hyperapp-echo/pkg/manifest.json | 2 ++ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/new/mod.rs b/src/new/mod.rs index 234658a2..497b4440 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -70,7 +70,7 @@ impl From<&String> for Template { "echo" => Template::Echo, "fibonacci" => Template::Fibonacci, "file-transfer" => Template::FileTransfer, - "hyperapp-echo" => Template::HyperappEcho, + "hyperapp-echo" => Template::HyperappEcho, _ => panic!("kit: template must be 'blank', 'chat', 'echo', 'fibonacci', or 'hyperapp-echo'; not '{s}'"), } } @@ -318,14 +318,6 @@ pub fn execute( ); let ui_prefix = format!("{}/{}/", ui_infix, template.to_string()); let test_prefix = format!("test/{}/", template.to_string()); - - println!("DEBUG: PATH_TO_CONTENT keys related to hyperapp-echo:"); - for (path, _) in PATH_TO_CONTENT.iter() { - if path.contains("hyperapp-echo") { - println!(" {}", path); - } - } - let mut path_to_content: HashMap = PATH_TO_CONTENT .iter() .filter_map(|(path, content)| { diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs b/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs index d126a45a..7369d5df 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs +++ b/src/new/templates/rust/no-ui/hyperapp-echo/hyperapp-echo/src/lib.rs @@ -1,6 +1,6 @@ use serde::{Serialize, Deserialize}; use hyperprocess_macro::hyperprocess; - +use hyperware_process_lib::println; #[derive(Default, Debug, Serialize, Deserialize)] pub struct HyperappEchoState {} diff --git a/src/new/templates/rust/no-ui/hyperapp-echo/pkg/manifest.json b/src/new/templates/rust/no-ui/hyperapp-echo/pkg/manifest.json index 9f8c6d73..98f17d2a 100644 --- a/src/new/templates/rust/no-ui/hyperapp-echo/pkg/manifest.json +++ b/src/new/templates/rust/no-ui/hyperapp-echo/pkg/manifest.json @@ -8,12 +8,14 @@ "homepage:homepage:sys", "http-client:distro:sys", "http-server:distro:sys", + "terminal:terminal:sys", "vfs:distro:sys" ], "grant_capabilities": [ "homepage:homepage:sys", "http-client:distro:sys", "http-server:distro:sys", + "terminal:terminal:sys", "vfs:distro:sys" ], "public": false