From 73dc488239f4799954931edb19c148d3b21a9436 Mon Sep 17 00:00:00 2001 From: Ruaridh Date: Fri, 24 Apr 2020 19:15:57 +0100 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: Denali Marsh Co-Authored-By: Kevin Davis --- x/committee/client/cli/query.go | 2 +- x/committee/client/cli/tx.go | 2 +- x/committee/client/rest/query.go | 5 +++-- x/committee/client/rest/tx.go | 4 ++-- x/committee/keeper/keeper_test.go | 4 ++-- x/committee/types/codec.go | 2 +- x/committee/types/gov_proposal.go | 4 ++-- x/committee/types/querier.go | 1 - 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x/committee/client/cli/query.go b/x/committee/client/cli/query.go index 12add284..e0318fba 100644 --- a/x/committee/client/cli/query.go +++ b/x/committee/client/cli/query.go @@ -40,7 +40,7 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { return govQueryCmd } -// GetCmdQueryProposals implements a query proposals command. +// GetCmdQueryCommittees implements a query committees command. func GetCmdQueryCommittees(queryRoute string, cdc *codec.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "committees", diff --git a/x/committee/client/cli/tx.go b/x/committee/client/cli/tx.go index 2e142e8d..292a8476 100644 --- a/x/committee/client/cli/tx.go +++ b/x/committee/client/cli/tx.go @@ -189,7 +189,7 @@ func mustGetExampleCommitteeChangeProposal(cdc *codec.Codec) string { types.NewCommittee( 1, "The description of this committee.", - []sdk.AccAddress{sdk.AccAddress(crypto.AddressHash([]byte("exampleAddres")))}, + []sdk.AccAddress{sdk.AccAddress(crypto.AddressHash([]byte("exampleAddress")))}, []types.Permission{ types.ParamChangePermission{ AllowedParams: types.AllowedParams{{Subspace: "cdp", Key: "CircuitBreaker"}}, diff --git a/x/committee/client/rest/query.go b/x/committee/client/rest/query.go index da80ec5c..1ae72928 100644 --- a/x/committee/client/rest/query.go +++ b/x/committee/client/rest/query.go @@ -190,6 +190,7 @@ func queryProposerHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { } // Write response + cliCtx = cliCtx.WithHeight(height) rest.PostProcessResponse(w, cliCtx, res) } } @@ -209,7 +210,7 @@ func queryVotesOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // Prepare params for querier vars := mux.Vars(r) if len(vars[RestProposalID]) == 0 { - err := errors.New("proposalID required but not specified") + err := errors.New(fmt.Sprintf("%s required but not specified", RestProposalID)) rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) return } @@ -247,7 +248,7 @@ func queryTallyOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // Prepare params for querier vars := mux.Vars(r) if len(vars[RestProposalID]) == 0 { - err := errors.New("proposalID required but not specified") + err := errors.New(fmt.Sprintf("%s required but not specified", RestProposalID)) rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) return } diff --git a/x/committee/client/rest/tx.go b/x/committee/client/rest/tx.go index 46447123..263acf51 100644 --- a/x/committee/client/rest/tx.go +++ b/x/committee/client/rest/tx.go @@ -34,7 +34,7 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // Parse and validate url params vars := mux.Vars(r) if len(vars[RestCommitteeID]) == 0 { - rest.WriteErrorResponse(w, http.StatusBadRequest, "committeeID required but not specified") + rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("%s required but not specified", RestCommitteeID)) return } committeeID, ok := rest.ParseUint64OrReturnBadRequest(w, vars[RestCommitteeID]) @@ -78,7 +78,7 @@ func postVoteHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // Parse and validate url params vars := mux.Vars(r) if len(vars[RestProposalID]) == 0 { - rest.WriteErrorResponse(w, http.StatusBadRequest, "proposalID required but not specified") + rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("%s required but not specified", RestProposalID)) return } proposalID, ok := rest.ParseUint64OrReturnBadRequest(w, vars[RestProposalID]) diff --git a/x/committee/keeper/keeper_test.go b/x/committee/keeper/keeper_test.go index 90f624a7..c317d8d7 100644 --- a/x/committee/keeper/keeper_test.go +++ b/x/committee/keeper/keeper_test.go @@ -61,7 +61,7 @@ func (suite *KeeperTestSuite) TestGetSetDeleteCommittee() { suite.False(found) } -func (suite *KeeperTestSuite) TestGetSetProposal() { +func (suite *KeeperTestSuite) TestGetSetDeleteProposal() { // test setup prop := types.Proposal{ ID: 12, @@ -86,7 +86,7 @@ func (suite *KeeperTestSuite) TestGetSetProposal() { suite.False(found) } -func (suite *KeeperTestSuite) TestGetSetVote() { +func (suite *KeeperTestSuite) TestGetSetDeleteVote() { // test setup vote := types.Vote{ ProposalID: 12, diff --git a/x/committee/types/codec.go b/x/committee/types/codec.go index a904d40e..bdac0489 100644 --- a/x/committee/types/codec.go +++ b/x/committee/types/codec.go @@ -29,7 +29,7 @@ func RegisterModuleCodec(cdc *codec.Codec) { RegisterAppCodec(cdc) } -// RegisterCodec registers the necessary types for the module +// RegisterAppCodec registers the necessary types for the module func RegisterAppCodec(cdc *codec.Codec) { // Proposals // The app codec needs the gov.Content type registered. This is done by the gov module. diff --git a/x/committee/types/gov_proposal.go b/x/committee/types/gov_proposal.go index aa201660..45bfe0a4 100644 --- a/x/committee/types/gov_proposal.go +++ b/x/committee/types/gov_proposal.go @@ -41,7 +41,7 @@ func (ccp CommitteeChangeProposal) GetTitle() string { return ccp.Title } // GetDescription returns the description of the proposal. func (ccp CommitteeChangeProposal) GetDescription() string { return ccp.Description } -// GetDescription returns the routing key of the proposal. +// ProposalRoute returns the routing key of the proposal. func (ccp CommitteeChangeProposal) ProposalRoute() string { return RouterKey } // ProposalType returns the type of the proposal. @@ -93,7 +93,7 @@ func (cdp CommitteeDeleteProposal) GetTitle() string { return cdp.Title } // GetDescription returns the description of the proposal. func (cdp CommitteeDeleteProposal) GetDescription() string { return cdp.Description } -// GetDescription returns the routing key of the proposal. +// ProposalRoute returns the routing key of the proposal. func (cdp CommitteeDeleteProposal) ProposalRoute() string { return RouterKey } // ProposalType returns the type of the proposal. diff --git a/x/committee/types/querier.go b/x/committee/types/querier.go index f58ed338..af1df4f2 100644 --- a/x/committee/types/querier.go +++ b/x/committee/types/querier.go @@ -6,7 +6,6 @@ import ( // Query endpoints supported by the Querier const ( - //QueryParams = "params" QueryCommittees = "committees" QueryCommittee = "committee" QueryProposals = "proposals"