diff --git a/types/block_test.go b/types/block_test.go index 4ed47dd9d..c18b2ef1e 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -274,7 +274,7 @@ func TestCommit(t *testing.T) { require.NotNil(t, commit.BitArray()) assert.Equal(t, bits.NewBitArray(10).Size(), commit.BitArray().Size()) - assert.Equal(t, voteSet.GetByIndex(0), commit.GetByIndex(0)) + assert.Equal(t, voteWithoutExtension(voteSet.GetByIndex(0)), commit.GetByIndex(0)) assert.True(t, commit.IsCommit()) } @@ -571,8 +571,8 @@ func TestCommitToVoteSet(t *testing.T) { voteSet2 := CommitToVoteSet(chainID, commit, valSet) for i := int32(0); int(i) < len(vals); i++ { - vote1 := voteSet.GetByIndex(i) - vote2 := voteSet2.GetByIndex(i) + vote1 := voteWithoutExtension(voteSet.GetByIndex(i)) + vote2 := voteWithoutExtension(voteSet2.GetByIndex(i)) vote3 := commit.GetVote(i) vote1bz, err := vote1.ToProto().Marshal() diff --git a/types/test_util.go b/types/test_util.go index 55f56ebf5..8aea2f02c 100644 --- a/types/test_util.go +++ b/types/test_util.go @@ -46,3 +46,13 @@ func signAddVote(ctx context.Context, privVal PrivValidator, vote *Vote, voteSet vote.ExtensionSignature = v.ExtensionSignature return voteSet.AddVote(vote) } + +// Votes constructed from commits don't have extensions, because we don't store +// the extensions themselves in the commit. This method is used to construct a +// copy of a vote, but nil its extension and signature. +func voteWithoutExtension(v *Vote) *Vote { + vc := v.Copy() + vc.Extension = nil + vc.ExtensionSignature = nil + return vc +}