Skip to content

Commit

Permalink
fix: bump gogoproto and fix tests mentioning #10965
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 14, 2022
1 parent d9bc5ac commit 93831c0
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 201 deletions.
6 changes: 3 additions & 3 deletions api/cosmos/gov/v1beta1/gov.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,6 @@ replace (
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1
)

replace github.com/cosmos/gogoproto => ../gogoproto

retract v0.43.0
5 changes: 2 additions & 3 deletions proto/cosmos/auth/v1beta1/auth.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ message ModuleAccount {

// Params defines the parameters for the auth module.
message Params {
option (amino.name) = "cosmos-sdk/x/auth/Params";
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;
option (amino.name) = "cosmos-sdk/x/auth/Params";
option (gogoproto.equal) = true;

uint64 max_memo_characters = 1;
uint64 tx_sig_limit = 2;
Expand Down
4 changes: 1 addition & 3 deletions proto/cosmos/gov/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import "amino/amino.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";

option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.goproto_getters_all) = false;

// VoteOption enumerates the valid vote options for a given governance proposal.
enum VoteOption {
Expand Down
5 changes: 3 additions & 2 deletions x/auth/types/auth.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions x/auth/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package types

import (
"fmt"

"sigs.k8s.io/yaml"
)

// Default parameter values
Expand Down Expand Up @@ -51,12 +49,6 @@ func (p Params) SigVerifyCostSecp256r1() uint64 {
return p.SigVerifyCostSecp256k1 / 2
}

// String implements the stringer interface.
func (p Params) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}

func validateTxSigLimit(i interface{}) error {
v, ok := i.(uint64)
if !ok {
Expand Down
2 changes: 2 additions & 0 deletions x/auth/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func TestParams_Validate(t *testing.T) {
require.NoError(t, got)
return
}

require.NotEmpty(t, tt.params.String())
require.Equal(t, tt.wantErr, got)
})
}
Expand Down
27 changes: 6 additions & 21 deletions x/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposal() {

if testCase.expPass {
suite.Require().NoError(err)
// Instead of using MashalJSON, we could compare .String() output too.
// https://github.com/cosmos/cosmos-sdk/issues/10965
expJSON, err := suite.cdc.MarshalJSON(&expProposal)
suite.Require().NoError(err)
actualJSON, err := suite.cdc.MarshalJSON(proposalRes.Proposal)
suite.Require().NoError(err)
suite.Require().Equal(expJSON, actualJSON)
suite.Require().NotEmpty(proposalRes.Proposal.String())
suite.Require().Equal(proposalRes.Proposal.String(), expProposal.String())
} else {
suite.Require().Error(err)
suite.Require().Nil(proposalRes)
Expand Down Expand Up @@ -150,13 +145,8 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryProposal() {

if testCase.expPass {
suite.Require().NoError(err)
// Instead of using MashalJSON, we could compare .String() output too.
// https://github.com/cosmos/cosmos-sdk/issues/10965
expJSON, err := suite.cdc.MarshalJSON(&expProposal)
suite.Require().NoError(err)
actualJSON, err := suite.cdc.MarshalJSON(&proposalRes.Proposal)
suite.Require().NoError(err)
suite.Require().Equal(expJSON, actualJSON)
suite.Require().NotEmpty(proposalRes.Proposal.String())
suite.Require().Equal(proposalRes.Proposal.String(), expProposal.String())
} else {
suite.Require().Error(err)
suite.Require().Nil(proposalRes)
Expand Down Expand Up @@ -299,14 +289,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {

suite.Require().Len(proposals.GetProposals(), len(expRes.GetProposals()))
for i := 0; i < len(proposals.GetProposals()); i++ {
// Instead of using MashalJSON, we could compare .String() output too.
// https://github.com/cosmos/cosmos-sdk/issues/10965
expJSON, err := suite.cdc.MarshalJSON(expRes.GetProposals()[i])
suite.Require().NoError(err)
actualJSON, err := suite.cdc.MarshalJSON(proposals.GetProposals()[i])
suite.Require().NoError(err)

suite.Require().Equal(expJSON, actualJSON)
suite.Require().NotEmpty(proposals.GetProposals()[i])
suite.Require().Equal(expRes.GetProposals()[i], proposals.GetProposals()[i])
}

} else {
Expand Down
4 changes: 1 addition & 3 deletions x/gov/types/v1/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ func TestProposalStatus_Format(t *testing.T) {
// Here, we're creating a proposal which has a Msg (1st any) with a legacy
// content (2nd any).
func TestNestedAnys(t *testing.T) {
// TODO https://github.com/cosmos/cosmos-sdk/issues/10965
t.Skip()
testProposal := v1beta1.NewTextProposal("Proposal", "testing proposal")
msgContent, err := v1.NewLegacyContent(testProposal, "cosmos1govacct")
require.NoError(t, err)
proposal, err := v1.NewProposal([]sdk.Msg{msgContent}, 1, "", time.Now(), time.Now())
require.NoError(t, err)

require.Equal(t, "TODO Fix panic here", proposal.String())
require.NotPanics(t, func() { _ = proposal.String() })
}
9 changes: 1 addition & 8 deletions x/gov/types/v1beta1/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package v1beta1
import (
"fmt"

"sigs.k8s.io/yaml"

sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -15,14 +13,9 @@ func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins) D
return Deposit{proposalID, depositor.String(), amount}
}

func (d Deposit) String() string {
out, _ := yaml.Marshal(d)
return string(out)
}

// Empty returns whether a deposit is empty.
func (d Deposit) Empty() bool {
return d.String() == Deposit{}.String()
return d.String() == (&Deposit{}).String()
}

// Deposits is a collection of Deposit objects
Expand Down
Loading

0 comments on commit 93831c0

Please sign in to comment.