From 82ac5569a0b91774ea72d1737194acd9f831b8e5 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 24 Aug 2021 18:17:59 +0200 Subject: [PATCH] clean up tests --- internal/statesync/reactor_test.go | 2 +- internal/test/factory/block.go | 6 +++++- internal/test/factory/commit.go | 3 ++- internal/test/factory/vote.go | 5 ++++- light/helpers_test.go | 6 ++++-- node/node_test.go | 2 +- pkg/block/block_meta.go | 5 ++++- pkg/block/block_meta_test.go | 6 ++++-- pkg/block/block_test.go | 3 ++- pkg/consensus/proposal_test.go | 12 ++++++++---- pkg/consensus/validation.go | 6 ++++-- pkg/consensus/validation_test.go | 2 +- pkg/consensus/validator_set.go | 3 ++- pkg/consensus/vote_set_test.go | 2 +- pkg/evidence/evidence.go | 5 +++-- pkg/evidence/evidence_test.go | 21 ++++++++++----------- pkg/light/light_test.go | 5 ++++- pkg/metadata/header_test.go | 15 +++++++++------ pkg/metadata/id_test.go | 2 +- privval/grpc/client_test.go | 3 ++- rpc/client/local/local.go | 2 +- rpc/core/consensus.go | 2 +- rpc/core/env.go | 4 ++-- rpc/core/types/responses.go | 4 ++-- state/execution.go | 5 ++++- state/execution_test.go | 4 ++-- state/validation_test.go | 6 +++--- 27 files changed, 87 insertions(+), 54 deletions(-) diff --git a/internal/statesync/reactor_test.go b/internal/statesync/reactor_test.go index d394c557b..70c0b8003 100644 --- a/internal/statesync/reactor_test.go +++ b/internal/statesync/reactor_test.go @@ -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) diff --git a/internal/test/factory/block.go b/internal/test/factory/block.go index 9b4bbbf9e..b6decf375 100644 --- a/internal/test/factory/block.go +++ b/internal/test/factory/block.go @@ -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")), }, } } diff --git a/internal/test/factory/commit.go b/internal/test/factory/commit.go index 866b03751..aa9994467 100644 --- a/internal/test/factory/commit.go +++ b/internal/test/factory/commit.go @@ -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 { diff --git a/internal/test/factory/vote.go b/internal/test/factory/vote.go index e23448003..96d746ed7 100644 --- a/internal/test/factory/vote.go +++ b/internal/test/factory/vote.go @@ -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) diff --git a/light/helpers_test.go b/light/helpers_test.go index 2e4ac066e..dad52385c 100644 --- a/light/helpers_test.go +++ b/light/helpers_test.go @@ -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{ diff --git a/node/node_test.go b/node/node_test.go index 07f61fdf7..5918433cc 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -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, diff --git a/pkg/block/block_meta.go b/pkg/block/block_meta.go index fac52de04..3e2991871 100644 --- a/pkg/block/block_meta.go +++ b/pkg/block/block_meta.go @@ -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), diff --git a/pkg/block/block_meta_test.go b/pkg/block/block_meta_test.go index 6748baeb7..68944899f 100644 --- a/pkg/block/block_meta_test.go +++ b/pkg/block/block_meta_test.go @@ -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"), diff --git a/pkg/block/block_test.go b/pkg/block/block_test.go index e60fb0c34..d9d91e8bb 100644 --- a/pkg/block/block_test.go +++ b/pkg/block/block_test.go @@ -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{}) diff --git a/pkg/consensus/proposal_test.go b/pkg/consensus/proposal_test.go index 34fbeb9c1..c685af5c7 100644 --- a/pkg/consensus/proposal_test.go +++ b/pkg/consensus/proposal_test.go @@ -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) diff --git a/pkg/consensus/validation.go b/pkg/consensus/validation.go index dad6e6281..25c581e09 100644 --- a/pkg/consensus/validation.go +++ b/pkg/consensus/validation.go @@ -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") } diff --git a/pkg/consensus/validation_test.go b/pkg/consensus/validation_test.go index f82bacee3..11b75d8cf 100644 --- a/pkg/consensus/validation_test.go +++ b/pkg/consensus/validation_test.go @@ -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} ) diff --git a/pkg/consensus/validator_set.go b/pkg/consensus/validator_set.go index e4dba7ba6..b5bba8895 100644 --- a/pkg/consensus/validator_set.go +++ b/pkg/consensus/validator_set.go @@ -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) } diff --git a/pkg/consensus/vote_set_test.go b/pkg/consensus/vote_set_test.go index 17fe42d12..e6f88f7b1 100644 --- a/pkg/consensus/vote_set_test.go +++ b/pkg/consensus/vote_set_test.go @@ -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) diff --git a/pkg/evidence/evidence.go b/pkg/evidence/evidence.go index acb1bdd52..ff78979c7 100644 --- a/pkg/evidence/evidence.go +++ b/pkg/evidence/evidence.go @@ -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 } diff --git a/pkg/evidence/evidence_test.go b/pkg/evidence/evidence_test.go index 80ccb6e17..480d90c0b 100644 --- a/pkg/evidence/evidence_test.go +++ b/pkg/evidence/evidence_test.go @@ -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", }, } diff --git a/pkg/light/light_test.go b/pkg/light/light_test.go index ff0dce46f..eb0dbd288 100644 --- a/pkg/light/light_test.go +++ b/pkg/light/light_test.go @@ -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 { diff --git a/pkg/metadata/header_test.go b/pkg/metadata/header_test.go index dfbe15221..1ec371171 100644 --- a/pkg/metadata/header_test.go +++ b/pkg/metadata/header_test.go @@ -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")), diff --git a/pkg/metadata/id_test.go b/pkg/metadata/id_test.go index 2d7c60ec4..4cbcd7e9d 100644 --- a/pkg/metadata/id_test.go +++ b/pkg/metadata/id_test.go @@ -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 diff --git a/privval/grpc/client_test.go b/privval/grpc/client_test.go index 59ec2a11f..e7ecc8964 100644 --- a/privval/grpc/client_test.go +++ b/privval/grpc/client_test.go @@ -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() diff --git a/rpc/client/local/local.go b/rpc/client/local/local.go index 847211eaf..2f683432b 100644 --- a/rpc/client/local/local.go +++ b/rpc/client/local/local.go @@ -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. diff --git a/rpc/core/consensus.go b/rpc/core/consensus.go index 3a5a4b6ac..c8bb31088 100644 --- a/rpc/core/consensus.go +++ b/rpc/core/consensus.go @@ -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 } diff --git a/rpc/core/env.go b/rpc/core/env.go index 7154a5cc4..1d6362994 100644 --- a/rpc/core/env.go +++ b/rpc/core/env.go @@ -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 } //---------------------------------------------- diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 8be626386..f77fd5423 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -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. diff --git a/state/execution.go b/state/execution.go index a4633cb3f..c0d5684d7 100644 --- a/state/execution.go +++ b/state/execution.go @@ -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) } diff --git a/state/execution_test.go b/state/execution_test.go index 1e324e904..fe8302fec 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -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()) diff --git a/state/validation_test.go b/state/validation_test.go index be74264b9..648d200ba 100644 --- a/state/validation_test.go +++ b/state/validation_test.go @@ -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