From 1a25cdae6f9e035876b1509009ab9e708f9901bc Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 2 Mar 2020 17:21:00 -0500 Subject: [PATCH] Update tests --- x/gov/keeper/proposal_test.go | 2 +- x/gov/types/proposal.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/x/gov/keeper/proposal_test.go b/x/gov/keeper/proposal_test.go index 99169d1769..a02b6da72a 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 2ba08980eb..9e65ec3c90 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 }