Browse Source

add more tests for evidence

Refs #693
pull/1936/head
Anton Kaliaev 7 years ago
parent
commit
37ce4e549e
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 29 additions and 2 deletions
  1. +1
    -1
      types/evidence.go
  2. +28
    -1
      types/evidence_test.go

+ 1
- 1
types/evidence.go View File

@ -4,7 +4,7 @@ import (
"bytes"
"fmt"
"github.com/tendermint/go-amino"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/merkle"


+ 28
- 1
types/evidence_test.go View File

@ -36,7 +36,7 @@ func TestEvidence(t *testing.T) {
blockID3 := makeBlockID("blockhash", 10000, "partshash")
blockID4 := makeBlockID("blockhash", 10000, "partshash2")
chainID := "mychain"
const chainID = "mychain"
vote1 := makeVote(val, chainID, 0, 10, 2, 1, blockID)
badVote := makeVote(val, chainID, 0, 10, 2, 1, blockID)
@ -72,3 +72,30 @@ func TestEvidence(t *testing.T) {
}
}
}
func TestDuplicatedVoteEvidence(t *testing.T) {
ev := randomDuplicatedVoteEvidence()
assert.True(t, ev.Equal(ev))
assert.False(t, ev.Equal(&DuplicateVoteEvidence{}))
}
func TestEvidenceList(t *testing.T) {
ev := randomDuplicatedVoteEvidence()
evl := EvidenceList([]Evidence{ev})
assert.NotNil(t, evl.Hash())
assert.True(t, evl.Has(ev))
assert.False(t, evl.Has(&DuplicateVoteEvidence{}))
}
func randomDuplicatedVoteEvidence() *DuplicateVoteEvidence {
val := NewMockPV()
blockID := makeBlockID("blockhash", 1000, "partshash")
blockID2 := makeBlockID("blockhash2", 1000, "partshash")
const chainID = "mychain"
return &DuplicateVoteEvidence{
VoteA: makeVote(val, chainID, 0, 10, 2, 1, blockID),
VoteB: makeVote(val, chainID, 0, 10, 2, 1, blockID2),
}
}

Loading…
Cancel
Save