separate mock evidence from real evidence (#2571)

Closes #2525
This commit is contained in:
Anton Kaliaev
2018-10-09 14:10:05 +02:00
committed by Alexander Simmerl
parent 989a2f32b1
commit 724e264ff5
7 changed files with 33 additions and 10 deletions
+8
View File
@@ -3,6 +3,7 @@ package types
import (
"crypto/rand"
"math"
"os"
"testing"
"time"
@@ -13,6 +14,13 @@ import (
cmn "github.com/tendermint/tendermint/libs/common"
)
func TestMain(m *testing.M) {
RegisterMockEvidences(cdc)
code := m.Run()
os.Exit(code)
}
func TestBlockAddEvidence(t *testing.T) {
txs := []Tx{Tx("foo"), Tx("bar")}
lastID := makeBlockIDRandom()
+2 -1
View File
@@ -46,8 +46,9 @@ type Evidence interface {
func RegisterEvidences(cdc *amino.Codec) {
cdc.RegisterInterface((*Evidence)(nil), nil)
cdc.RegisterConcrete(&DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence", nil)
}
// mocks
func RegisterMockEvidences(cdc *amino.Codec) {
cdc.RegisterConcrete(MockGoodEvidence{}, "tendermint/MockGoodEvidence", nil)
cdc.RegisterConcrete(MockBadEvidence{}, "tendermint/MockBadEvidence", nil)
}
+6 -1
View File
@@ -1,7 +1,7 @@
package types
import (
"github.com/tendermint/go-amino"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto/encoding/amino"
)
@@ -15,3 +15,8 @@ func RegisterBlockAmino(cdc *amino.Codec) {
cryptoAmino.RegisterAmino(cdc)
RegisterEvidences(cdc)
}
// GetCodec returns a codec used by the package. For testing purposes only.
func GetCodec() *amino.Codec {
return cdc
}