-
Notifications
You must be signed in to change notification settings - Fork 31
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: validate validator addresses in update-validator-auths proposal #411
Conversation
Codecov Report
@@ Coverage Diff @@
## main #411 +/- ##
=======================================
Coverage ? 54.14%
=======================================
Files ? 687
Lines ? 70331
Branches ? 0
=======================================
Hits ? 38081
Misses ? 29225
Partials ? 3025 |
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.
Reviewed my changes and added some explanations
| `ValidatorAuths` | [QueryValidatorAuthsRequest](#lbm.consortium.v1.QueryValidatorAuthsRequest) | [QueryValidatorAuthsResponse](#lbm.consortium.v1.QueryValidatorAuthsResponse) | ValidatorAuths queries authorization infos of validators. | GET|/lbm/consortium/v1/validators| | ||
| `ValidatorAuth` | [QueryValidatorAuthRequest](#lbm.consortium.v1.QueryValidatorAuthRequest) | [QueryValidatorAuthResponse](#lbm.consortium.v1.QueryValidatorAuthResponse) | ValidatorAuth queries authorization info of a validator. | GET|/lbm/consortium/v1/validators/{validator_address}| | ||
| `ValidatorAuths` | [QueryValidatorAuthsRequest](#lbm.consortium.v1.QueryValidatorAuthsRequest) | [QueryValidatorAuthsResponse](#lbm.consortium.v1.QueryValidatorAuthsResponse) | ValidatorAuths queries authorization infos of validators. | GET|/lbm/consortium/v1/validators| |
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.
reposition the two functions
@@ -14,15 +14,15 @@ service Query { | |||
option (google.api.http).get = "/lbm/consortium/v1/params"; | |||
} | |||
|
|||
// ValidatorAuths queries authorization infos of validators. |
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.
reposition the two functions
@@ -0,0 +1,44 @@ | |||
// Package rest provides HTTP types and primitives for REST |
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.
import rest.go from cosmos-sdk
GetParamsCmd(), | ||
GetValidatorAuthsCmd(), | ||
GetValidatorAuthCmd(), | ||
NewQueryCmdParams(), | ||
NewQueryCmdValidatorAuth(), | ||
NewQueryCmdValidatorAuths(), |
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.
rename the functions
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.
Why did you change the name with prefix New
?
I understand the New
prefix of function creates some instance. But I think this functions doesn't seems to do that.
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 it's a matter of choice. You can use both of New and Get, then they would mean creating a new command instance and get a command instance, respectively.
An example of New:
https://github.com/cosmos/cosmos-sdk/blob/a7c09a3278613a2c383968e73ee36150245cbdc1/x/nft/client/cli/tx.go#L27-L29
An example of Get:
https://github.com/cosmos/cosmos-sdk/blob/a7c09a3278613a2c383968e73ee36150245cbdc1/x/nft/client/cli/query.go#L31-L39
It is interesting that they are both in the same module.
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 understood. Thank you.
@@ -56,27 +56,27 @@ func GetParamsCmd() *cobra.Command { | |||
return cmd | |||
} | |||
|
|||
// GetValidatorAuthsCmd returns validator authorization by consortium |
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.
reposition the two functions
respType proto.Message | ||
}{ | ||
{ | ||
"with wrong # of args", |
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 does not accept any argument as of now
respType proto.Message | ||
}{ | ||
{ | ||
"with no args", |
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.
an empty proposal is forbidden
@@ -0,0 +1,173 @@ | |||
package testutil |
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.
add query tests
@@ -0,0 +1,135 @@ | |||
package testutil |
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.
add gRPC query tests
var consortiumData types.GenesisState | ||
s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[types.ModuleName], &consortiumData)) | ||
|
||
// enable consortium | ||
params := &types.Params{ | ||
Enabled: true, | ||
} | ||
consortiumData.Params = params | ||
|
||
consortiumDataBz, err := s.cfg.Codec.MarshalJSON(&consortiumData) | ||
s.Require().NoError(err) | ||
genesisState[types.ModuleName] = consortiumDataBz | ||
s.cfg.GenesisState = genesisState |
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.
modify the genesis state to enable the consortium module in the tests
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.
LGTM
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.
LGTM
* main: (44 commits) feat: rewrite issue template and move PR template (#410) fix: validate validator addresses in update-validator-auths proposal (#411) feat: add `bankplus` function to restrict to send coin to inactive smart contract. (#400) build(deps): bump actions/setup-go from 2.1.4 to 2.1.5 (#408) ci: fix branch name on ci script (#409) feat: Add CreateValidator access control feature (#406) build(deps): bump github.com/spf13/viper from 1.9.0 to 1.10.1 (#403) build(deps): bump github.com/rs/zerolog from 1.26.0 to 1.26.1 (#402) fix: fix query signing infos command (#407) build(deps): bump github.com/spf13/cobra from 1.1.3 to 1.3.0 (#399) build(deps): github.com/ulikunitz/xz from 0.5.5 to 0.5.10 (#398) build(deps): bump actions/stale from 3 to 4.1.0 (#396) build(deps): bump actions/cache from 2.1.3 to 2.1.7 (#386) feat: Add the `instantiate_permission` in the `CodeInfoResponse` (#395) fix: fix bug where `StoreCodeAndInstantiateContract`, `UpdateContractStatus`, `UpdateContractStatusProposal` API does not work (#393) docs: modify with latest version of swagger REST interface docs. (#392) fix: fix invalid root hash by bumping up tm-db (#388) chore: fix swagger's config path for wasm (#391) build(deps): bump technote-space/get-diff-action from 5.0.1 to 5.0.2 (#379) fix: update allowance inside AllowedMsgAllowance (#383) ...
Description
I intended to add tests to the module, but I have found & fixed a bug along the way.
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes