|
@ -80,6 +80,12 @@ func TestDuplicatedVoteEvidence(t *testing.T) { |
|
|
|
|
|
|
|
|
assert.True(t, ev.Equal(ev)) |
|
|
assert.True(t, ev.Equal(ev)) |
|
|
assert.False(t, ev.Equal(&DuplicateVoteEvidence{})) |
|
|
assert.False(t, ev.Equal(&DuplicateVoteEvidence{})) |
|
|
|
|
|
|
|
|
|
|
|
maxTime := ev.VoteB.Timestamp |
|
|
|
|
|
if ev.VoteA.Timestamp.After(ev.VoteB.Timestamp) { |
|
|
|
|
|
maxTime = ev.VoteA.Timestamp |
|
|
|
|
|
} |
|
|
|
|
|
assert.Equal(t, maxTime, ev.Time(), "expected time of the latest vote") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func TestEvidenceList(t *testing.T) { |
|
|
func TestEvidenceList(t *testing.T) { |
|
@ -152,7 +158,7 @@ func randomDuplicatedVoteEvidence(t *testing.T) *DuplicateVoteEvidence { |
|
|
const chainID = "mychain" |
|
|
const chainID = "mychain" |
|
|
return &DuplicateVoteEvidence{ |
|
|
return &DuplicateVoteEvidence{ |
|
|
VoteA: makeVote(t, val, chainID, 0, 10, 2, 1, blockID, defaultVoteTime), |
|
|
VoteA: makeVote(t, val, chainID, 0, 10, 2, 1, blockID, defaultVoteTime), |
|
|
VoteB: makeVote(t, val, chainID, 0, 10, 2, 1, blockID2, defaultVoteTime), |
|
|
|
|
|
|
|
|
VoteB: makeVote(t, val, chainID, 0, 10, 2, 1, blockID2, defaultVoteTime.Add(1*time.Minute)), |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -223,7 +229,7 @@ func TestLunaticValidatorEvidence(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
assert.Equal(t, header.Height, ev.Height()) |
|
|
assert.Equal(t, header.Height, ev.Height()) |
|
|
assert.Equal(t, bTime, ev.Time()) |
|
|
|
|
|
|
|
|
assert.Equal(t, defaultVoteTime, ev.Time()) |
|
|
assert.EqualValues(t, vote.ValidatorAddress, ev.Address()) |
|
|
assert.EqualValues(t, vote.ValidatorAddress, ev.Address()) |
|
|
assert.NotEmpty(t, ev.Hash()) |
|
|
assert.NotEmpty(t, ev.Hash()) |
|
|
assert.NotEmpty(t, ev.Bytes()) |
|
|
assert.NotEmpty(t, ev.Bytes()) |
|
@ -330,7 +336,7 @@ func TestConflictingHeadersEvidence(t *testing.T) { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
assert.Equal(t, height, ev.Height()) |
|
|
assert.Equal(t, height, ev.Height()) |
|
|
// assert.Equal(t, bTime, ev.Time())
|
|
|
|
|
|
|
|
|
assert.Equal(t, ev.H2.Time, ev.Time()) |
|
|
assert.NotEmpty(t, ev.Hash()) |
|
|
assert.NotEmpty(t, ev.Hash()) |
|
|
assert.NotEmpty(t, ev.Bytes()) |
|
|
assert.NotEmpty(t, ev.Bytes()) |
|
|
assert.NoError(t, ev.VerifyComposite(header1, valSet)) |
|
|
assert.NoError(t, ev.VerifyComposite(header1, valSet)) |
|
@ -350,7 +356,7 @@ func TestPotentialAmnesiaEvidence(t *testing.T) { |
|
|
blockID = makeBlockID(tmhash.Sum([]byte("blockhash")), math.MaxInt32, tmhash.Sum([]byte("partshash"))) |
|
|
blockID = makeBlockID(tmhash.Sum([]byte("blockhash")), math.MaxInt32, tmhash.Sum([]byte("partshash"))) |
|
|
blockID2 = makeBlockID(tmhash.Sum([]byte("blockhash2")), math.MaxInt32, tmhash.Sum([]byte("partshash"))) |
|
|
blockID2 = makeBlockID(tmhash.Sum([]byte("blockhash2")), math.MaxInt32, tmhash.Sum([]byte("partshash"))) |
|
|
vote1 = makeVote(t, val, chainID, 0, height, 0, 2, blockID, defaultVoteTime) |
|
|
vote1 = makeVote(t, val, chainID, 0, height, 0, 2, blockID, defaultVoteTime) |
|
|
vote2 = makeVote(t, val, chainID, 0, height, 1, 2, blockID2, defaultVoteTime) |
|
|
|
|
|
|
|
|
vote2 = makeVote(t, val, chainID, 0, height, 1, 2, blockID2, defaultVoteTime.Add(1*time.Minute)) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
ev := &PotentialAmnesiaEvidence{ |
|
|
ev := &PotentialAmnesiaEvidence{ |
|
@ -359,7 +365,7 @@ func TestPotentialAmnesiaEvidence(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
assert.Equal(t, height, ev.Height()) |
|
|
assert.Equal(t, height, ev.Height()) |
|
|
// assert.Equal(t, bTime, ev.Time())
|
|
|
|
|
|
|
|
|
assert.Equal(t, vote2.Timestamp, ev.Time()) |
|
|
assert.EqualValues(t, vote1.ValidatorAddress, ev.Address()) |
|
|
assert.EqualValues(t, vote1.ValidatorAddress, ev.Address()) |
|
|
assert.NotEmpty(t, ev.Hash()) |
|
|
assert.NotEmpty(t, ev.Hash()) |
|
|
assert.NotEmpty(t, ev.Bytes()) |
|
|
assert.NotEmpty(t, ev.Bytes()) |
|
|