aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/tests/rpc_pubsub_impl.rs
blob: 9d2eb5764832195084d4c71c7968b8f45b626846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
}