Browse Source

Add test for MakePartSet with evidence

pull/2076/head
Hendrik Hofstadt 6 years ago
committed by Ethan Buchman
parent
commit
49b52ee3c7
3 changed files with 23 additions and 4 deletions
  1. +20
    -1
      types/block_test.go
  2. +2
    -2
      types/evidence.go
  3. +1
    -1
      types/wire.go

+ 20
- 1
types/block_test.go View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
crypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto"
cmn "github.com/tendermint/tendermint/libs/common"
)
@ -101,6 +101,25 @@ func TestBlockMakePartSet(t *testing.T) {
assert.Equal(t, 1, partSet.Total())
}
func TestBlockMakePartSetWithEvidence(t *testing.T) {
assert.Nil(t, (*Block)(nil).MakePartSet(2))
txs := []Tx{Tx("foo"), Tx("bar")}
lastID := makeBlockIDRandom()
h := int64(3)
voteSet, valSet, vals := randVoteSet(h-1, 1, VoteTypePrecommit, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals)
require.NoError(t, err)
ev := NewMockGoodEvidence(h, 0, valSet.Validators[0].Address)
evList := []Evidence{ev}
partSet := MakeBlock(h, txs, commit, evList).MakePartSet(1024)
assert.NotNil(t, partSet)
assert.Equal(t, 3, partSet.Total())
}
func TestBlockHashesTo(t *testing.T) {
assert.False(t, (*Block)(nil).HashesTo(nil))


+ 2
- 2
types/evidence.go View File

@ -43,8 +43,8 @@ func RegisterEvidences(cdc *amino.Codec) {
cdc.RegisterConcrete(&DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence", nil)
// mocks
cdc.RegisterConcrete(&MockGoodEvidence{}, "tendermint/MockGoodEvidence", nil)
cdc.RegisterConcrete(&MockBadEvidence{}, "tendermint/MockBadEvidence", nil)
cdc.RegisterConcrete(MockGoodEvidence{}, "tendermint/MockGoodEvidence", nil)
cdc.RegisterConcrete(MockBadEvidence{}, "tendermint/MockBadEvidence", nil)
}
//-------------------------------------------


+ 1
- 1
types/wire.go View File

@ -2,7 +2,7 @@ package types
import (
"github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc = amino.NewCodec()


Loading…
Cancel
Save