Unverified Commit 9e8f649f authored by Alexandru Vasile's avatar Alexandru Vasile
Browse files

Test internal subscription sink state


Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>
parent c7b28676
......@@ -348,3 +348,36 @@ async fn subscribe_unsubscribe_without_server() {
futures::future::join(sub1, sub2).await;
}
#[tokio::test]
async fn empty_subscription_without_server() {
let mut module = RpcModule::new(());
module
.register_subscription("my_sub", "my_sub", "my_unsub", |_, mut _sink, _| {
// Sink was never accepted or rejected. Expected to return `InvalidParams`.
Ok(())
})
.unwrap();
let sub_err = module.subscribe("my_sub", EmptyParams::new()).await.unwrap_err();
assert!(
matches!(sub_err, Error::Call(CallError::Custom(e)) if e.message().contains("Invalid params") && e.code() == ErrorCode::InvalidParams.code())
);
}
#[tokio::test]
async fn rejected_subscription_without_server() {
let mut module = RpcModule::new(());
module
.register_subscription("my_sub", "my_sub", "my_unsub", |_, mut sink, _| {
let err = ErrorObject::borrowed(0, &"rejected", None);
sink.reject(err.into_owned())?;
Ok(())
})
.unwrap();
let sub_err = module.subscribe("my_sub", EmptyParams::new()).await.unwrap_err();
assert!(matches!(sub_err, Error::Call(CallError::Custom(e)) if e.message().contains("rejected") && e.code() == 0));
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment