Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[rpc module] test helper for calling and converting types to JSON-RPC params #458
[rpc module] test helper for calling and converting types to JSON-RPC params #458
Changes from 10 commits
e6d8030
87695e3
1eb4d5b
95332be
45cddc0
7967bc3
0f96612
c524e46
a8fb086
e8f44b1
2e1e0b5
0e366ea
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there's only one param provided to the call, and it's something that already serializes to an array like
Vec<u8>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would already be serialized to an array then we won' insert
[
json]
, see if expression above :)However, it could be weird if you put in a
Vec<_>
and expect it to be serialized as[[my vec]]
, lemme double check I forgot if I added a test for this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the case I was picturing; if there's an RPC call that accepts 1 param, a
Vec<u8>
, then I guess I couldn't usetest_call
, because using it would lead to params like[1,2,3]
being passed in instead of a single param like[[1,2,3]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yepp, you are right.
I did it this way to work with both
RpcParams::parse
andRpcParams::Sequence::next()
, but it won't work with doing weird things or that. I guess I was fooled because I usedJsonValue
in the test....Don't remember if I had an issue with the parser to get this work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is an chicken and egg problem it will always be an edge-case for this; so no good solution AFAIU.
Perhaps, I should revisit to try to add
into_rpc_test_module
or something from because this essentially becomes a footgun unless we doif params == edge_case then panic!("not supported")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A call like
test_call
could accept something likeT: IntoRpcParams
, which is implemented for a bunch of tuple sizes (and maybe even slices and arrays) like:That way, You could call eg
.test_call("foo", (a, b, c))
or.test_call("foo", [a])
or.test_call("foo", (a,))
with low overhead?(perhaps something like that exists in JsonRpsee already and I'm not being very helpful; I haven't checked! :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's good idea, I think that's better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I played around with tuples on a branch on saturday and it worked fine up to a point and then didn't. I ended up having to call some permutations with a string and some with a tuple, in the end I abandoned it because it felt like the user would have a deeper understanding of what's going on than I felt was warranted.
That said, it might work out better for you. :)