diff options
Diffstat (limited to 'jsonrpc/tests/rpc_pubsub_impl.rs')
-rw-r--r-- | jsonrpc/tests/rpc_pubsub_impl.rs | 30 |
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 +} |