Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc module): failed unsubscribe should be logged in middleware #792

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

niklasad1
Copy link
Member

No description provided.

@niklasad1 niklasad1 requested a review from a team as a code owner June 13, 2022 09:34
@@ -311,3 +315,46 @@ async fn subscribing_without_server_bad_params() {
matches!(sub, Error::Call(CallError::Custom(e)) if e.message().contains("invalid length 0, expected an array of length 1 at line 1 column 2") && e.code() == ErrorCode::InvalidParams.code())
);
}

#[tokio::test]
async fn subscribe_unsubscribe_without_server() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is more or less copied from https://github.com/paritytech/substrate/blob/master/client/beefy/rpc/src/lib.rs#L245-#L269

I have tried to debug it but doesn't hurt to have that test here as well

@@ -60,7 +60,7 @@ pub type AsyncMethod<'a> = Arc<
dyn Send + Sync + Fn(Id<'a>, Params<'a>, MethodSink, ConnectionId, Option<ResourceGuard>) -> BoxFuture<'a, bool>,
>;
/// Method callback for subscriptions.
pub type SubscriptionMethod = Arc<dyn Send + Sync + Fn(Id, Params, &MethodSink, ConnState) -> bool>;
pub type SubscriptionMethod = Arc<dyn Send + Sync + Fn(Id, Params, MethodSink, ConnState) -> bool>;
Copy link
Member Author

@niklasad1 niklasad1 Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to indicate that the subscription takes ownership of the sink

it was cloned under the hood before, this should make it clear that it will be alive as long as the subscription callback is alive.

Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@niklasad1 niklasad1 merged commit 6888804 into master Jun 13, 2022
@niklasad1 niklasad1 deleted the add-test-subscribe-unsubscibe-rpc-module branch June 13, 2022 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants