From cfa602a96ca3bd0b27537e40780ac2efe0a32149 Mon Sep 17 00:00:00 2001 From: Jeremiah Andrews Date: Wed, 8 Aug 2018 15:19:22 -0700 Subject: [PATCH] Add signer with different BlockID to TestMakeCommit --- types/vote_set_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/types/vote_set_test.go b/types/vote_set_test.go index 32ceb7b16..cf8b861a5 100644 --- a/types/vote_set_test.go +++ b/types/vote_set_test.go @@ -447,7 +447,7 @@ func TestConflicts(t *testing.T) { func TestMakeCommit(t *testing.T) { height, round := int64(1), 0 - voteSet, _, privValidators := randVoteSet(height, round, VoteTypePrecommit, 10, 1) + voteSet, valz, privValidators := randVoteSet(height, round, VoteTypePrecommit, 10, 1) blockHash, blockPartsHeader := crypto.CRandBytes(32), PartSetHeader{123, crypto.CRandBytes(32)} voteProto := &Vote{ @@ -493,6 +493,20 @@ func TestMakeCommit(t *testing.T) { } } + // The 9th voted for a different BlockID + { + voteProtoDiff := voteProto.Copy() + voteProtoDiff.BlockID = BlockID{ + crypto.CRandBytes(32), + PartSetHeader{123, crypto.CRandBytes(32)}, + } + vote := withValidator(voteProtoDiff, privValidators[8].GetAddress(), 8) + _, err := signAddVote(privValidators[8], vote, voteSet) + if err != nil { + t.Error(err) + } + } + commit := voteSet.MakeCommit() // Commit should have 10 elements @@ -505,4 +519,8 @@ func TestMakeCommit(t *testing.T) { t.Errorf("Error in Commit.ValidateBasic(): %v", err) } + err := valz.VerifyCommit("test_chain_id", BlockID{blockHash, blockPartsHeader}, int64(1), commit) + if err != nil { + t.Errorf("Error in VerifyCommit: %v", err) + } }