aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/tests/rpc_pubsub_impl.rs
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-30 20:03:02 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-30 20:03:02 +0200
commit3c55168b72c022b618822c7993b7692f583506db (patch)
tree146c03f6cc19956ec0acfb7ba26a6202cb5a9647 /jsonrpc/tests/rpc_pubsub_impl.rs
parent2ec4d4a3c3779dc016c8437891f825a54a805808 (diff)
jsonrpc: remove redundant macro codes in the main crate and clean up
internal proc macros
Diffstat (limited to 'jsonrpc/tests/rpc_pubsub_impl.rs')
-rw-r--r--jsonrpc/tests/rpc_pubsub_impl.rs30
1 files changed, 30 insertions, 0 deletions
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<Channel>,
+ _method: String,
+ params: Value,
+ ) -> Result<Value, RPCError> {
+ 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
+}