Skip to content

Commit

Permalink
fix: add verification on accounts into x/foundation Grants cli (#732)
Browse files Browse the repository at this point in the history
* Add verification on accounts

* Add unit tests on query cli

* Update CHANGELOG.md
  • Loading branch information
0Tech authored Oct 19, 2022
1 parent 5ed82db commit c854241
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (baseapp) [\#724](https://github.com/line/lbm-sdk/pull/724) add checking pubkey type from validator params
* (x/staking) [\#726](https://github.com/line/lbm-sdk/pull/726) check allowedList size in StakeAuthorization.Accept()
* (x/staking) [\#728](https://github.com/line/lbm-sdk/pull/728) fix typo in unbondingToUnbonded() panic
* (x/foundation) [\#732](https://github.com/line/lbm-sdk/pull/732) add verification on accounts into x/foundation Grants cli

### Breaking Changes
* (proto) [\#564](https://github.com/line/lbm-sdk/pull/564) change gRPC path to original cosmos path
Expand Down
8 changes: 7 additions & 1 deletion x/foundation/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,18 @@ func NewQueryCmdGrants() *cobra.Command {
return err
}

grantee, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
return err
}

msgTypeURL := ""
if len(args) >= 2 {
msgTypeURL = args[1]
}

params := foundation.QueryGrantsRequest{
Grantee: args[0],
Grantee: grantee.String(),
MsgTypeUrl: msgTypeURL,
Pagination: pageReq,
}
Expand Down
47 changes: 47 additions & 0 deletions x/foundation/client/testutil/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ func (s *IntegrationTestSuite) TestNewQueryCmdMember() {
false,
nil,
},
"invalid member": {
[]string{
"",
},
false,
nil,
},
}

for name, tc := range testCases {
Expand Down Expand Up @@ -265,6 +272,12 @@ func (s *IntegrationTestSuite) TestNewQueryCmdProposal() {
},
false,
},
"invalid id": {
[]string{
fmt.Sprintf("%d", -1),
},
false,
},
}

for name, tc := range testCases {
Expand Down Expand Up @@ -352,6 +365,20 @@ func (s *IntegrationTestSuite) TestNewQueryCmdVote() {
},
false,
},
"invalid proposal id": {
[]string{
fmt.Sprintf("%d", -1),
s.permanentMember.String(),
},
false,
},
"invalid voter": {
[]string{
fmt.Sprintf("%d", s.proposalID),
"",
},
false,
},
}

for name, tc := range testCases {
Expand Down Expand Up @@ -396,6 +423,12 @@ func (s *IntegrationTestSuite) TestNewQueryCmdVotes() {
},
false,
},
"invalid proposal id": {
[]string{
fmt.Sprintf("%d", -1),
},
false,
},
}

for name, tc := range testCases {
Expand Down Expand Up @@ -440,6 +473,12 @@ func (s *IntegrationTestSuite) TestNewQueryCmdTallyResult() {
},
false,
},
"invalid proposal id": {
[]string{
fmt.Sprintf("%d", -1),
},
false,
},
}

for name, tc := range testCases {
Expand Down Expand Up @@ -496,6 +535,14 @@ func (s *IntegrationTestSuite) TestNewQueryCmdGrants() {
false,
0,
},
"invalid grantee": {
[]string{
"",
foundation.ReceiveFromTreasuryAuthorization{}.MsgTypeURL(),
},
false,
0,
},
}

for name, tc := range testCases {
Expand Down

0 comments on commit c854241

Please sign in to comment.