From a29c781295fc13fd58c77894e35a3aa3f43029ac Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 11 Dec 2017 18:42:58 +0100 Subject: [PATCH] Add default timestamp to all instances of *types.Vote --- consensus/common_test.go | 1 + consensus/state.go | 1 + consensus/types/height_vote_set_test.go | 2 ++ lite/helpers.go | 1 + types/priv_validator_test.go | 2 ++ types/vote_set_test.go | 7 +++++++ 6 files changed, 14 insertions(+) diff --git a/consensus/common_test.go b/consensus/common_test.go index 23e56e67e..377f1929f 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -74,6 +74,7 @@ func (vs *validatorStub) signVote(voteType byte, hash []byte, header types.PartS ValidatorAddress: vs.PrivValidator.GetAddress(), Height: vs.Height, Round: vs.Round, + Timestamp: time.Now().UTC(), Type: voteType, BlockID: types.BlockID{hash, header}, } diff --git a/consensus/state.go b/consensus/state.go index eedc30bc0..68133f53a 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1466,6 +1466,7 @@ func (cs *ConsensusState) signVote(type_ byte, hash []byte, header types.PartSet ValidatorIndex: valIndex, Height: cs.Height, Round: cs.Round, + Timestamp: time.Now().UTC(), Type: type_, BlockID: types.BlockID{hash, header}, } diff --git a/consensus/types/height_vote_set_test.go b/consensus/types/height_vote_set_test.go index e09d1419d..306592aa2 100644 --- a/consensus/types/height_vote_set_test.go +++ b/consensus/types/height_vote_set_test.go @@ -2,6 +2,7 @@ package types import ( "testing" + "time" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/types" @@ -54,6 +55,7 @@ func makeVoteHR(t *testing.T, height int64, round int, privVals []*types.PrivVal ValidatorIndex: valIndex, Height: height, Round: round, + Timestamp: time.Now().UTC(), Type: types.VoteTypePrecommit, BlockID: types.BlockID{[]byte("fakehash"), types.PartSetHeader{}}, } diff --git a/lite/helpers.go b/lite/helpers.go index 9319c4590..5702203ba 100644 --- a/lite/helpers.go +++ b/lite/helpers.go @@ -97,6 +97,7 @@ func makeVote(header *types.Header, vals *types.ValidatorSet, key crypto.PrivKey ValidatorIndex: idx, Height: header.Height, Round: 1, + Timestamp: time.Now().UTC(), Type: types.VoteTypePrecommit, BlockID: types.BlockID{Hash: header.Hash()}, } diff --git a/types/priv_validator_test.go b/types/priv_validator_test.go index 3b13ed909..4e55fd49b 100644 --- a/types/priv_validator_test.go +++ b/types/priv_validator_test.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -165,6 +166,7 @@ func newVote(addr data.Bytes, idx int, height int64, round int, typ byte, blockI Height: height, Round: round, Type: typ, + Timestamp: time.Now().UTC(), BlockID: blockID, } } diff --git a/types/vote_set_test.go b/types/vote_set_test.go index b093c44fd..d125c5502 100644 --- a/types/vote_set_test.go +++ b/types/vote_set_test.go @@ -3,6 +3,7 @@ package types import ( "bytes" "testing" + "time" crypto "github.com/tendermint/go-crypto" cmn "github.com/tendermint/tmlibs/common" @@ -92,6 +93,7 @@ func TestAddVote(t *testing.T) { Height: height, Round: round, Type: VoteTypePrevote, + Timestamp: time.Now().UTC(), BlockID: BlockID{nil, PartSetHeader{}}, } _, err := signAddVote(val0, vote, voteSet) @@ -121,6 +123,7 @@ func Test2_3Majority(t *testing.T) { Height: height, Round: round, Type: VoteTypePrevote, + Timestamp: time.Now().UTC(), BlockID: BlockID{nil, PartSetHeader{}}, } // 6 out of 10 voted for nil. @@ -176,6 +179,7 @@ func Test2_3MajorityRedux(t *testing.T) { ValidatorIndex: -1, // NOTE: must fill in Height: height, Round: round, + Timestamp: time.Now().UTC(), Type: VoteTypePrevote, BlockID: BlockID{blockHash, blockPartsHeader}, } @@ -270,6 +274,7 @@ func TestBadVotes(t *testing.T) { ValidatorIndex: -1, Height: height, Round: round, + Timestamp: time.Now().UTC(), Type: VoteTypePrevote, BlockID: BlockID{nil, PartSetHeader{}}, } @@ -331,6 +336,7 @@ func TestConflicts(t *testing.T) { ValidatorIndex: -1, Height: height, Round: round, + Timestamp: time.Now().UTC(), Type: VoteTypePrevote, BlockID: BlockID{nil, PartSetHeader{}}, } @@ -459,6 +465,7 @@ func TestMakeCommit(t *testing.T) { ValidatorIndex: -1, Height: height, Round: round, + Timestamp: time.Now().UTC(), Type: VoteTypePrecommit, BlockID: BlockID{blockHash, blockPartsHeader}, }