mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-27 19:37:08 +00:00
clean up tests
This commit is contained in:
@@ -446,7 +446,7 @@ func TestReactor_Backfill(t *testing.T) {
|
||||
|
||||
trackingHeight := startHeight
|
||||
rts.stateStore.On("SaveValidatorSets", mock.AnythingOfType("int64"), mock.AnythingOfType("int64"),
|
||||
mock.AnythingOfType("*types.ValidatorSet")).Return(func(lh, uh int64, vals *consensus.ValidatorSet) error {
|
||||
mock.AnythingOfType("*consensus.ValidatorSet")).Return(func(lh, uh int64, vals *consensus.ValidatorSet) error {
|
||||
require.Equal(t, trackingHeight, lh)
|
||||
require.Equal(t, lh, uh)
|
||||
require.GreaterOrEqual(t, lh, stopHeight)
|
||||
|
||||
@@ -36,12 +36,16 @@ func MakeBlockID() metadata.BlockID {
|
||||
return MakeBlockIDWithHash(RandomHash())
|
||||
}
|
||||
|
||||
func MakeBlockIDFromBytes(bytes []byte) metadata.BlockID {
|
||||
return MakeBlockIDWithHash(tmhash.Sum(bytes))
|
||||
}
|
||||
|
||||
func MakeBlockIDWithHash(hash []byte) metadata.BlockID {
|
||||
return metadata.BlockID{
|
||||
Hash: hash,
|
||||
PartSetHeader: metadata.PartSetHeader{
|
||||
Total: 100,
|
||||
Hash: RandomHash(),
|
||||
Hash: tmhash.Sum([]byte("part_set_header")),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ func MakeCommit(blockID metadata.BlockID, height int64, round int32,
|
||||
return voteSet.MakeCommit(), nil
|
||||
}
|
||||
|
||||
func SignAddVote(privVal consensus.PrivValidator, vote *consensus.Vote, voteSet *consensus.VoteSet) (signed bool, err error) {
|
||||
func SignAddVote(privVal consensus.PrivValidator, vote *consensus.Vote,
|
||||
voteSet *consensus.VoteSet) (signed bool, err error) {
|
||||
v := vote.ToProto()
|
||||
err = privVal.SignVote(context.Background(), voteSet.ChainID(), v)
|
||||
if err != nil {
|
||||
|
||||
@@ -57,7 +57,10 @@ func RandVoteSet(
|
||||
return consensus.NewVoteSet("test_chain_id", height, round, signedMsgType, valSet), valSet, privValidators
|
||||
}
|
||||
|
||||
func RandValidatorPrivValSet(numValidators int, votingPower int64) (*consensus.ValidatorSet, []consensus.PrivValidator) {
|
||||
func RandValidatorPrivValSet(
|
||||
numValidators int,
|
||||
votingPower int64,
|
||||
) (*consensus.ValidatorSet, []consensus.PrivValidator) {
|
||||
var (
|
||||
valz = make([]*consensus.Validator, numValidators)
|
||||
privValidators = make([]consensus.PrivValidator, numValidators)
|
||||
|
||||
@@ -77,7 +77,8 @@ func (pkz privKeys) ToValidators(init, inc int64) *consensus.ValidatorSet {
|
||||
}
|
||||
|
||||
// signHeader properly signs the header with all keys from first to last exclusive.
|
||||
func (pkz privKeys) signHeader(header *metadata.Header, valSet *consensus.ValidatorSet, first, last int) *metadata.Commit {
|
||||
func (pkz privKeys) signHeader(header *metadata.Header, valSet *consensus.ValidatorSet,
|
||||
first, last int) *metadata.Commit {
|
||||
commitSigs := make([]metadata.CommitSig, len(pkz))
|
||||
for i := 0; i < len(pkz); i++ {
|
||||
commitSigs[i] = metadata.NewCommitSigAbsent()
|
||||
@@ -147,7 +148,8 @@ func genHeader(chainID string, height int64, bTime time.Time, txs mempool.Txs,
|
||||
|
||||
// GenSignedHeader calls genHeader and signHeader and combines them into a SignedHeader.
|
||||
func (pkz privKeys) GenSignedHeader(chainID string, height int64, bTime time.Time, txs mempool.Txs,
|
||||
valset, nextValset *consensus.ValidatorSet, appHash, consHash, resHash []byte, first, last int) *metadata.SignedHeader {
|
||||
valset, nextValset *consensus.ValidatorSet, appHash, consHash, resHash []byte, first, last int,
|
||||
) *metadata.SignedHeader {
|
||||
|
||||
header := genHeader(chainID, height, bTime, txs, valset, nextValset, appHash, consHash, resHash)
|
||||
return &metadata.SignedHeader{
|
||||
|
||||
+1
-1
@@ -522,7 +522,7 @@ func TestNodeSetEventSink(t *testing.T) {
|
||||
eventBus, err := createAndStartEventBus(logger)
|
||||
require.NoError(t, err)
|
||||
|
||||
genDoc, err := types.GenesisDocFromFile(config.GenesisFile())
|
||||
genDoc, err := consensus.GenesisDocFromFile(config.GenesisFile())
|
||||
require.NoError(t, err)
|
||||
|
||||
indexService, eventSinks, err := createAndStartIndexerService(config,
|
||||
|
||||
@@ -20,7 +20,10 @@ type BlockMeta struct {
|
||||
// NewBlockMeta returns a new BlockMeta.
|
||||
func NewBlockMeta(block *Block, blockParts *metadata.PartSet) *BlockMeta {
|
||||
return &BlockMeta{
|
||||
BlockID: metadata.BlockID{block.Hash(), blockParts.Header()},
|
||||
BlockID: metadata.BlockID{
|
||||
Hash: block.Hash(),
|
||||
PartSetHeader: blockParts.Header(),
|
||||
},
|
||||
BlockSize: block.Size(),
|
||||
Header: block.Header,
|
||||
NumTxs: len(block.Data.Txs),
|
||||
|
||||
@@ -14,7 +14,8 @@ import (
|
||||
|
||||
func TestBlockMeta_ToProto(t *testing.T) {
|
||||
h := test.MakeRandomHeader()
|
||||
bi := metadata.BlockID{Hash: h.Hash(), PartSetHeader: metadata.PartSetHeader{Total: 123, Hash: tmrand.Bytes(tmhash.Size)}}
|
||||
bi := metadata.BlockID{Hash: h.Hash(),
|
||||
PartSetHeader: metadata.PartSetHeader{Total: 123, Hash: tmrand.Bytes(tmhash.Size)}}
|
||||
|
||||
bm := &block.BlockMeta{
|
||||
BlockID: bi,
|
||||
@@ -51,7 +52,8 @@ func TestBlockMeta_ToProto(t *testing.T) {
|
||||
|
||||
func TestBlockMeta_ValidateBasic(t *testing.T) {
|
||||
h := test.MakeRandomHeader()
|
||||
bi := metadata.BlockID{Hash: h.Hash(), PartSetHeader: metadata.PartSetHeader{Total: 123, Hash: tmrand.Bytes(tmhash.Size)}}
|
||||
bi := metadata.BlockID{Hash: h.Hash(),
|
||||
PartSetHeader: metadata.PartSetHeader{Total: 123, Hash: tmrand.Bytes(tmhash.Size)}}
|
||||
bi2 := metadata.BlockID{Hash: tmrand.Bytes(tmhash.Size),
|
||||
PartSetHeader: metadata.PartSetHeader{Total: 123, Hash: tmrand.Bytes(tmhash.Size)}}
|
||||
bi3 := metadata.BlockID{Hash: []byte("incorrect hash"),
|
||||
|
||||
@@ -250,7 +250,8 @@ func TestBlockMaxDataBytesNoEvidence(t *testing.T) {
|
||||
func TestBlockProtoBuf(t *testing.T) {
|
||||
h := mrand.Int63()
|
||||
c1 := test.MakeRandomCommit(time.Now())
|
||||
b1 := block.MakeBlock(h, []mempool.Tx{mempool.Tx([]byte{1})}, &metadata.Commit{Signatures: []metadata.CommitSig{}}, []evidence.Evidence{})
|
||||
b1 := block.MakeBlock(h, []mempool.Tx{mempool.Tx([]byte{1})}, &metadata.Commit{Signatures: []metadata.CommitSig{}},
|
||||
[]evidence.Evidence{})
|
||||
b1.ProposerAddress = tmrand.Bytes(crypto.AddressSize)
|
||||
|
||||
b2 := block.MakeBlock(h, []mempool.Tx{mempool.Tx([]byte{1})}, c1, []evidence.Evidence{})
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
"github.com/tendermint/tendermint/internal/libs/protoio"
|
||||
"github.com/tendermint/tendermint/internal/test/factory"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/pkg/consensus"
|
||||
"github.com/tendermint/tendermint/pkg/metadata"
|
||||
@@ -147,7 +148,10 @@ func TestProposalValidateBasic(t *testing.T) {
|
||||
p.Signature = make([]byte, metadata.MaxSignatureSize+1)
|
||||
}, true},
|
||||
}
|
||||
blockID := metadata.BlockID{tmhash.Sum([]byte("blockhash")), metadata.PartSetHeader{math.MaxInt32, tmhash.Sum([]byte("partshash"))}}
|
||||
blockID := metadata.BlockID{
|
||||
Hash: tmhash.Sum([]byte("blockhash")),
|
||||
PartSetHeader: metadata.PartSetHeader{math.MaxInt32, tmhash.Sum([]byte("partshash"))},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
@@ -166,7 +170,7 @@ func TestProposalValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProposalProtoBuf(t *testing.T) {
|
||||
proposal := consensus.NewProposal(1, 2, 3, metadata.BlockID{[]byte("hash"), metadata.PartSetHeader{2, []byte("part_set_hash")}})
|
||||
proposal := consensus.NewProposal(1, 2, 3, factory.MakeBlockID())
|
||||
proposal.Signature = []byte("sig")
|
||||
proposal2 := consensus.NewProposal(1, 2, 3, metadata.BlockID{})
|
||||
|
||||
@@ -180,12 +184,12 @@ func TestProposalProtoBuf(t *testing.T) {
|
||||
{"empty proposal failure validatebasic", &consensus.Proposal{}, false},
|
||||
{"nil proposal", nil, false},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
for idx, tc := range testCases {
|
||||
protoProposal := tc.p1.ToProto()
|
||||
|
||||
p, err := consensus.ProposalFromProto(protoProposal)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, err, idx)
|
||||
require.Equal(t, tc.p1, p, tc.msg)
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
|
||||
@@ -91,7 +91,8 @@ func VerifyCommitLight(chainID string, vals *ValidatorSet, blockID metadata.Bloc
|
||||
//
|
||||
// This method is primarily used by the light client and does not check all the
|
||||
// signatures.
|
||||
func VerifyCommitLightTrusting(chainID string, vals *ValidatorSet, commit *metadata.Commit, trustLevel tmmath.Fraction) error {
|
||||
func VerifyCommitLightTrusting(chainID string, vals *ValidatorSet, commit *metadata.Commit,
|
||||
trustLevel tmmath.Fraction) error {
|
||||
// sanity checks
|
||||
if vals == nil {
|
||||
return errors.New("nil validator set")
|
||||
@@ -319,7 +320,8 @@ func verifyCommitSingle(
|
||||
return nil
|
||||
}
|
||||
|
||||
func verifyBasicValsAndCommit(vals *ValidatorSet, commit *metadata.Commit, height int64, blockID metadata.BlockID) error {
|
||||
func verifyBasicValsAndCommit(vals *ValidatorSet, commit *metadata.Commit, height int64,
|
||||
blockID metadata.BlockID) error {
|
||||
if vals == nil {
|
||||
return errors.New("nil validator set")
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestValidatorSet_VerifyCommit_All(t *testing.T) {
|
||||
round = int32(0)
|
||||
height = int64(100)
|
||||
|
||||
blockID = test.MakeBlockIDWithHash([]byte("blockhash"))
|
||||
blockID = test.MakeBlockIDFromBytes([]byte("blockhash"))
|
||||
chainID = "Lalande21185"
|
||||
trustLevel = tmmath.Fraction{Numerator: 2, Denominator: 3}
|
||||
)
|
||||
|
||||
@@ -670,7 +670,8 @@ func (vals *ValidatorSet) VerifyCommitLight(chainID string, blockID metadata.Blo
|
||||
|
||||
// VerifyCommitLightTrusting verifies that trustLevel of the validator set signed
|
||||
// this commit.
|
||||
func (vals *ValidatorSet) VerifyCommitLightTrusting(chainID string, commit *metadata.Commit, trustLevel tmmath.Fraction) error {
|
||||
func (vals *ValidatorSet) VerifyCommitLightTrusting(chainID string, commit *metadata.Commit,
|
||||
trustLevel tmmath.Fraction) error {
|
||||
return VerifyCommitLightTrusting(chainID, vals, commit, trustLevel)
|
||||
}
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ func TestCommitToVoteSet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCommitToVoteSetWithVotesForNilBlock(t *testing.T) {
|
||||
blockID := test.MakeBlockIDWithHash([]byte("blockhash"))
|
||||
blockID := test.MakeBlockIDFromBytes([]byte("blockhash"))
|
||||
|
||||
const (
|
||||
height = int64(3)
|
||||
|
||||
@@ -87,7 +87,8 @@ var _ Evidence = &DuplicateVoteEvidence{}
|
||||
|
||||
// NewDuplicateVoteEvidence creates DuplicateVoteEvidence with right ordering given
|
||||
// two conflicting votes. If one of the votes is nil, evidence returned is nil as well
|
||||
func NewDuplicateVoteEvidence(vote1, vote2 *consensus.Vote, blockTime time.Time, valSet *consensus.ValidatorSet) *DuplicateVoteEvidence {
|
||||
func NewDuplicateVoteEvidence(vote1, vote2 *consensus.Vote, blockTime time.Time,
|
||||
valSet *consensus.ValidatorSet) *DuplicateVoteEvidence {
|
||||
var voteA, voteB *consensus.Vote
|
||||
if vote1 == nil || vote2 == nil || valSet == nil {
|
||||
return nil
|
||||
@@ -274,7 +275,7 @@ type LightClientAttackEvidence struct {
|
||||
CommonHeight int64
|
||||
|
||||
// abci specific information
|
||||
ByzantineValidators []*consensus.Validator // validators in the validator set that misbehaved in creating the conflicting block
|
||||
ByzantineValidators []*consensus.Validator // validators in the validator set that misbehaved
|
||||
TotalVotingPower int64 // total voting power of the validator set at the common height
|
||||
Timestamp time.Time // timestamp of the block at the common height
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ func TestEvidenceList(t *testing.T) {
|
||||
|
||||
func randomDuplicateVoteEvidence(t *testing.T) *evidence.DuplicateVoteEvidence {
|
||||
val := consensus.NewMockPV()
|
||||
blockID := test.MakeBlockIDWithHash([]byte("blockhash"))
|
||||
blockID2 := test.MakeBlockIDWithHash([]byte("blockhash2"))
|
||||
blockID := test.MakeBlockIDFromBytes([]byte("blockhash"))
|
||||
blockID2 := test.MakeBlockIDFromBytes([]byte("blockhash2"))
|
||||
const chainID = "mychain"
|
||||
return &evidence.DuplicateVoteEvidence{
|
||||
VoteA: makeVote(t, val, chainID, 0, 10, 2, 1, blockID, defaultVoteTime),
|
||||
@@ -59,8 +59,8 @@ func TestDuplicateVoteEvidence(t *testing.T) {
|
||||
|
||||
func TestDuplicateVoteEvidenceValidation(t *testing.T) {
|
||||
val := consensus.NewMockPV()
|
||||
blockID := test.MakeBlockIDWithHash(tmhash.Sum([]byte("blockhash")))
|
||||
blockID2 := test.MakeBlockIDWithHash(tmhash.Sum([]byte("blockhash2")))
|
||||
blockID := test.MakeBlockIDFromBytes(tmhash.Sum([]byte("blockhash")))
|
||||
blockID2 := test.MakeBlockIDFromBytes(tmhash.Sum([]byte("blockhash2")))
|
||||
const chainID = "mychain"
|
||||
|
||||
testCases := []struct {
|
||||
@@ -104,7 +104,7 @@ func TestLightClientAttackEvidenceBasic(t *testing.T) {
|
||||
voteSet, valSet, privVals := test.RandVoteSet(height, 1, tmproto.PrecommitType, nValidators, 1)
|
||||
header := makeHeaderRandom()
|
||||
header.Height = height
|
||||
blockID := test.MakeBlockIDWithHash(tmhash.Sum([]byte("blockhash")))
|
||||
blockID := test.MakeBlockIDFromBytes(tmhash.Sum([]byte("blockhash")))
|
||||
commit, err := test.MakeCommit(blockID, height, 1, voteSet, privVals, defaultVoteTime)
|
||||
require.NoError(t, err)
|
||||
lcae := &evidence.LightClientAttackEvidence{
|
||||
@@ -236,9 +236,8 @@ func TestMockEvidenceValidateBasic(t *testing.T) {
|
||||
assert.Nil(t, goodEvidence.ValidateBasic())
|
||||
}
|
||||
|
||||
func makeVote(
|
||||
t *testing.T, val consensus.PrivValidator, chainID string, valIndex int32, height int64, round int32, step int, blockID metadata.BlockID,
|
||||
time time.Time) *consensus.Vote {
|
||||
func makeVote(t *testing.T, val consensus.PrivValidator, chainID string, valIndex int32,
|
||||
height int64, round int32, step int, blockID metadata.BlockID, time time.Time) *consensus.Vote {
|
||||
pubKey, err := val.GetPubKey(context.Background())
|
||||
require.NoError(t, err)
|
||||
v := &consensus.Vote{
|
||||
@@ -378,15 +377,15 @@ func TestEvidenceVectors(t *testing.T) {
|
||||
}{
|
||||
{"duplicateVoteEvidence",
|
||||
evidence.EvidenceList{&evidence.DuplicateVoteEvidence{VoteA: v2, VoteB: v}},
|
||||
"a9ce28d13bb31001fc3e5b7927051baf98f86abdbd64377643a304164c826923",
|
||||
"71fe3d5d3d38e6c28afa7c57ac981178df7817e0ce7b76c41bbb03e5559a8c01",
|
||||
},
|
||||
{"LightClientAttackEvidence",
|
||||
evidence.EvidenceList{lcae},
|
||||
"2f8782163c3905b26e65823ababc977fe54e97b94e60c0360b1e4726b668bb8e",
|
||||
"c4cd12cabaf4159240902766e43997f70ad90b47e01a9f5cf0f1b145e1c75779",
|
||||
},
|
||||
{"LightClientAttackEvidence & DuplicateVoteEvidence",
|
||||
evidence.EvidenceList{&evidence.DuplicateVoteEvidence{VoteA: v2, VoteB: v}, lcae},
|
||||
"eedb4b47d6dbc9d43f53da8aa50bb826e8d9fc7d897da777c8af6a04aa74163e",
|
||||
"735a5b042e6b350711f5296eabbc4688bb5f3b57829edc14c4e9f794361216ef",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,10 @@ func TestLightBlockValidateBasic(t *testing.T) {
|
||||
{"valid light block", sh, vals, false},
|
||||
{"hashes don't match", sh, vals2, true},
|
||||
{"invalid validator set", sh, vals3, true},
|
||||
{"invalid signed header", &metadata.SignedHeader{Header: header, Commit: test.MakeRandomCommit(time.Now())}, vals, true},
|
||||
{"invalid signed header", &metadata.SignedHeader{
|
||||
Header: header,
|
||||
Commit: test.MakeRandomCommit(time.Now()),
|
||||
}, vals, true},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestHeaderHash(t *testing.T) {
|
||||
LastResultsHash: tmhash.Sum([]byte("last_results_hash")),
|
||||
EvidenceHash: tmhash.Sum([]byte("evidence_hash")),
|
||||
ProposerAddress: crypto.AddressHash([]byte("proposer_address")),
|
||||
}, hexBytesFromString("F740121F553B5418C3EFBD343C2DBFE9E007BB67B0D020A0741374BAB65242A4")},
|
||||
}, hexBytesFromString("B8C1FA74E943A05664AD19C97D6D89EED19400D6749D912C2F3A4AA15B3D8E92")},
|
||||
{"nil header yields nil", nil, nil},
|
||||
{"nil ValidatorsHash yields nil", &metadata.Header{
|
||||
Version: version.Consensus{Block: 1, App: 2},
|
||||
@@ -132,11 +132,14 @@ func TestMaxHeaderBytes(t *testing.T) {
|
||||
timestamp := time.Date(math.MaxInt64, 0, 0, 0, 0, 0, math.MaxInt64, time.UTC)
|
||||
|
||||
h := metadata.Header{
|
||||
Version: version.Consensus{Block: math.MaxInt64, App: math.MaxInt64},
|
||||
ChainID: maxChainID,
|
||||
Height: math.MaxInt64,
|
||||
Time: timestamp,
|
||||
LastBlockID: metadata.BlockID{make([]byte, tmhash.Size), metadata.PartSetHeader{math.MaxInt32, make([]byte, tmhash.Size)}},
|
||||
Version: version.Consensus{Block: math.MaxInt64, App: math.MaxInt64},
|
||||
ChainID: maxChainID,
|
||||
Height: math.MaxInt64,
|
||||
Time: timestamp,
|
||||
LastBlockID: metadata.BlockID{
|
||||
Hash: make([]byte, tmhash.Size),
|
||||
PartSetHeader: metadata.PartSetHeader{math.MaxInt32, make([]byte, tmhash.Size)},
|
||||
},
|
||||
LastCommitHash: tmhash.Sum([]byte("last_commit_hash")),
|
||||
DataHash: tmhash.Sum([]byte("data_hash")),
|
||||
ValidatorsHash: tmhash.Sum([]byte("validators_hash")),
|
||||
|
||||
@@ -67,7 +67,7 @@ func TestBlockIDValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlockIDProtoBuf(t *testing.T) {
|
||||
blockID := test.MakeBlockIDWithHash([]byte("hash"))
|
||||
blockID := test.MakeBlockIDFromBytes([]byte("hash"))
|
||||
testCases := []struct {
|
||||
msg string
|
||||
bid1 *metadata.BlockID
|
||||
|
||||
@@ -24,7 +24,8 @@ import (
|
||||
|
||||
const chainID = "chain-id"
|
||||
|
||||
func dialer(pv consensus.PrivValidator, logger log.Logger) (*grpc.Server, func(context.Context, string) (net.Conn, error)) {
|
||||
func dialer(pv consensus.PrivValidator, logger log.Logger,
|
||||
) (*grpc.Server, func(context.Context, string) (net.Conn, error)) {
|
||||
listener := bufconn.Listen(1024 * 1024)
|
||||
|
||||
server := grpc.NewServer()
|
||||
|
||||
@@ -50,7 +50,7 @@ type Local struct {
|
||||
// local RPC client constructor needs to build a local client.
|
||||
type NodeService interface {
|
||||
RPCEnvironment() *rpccore.Environment
|
||||
EventBus() *types.EventBus
|
||||
EventBus() *events.EventBus
|
||||
}
|
||||
|
||||
// New configures a client that calls the Node directly.
|
||||
|
||||
@@ -63,7 +63,7 @@ func (env *Environment) DumpConsensusState(ctx *rpctypes.Context) (*ctypes.Resul
|
||||
peers := env.P2PPeers.Peers().List()
|
||||
peerStates = make([]ctypes.PeerStateInfo, 0, len(peers))
|
||||
for _, peer := range peers {
|
||||
peerState, ok := peer.Get(types.PeerStateKey).(*cm.PeerState)
|
||||
peerState, ok := peer.Get(consensus.PeerStateKey).(*cm.PeerState)
|
||||
if !ok { // peer does not have a state yet
|
||||
continue
|
||||
}
|
||||
|
||||
+2
-2
@@ -61,8 +61,8 @@ type peers interface {
|
||||
}
|
||||
|
||||
type peerManager interface {
|
||||
Peers() []types.NodeID
|
||||
Addresses(types.NodeID) []p2p.NodeAddress
|
||||
Peers() []p2ptypes.NodeID
|
||||
Addresses(p2ptypes.NodeID) []p2p.NodeAddress
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
|
||||
@@ -149,8 +149,8 @@ type ResultDialPeers struct {
|
||||
|
||||
// A peer
|
||||
type Peer struct {
|
||||
ID types.NodeID `json:"node_id"`
|
||||
URL string `json:"url"`
|
||||
ID p2ptypes.NodeID `json:"node_id"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// Validators for a height.
|
||||
|
||||
+4
-1
@@ -599,7 +599,10 @@ func ExecCommitBlock(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
blockID := metadata.BlockID{Hash: block.Hash(), PartSetHeader: block.MakePartSet(metadata.BlockPartSizeBytes).Header()}
|
||||
blockID := metadata.BlockID{
|
||||
Hash: block.Hash(),
|
||||
PartSetHeader: block.MakePartSet(metadata.BlockPartSizeBytes).Header(),
|
||||
}
|
||||
fireEvents(be.logger, be.eventBus, block, blockID, abciResponses, validatorUpdates)
|
||||
}
|
||||
|
||||
|
||||
@@ -199,8 +199,8 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
|
||||
|
||||
evpool := &mocks.EvidencePool{}
|
||||
evpool.On("PendingEvidence", mock.AnythingOfType("int64")).Return(ev, int64(100))
|
||||
evpool.On("Update", mock.AnythingOfType("state.State"), mock.AnythingOfType("types.EvidenceList")).Return()
|
||||
evpool.On("CheckEvidence", mock.AnythingOfType("types.EvidenceList")).Return(nil)
|
||||
evpool.On("Update", mock.AnythingOfType("state.State"), mock.AnythingOfType("evidence.EvidenceList")).Return()
|
||||
evpool.On("CheckEvidence", mock.AnythingOfType("evidence.EvidenceList")).Return(nil)
|
||||
|
||||
blockStore := store.NewBlockStore(dbm.NewMemDB())
|
||||
|
||||
|
||||
@@ -249,9 +249,9 @@ func TestValidateBlockEvidence(t *testing.T) {
|
||||
defaultEvidenceTime := time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
evpool := &mocks.EvidencePool{}
|
||||
evpool.On("CheckEvidence", mock.AnythingOfType("types.EvidenceList")).Return(nil)
|
||||
evpool.On("Update", mock.AnythingOfType("state.State"), mock.AnythingOfType("types.EvidenceList")).Return()
|
||||
evpool.On("ABCIEvidence", mock.AnythingOfType("int64"), mock.AnythingOfType("[]types.Evidence")).Return(
|
||||
evpool.On("CheckEvidence", mock.AnythingOfType("evidence.EvidenceList")).Return(nil)
|
||||
evpool.On("Update", mock.AnythingOfType("state.State"), mock.AnythingOfType("evidence.EvidenceList")).Return()
|
||||
evpool.On("ABCIEvidence", mock.AnythingOfType("int64"), mock.AnythingOfType("[]evidence.Evidence")).Return(
|
||||
[]abci.Evidence{})
|
||||
|
||||
state.ConsensusParams.Evidence.MaxBytes = 1000
|
||||
|
||||
Reference in New Issue
Block a user