forked from jl777/SuperNET
-
Notifications
You must be signed in to change notification settings - Fork 116
improvement(RPC): unified interface for legacy and current RPC interfaces #2450
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
05544a7
re-write legacy `process_single_request`
onur-ozkan 5dc1cd8
provide unified RPC interface for clients
onur-ozkan b2e7184
remove `mmrpc` from various tests to have a coverage on recent change
onur-ozkan 52b6889
use `ERR` macro instead of `ERRL`
onur-ozkan 1083d11
remove unknown method test for legacy dispatcher
onur-ozkan 7523eb2
add info log
onur-ozkan da1d183
nit
onur-ozkan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,16 +53,6 @@ cfg_wasm32! { | |
| fn test_rpc() { | ||
| let (_, mm, _dump_log, _dump_dashboard) = mm_spat(); | ||
|
|
||
| let no_method = block_on(mm.rpc(&json! ({ | ||
| "userpass": mm.userpass, | ||
| "coin": "RICK", | ||
| "ipaddr": "electrum1.cipig.net", | ||
| "port": 10017 | ||
| }))) | ||
| .unwrap(); | ||
| assert!(no_method.0.is_server_error()); | ||
| assert_eq!((no_method.2)[ACCESS_CONTROL_ALLOW_ORIGIN], "http://localhost:4000"); | ||
|
Comment on lines
-56
to
-64
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was testing unknown methods on the legacy dispatcher (not very useful to cover to be honest). The behavior for unknown RPCs in the legacy dispatcher has changed: if a method isn't found there, we now try to find it in the current dispatcher. |
||
|
|
||
| let not_json = mm.rpc_str("It's just a string").unwrap(); | ||
| assert!(not_json.0.is_server_error()); | ||
| assert_eq!((not_json.2)[ACCESS_CONTROL_ALLOW_ORIGIN], "http://localhost:4000"); | ||
|
|
||
Oops, something went wrong.
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.
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.
Should we not first try rpc version 2 rather than legacy?
to make preference for v2, in case of identical rpc name for v2 and legacy
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.
This approach will cause BC on identical RPC names as they don't set
mmrpcfield.