From 3c55168b72c022b618822c7993b7692f583506db Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sun, 30 Jun 2024 20:03:02 +0200 Subject: jsonrpc: remove redundant macro codes in the main crate and clean up internal proc macros --- jsonrpc/tests/rpc_pubsub_impl.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 jsonrpc/tests/rpc_pubsub_impl.rs (limited to 'jsonrpc/tests/rpc_pubsub_impl.rs') diff --git a/jsonrpc/tests/rpc_pubsub_impl.rs b/jsonrpc/tests/rpc_pubsub_impl.rs new file mode 100644 index 0000000..9d2eb57 --- /dev/null +++ b/jsonrpc/tests/rpc_pubsub_impl.rs @@ -0,0 +1,30 @@ +use std::sync::Arc; + +use karyon_jsonrpc::{rpc_pubsub_impl, Channel, PubSubRPCService, RPCError}; +use serde_json::Value; + +#[test] +fn rpc_pubsub_impl_service() { + struct Foo {} + + #[rpc_pubsub_impl] + impl Foo { + async fn foo( + &self, + _channel: Arc, + _method: String, + params: Value, + ) -> Result { + Ok(params) + } + } + + let f = Arc::new(Foo {}); + + assert!(f.get_pubsub_method("foo").is_some()); + assert!(f.get_pubsub_method("bar").is_none()); + + let _params = serde_json::json!("params"); + + // TODO add more tests here +} -- cgit v1.2.3