This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
[WIP] 3116 valid number rpc params #1901
Open
pscott
wants to merge
16
commits into
PegaSysEng:master
Choose a base branch
from
pscott:3116_valid_number_rpc_params
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
01dd65f
Add asserthLength method in JsonRpcRequest
pscott e232db7
Add example of assertLength usage for eth_ method
pscott 4c11e7d
Add example of assertLength usage for eea_ method
pscott 0e5ca39
Add example of assertLength usage for priv_ method
pscott 66c551b
Add TooManyParams test for getUncleCountByBlockNumber
pscott 0dad4d2
Change assertLength method name to assertMaxLength
pscott 85e5d6c
Add TooManyParams test for EeaGetTransactionCount
pscott 33074ff
Add TooManyParams test for PrivGetPrivateTransaction
pscott 2ceab4e
Change variable name of extra variable in TooManyParams test
pscott 1b6e925
Add TooManyParams for PrivCreatePrivacyGroupTest
pscott 3ef41b5
Remove capital t on TooManyParams; Move assertion for tooManyParams b…
pscott c013432
Implement and test tooManyParams for priv_GetTransactionCount
pscott bcdb4e5
Implement and test tooManyParams for priv_GetPrivacyPrecompileAddress
pscott 6500447
Implement and test tooManyParams for eea_sendRawTransaction
pscott aa6a97c
Implement and test tooManyParams for eea_getTransactionReceipt
pscott 124261f
Standardize tooManyParams naming convention
pscott 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
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.
I'd suggest reworking the structure of this code a bit by:
int getMaxAllowedParams()
to theJsonRpcMethod
interfacedefault
methodassertValidRequest(JsonRpcRequest request)
toJsonRpcMethod
that throws anInvalidJsonRcpParameters
exception as you have here if there are too many paramsjsonRpcMethod.assertValidRequest(request)
before executingjsonRpcMethod.response(request)
inJsonRpcHttpService
This will make it straightforward to consistently enforce this validation without expecting every method to run these checks manually. And it allows methods to override the default validation if necessary.
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.
Thank you so much! Definitely a better code structure, I will do my best to implement it.
Quick question : should I still manually add a tooManyParams test for every method, or should I just add one test for one method and "assume" that it will be correct for other methods ?
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.
Seems kind of painful to handcraft tests for every method. But if there was some way to "automatically" test each method, that would be cool. One idea:
Otherwise, I think we can probably get away with just adding a single test to
JsonRpcHttpServiceTest
.