mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-08 04:50:16 +00:00
Votes constructed from commits cannot include extensions or signatures
Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user