diff --git a/x/gov/keeper/proposal_test.go b/x/gov/keeper/proposal_test.go index 99169d176..a02b6da72 100644 --- a/x/gov/keeper/proposal_test.go +++ b/x/gov/keeper/proposal_test.go @@ -26,7 +26,7 @@ func TestGetSetProposal(t *testing.T) { gotProposal, ok := app.GovKeeper.GetProposal(ctx, proposalID) require.True(t, ok) - require.Equal(t, proposal.String(), gotProposal.String()) + require.True(t, proposal.Equal(gotProposal)) } func TestActivateVotingPeriod(t *testing.T) { diff --git a/x/gov/types/proposal.go b/x/gov/types/proposal.go index 2ba08980e..9e65ec3c9 100644 --- a/x/gov/types/proposal.go +++ b/x/gov/types/proposal.go @@ -37,6 +37,11 @@ func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Tim } } +// Equal returns true if two Proposal types are equal. +func (p Proposal) Equal(other Proposal) bool { + return p.ProposalBase.Equal(other.ProposalBase) && p.Content.String() == other.Content.String() +} + // String implements stringer interface func (p Proposal) String() string { out, _ := yaml.Marshal(p) @@ -189,14 +194,14 @@ const ( ProposalTypeText string = "Text" ) +// Implements Content Interface +var _ Content = TextProposal{} + // NewTextProposal creates a text proposal Content func NewTextProposal(title, description string) Content { return TextProposal{title, description} } -// Implements Content Interface -var _ Content = TextProposal{} - // GetTitle returns the proposal title func (tp TextProposal) GetTitle() string { return tp.Title }