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

Add a test illustrating how to use the call convenience method #443

Closed
wants to merge 3 commits into from

Conversation

dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Aug 26, 2021

This is just me learning the API, not much to see here.

Copy link
Contributor

@maciejhirsz maciejhirsz left a comment

Choose a reason for hiding this comment

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

Looks good, the assert could be less boilerplate-y I think :)

let mut module = RpcModule::new(());
module.register_method("boo", |_: RpcParams, _| Ok(String::from("boo!"))).unwrap();
let result = &module.call("boo", None).await;
assert_eq!(result, &Some(String::from("{\"jsonrpc\":\"2.0\",\"result\":\"boo!\",\"id\":0}")));
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this work:

assert_eq!(result.as_ref(), Some("{\"jsonrpc\":\"2.0\",\"result\":\"boo!\",\"id\":0}"));

Or, since it's a test:

assert_eq!(result.unwrap(), "{\"jsonrpc\":\"2.0\",\"result\":\"boo!\",\"id\":0}");

Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

would be good to a test with the proc macro and param parsing with the issues that you ran into recently

@dvdplm
Copy link
Contributor Author

dvdplm commented Sep 8, 2021

Yeah I'm keeping this open as a "scratch pad" for things I run into. :)

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.

None yet

3 participants