From 0262cd0987827965819e6f4528cd425c216332a1 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:53:25 +0300 Subject: [PATCH] fix: tests and build everywhere --- blockchain/msgs_test.go | 5 +++++ blockchain/v0/reactor_test.go | 9 +++++++-- consensus/byzantine_test.go | 4 ++-- consensus/common_test.go | 2 +- consensus/msgs_test.go | 7 ++++--- consensus/replay_test.go | 16 ++++++++++------ consensus/state_test.go | 4 ++-- evidence/pool_test.go | 10 ++++++++-- light/client.go | 3 +-- light/provider/http/http.go | 3 ++- node/node_test.go | 6 +++--- privval/file_test.go | 3 ++- privval/msgs_test.go | 3 ++- privval/signer_client_test.go | 7 ++++--- rpc/core/types/responses.go | 3 ++- state/execution_test.go | 2 +- state/helpers_test.go | 13 ++++++++++--- state/validation_test.go | 12 +++++------- store/store_test.go | 9 +++++++-- tools/tm-signer-harness/internal/test_harness.go | 3 ++- 20 files changed, 80 insertions(+), 44 deletions(-) diff --git a/blockchain/msgs_test.go b/blockchain/msgs_test.go index 3a608430e8..8c83d0ce01 100644 --- a/blockchain/msgs_test.go +++ b/blockchain/msgs_test.go @@ -1,11 +1,13 @@ package blockchain import ( + "context" "encoding/hex" "math" "testing" "github.com/gogo/protobuf/proto" + mdutils "github.com/ipfs/go-merkledag/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -83,6 +85,9 @@ func TestBlockchainMessageVectors(t *testing.T) { block := types.MakeBlock(int64(3), []types.Tx{types.Tx("Hello World")}, nil, nil, types.Messages{}, nil) block.Version.Block = 11 // overwrite updated protocol version + _, err := block.RowSet(context.TODO(), mdutils.Mock()) + require.NoError(t, err) + bpb, err := block.ToProto() require.NoError(t, err) diff --git a/blockchain/v0/reactor_test.go b/blockchain/v0/reactor_test.go index 218caf0b43..4a4ca46a1a 100644 --- a/blockchain/v0/reactor_test.go +++ b/blockchain/v0/reactor_test.go @@ -1,6 +1,7 @@ package v0 import ( + "context" "crypto/sha256" "fmt" "os" @@ -294,9 +295,13 @@ func makeTxs(height int64) (txs []types.Tx) { } func makeBlock(height int64, state sm.State, lastCommit *types.Commit) *types.Block { - block, _ := state.MakeBlock(height, makeTxs(height), nil, + b := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, lastCommit, state.Validators.GetProposer().Address) - return block + _, err := b.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + panic(err) + } + return b } type testApp struct { diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index 0436b8bfef..f286d6b840 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -381,7 +381,7 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St // Avoid sending on internalMsgQueue and running consensus state. // Create a new proposal block from state/txs from the mempool. - block1, blockParts1 := cs.createProposalBlock() + block1, blockParts1, _ := cs.createProposalBlock() polRound, propBlockID := cs.ValidRound, types.BlockID{Hash: block1.Hash(), PartSetHeader: blockParts1.Header()} proposal1 := types.NewProposal(height, round, polRound, propBlockID, &block1.DataAvailabilityHeader) p1, err := proposal1.ToProto() @@ -396,7 +396,7 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St deliverTxsRange(cs, 0, 1) // Create a new proposal block from state/txs from the mempool. - block2, blockParts2 := cs.createProposalBlock() + block2, blockParts2, _ := cs.createProposalBlock() polRound, propBlockID = cs.ValidRound, types.BlockID{Hash: block2.Hash(), PartSetHeader: blockParts2.Header()} proposal2 := types.NewProposal(height, round, polRound, propBlockID, &block2.DataAvailabilityHeader) p2, err := proposal2.ToProto() diff --git a/consensus/common_test.go b/consensus/common_test.go index e3372552fd..87cb012404 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -193,7 +193,7 @@ func decideProposal( round int32, ) (proposal *types.Proposal, block *types.Block) { cs1.mtx.Lock() - block, blockParts := cs1.createProposalBlock() + block, blockParts, _ := cs1.createProposalBlock() validRound := cs1.ValidRound chainID := cs1.state.ChainID cs1.mtx.Unlock() diff --git a/consensus/msgs_test.go b/consensus/msgs_test.go index 1ca5c30b62..83a404b53e 100644 --- a/consensus/msgs_test.go +++ b/consensus/msgs_test.go @@ -15,6 +15,7 @@ import ( "github.com/lazyledger/lazyledger-core/libs/bits" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" "github.com/lazyledger/lazyledger-core/p2p" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmcons "github.com/lazyledger/lazyledger-core/proto/tendermint/consensus" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" @@ -48,7 +49,7 @@ func TestMsgToProto(t *testing.T) { pbParts, err := parts.ToProto() require.NoError(t, err) - roots, err := types.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) + roots, err := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) require.NoError(t, err) proposal := types.Proposal{ Type: tmproto.ProposalType, @@ -58,7 +59,7 @@ func TestMsgToProto(t *testing.T) { BlockID: bi, Timestamp: time.Now(), Signature: tmrand.Bytes(20), - DAHeader: &types.DataAvailabilityHeader{ + DAHeader: &ipld.DataAvailabilityHeader{ RowsRoots: roots, ColumnRoots: roots, }, @@ -361,7 +362,7 @@ func TestConsMsgsVectors(t *testing.T) { BlockID: bi, Timestamp: date, Signature: []byte("add_more_exclamation"), - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } pbProposal, err := proposal.ToProto() require.NoError(t, err) diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 781aaa38d9..789f0b6bfc 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -370,7 +370,7 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts := propBlock.MakePartSet(partSize) blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} @@ -401,7 +401,7 @@ func TestSimulateValidatorsChange(t *testing.T) { updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) err = assertMempool(css[0].txNotifier).CheckTx(updateValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} @@ -439,7 +439,7 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} newVss := make([]*validatorStub, nVals+1) @@ -515,7 +515,7 @@ func TestSimulateValidatorsChange(t *testing.T) { removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0) err = assertMempool(css[0].txNotifier).CheckTx(removeValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} newVss = make([]*validatorStub, nVals+3) @@ -1001,8 +1001,7 @@ func makeBlock(state sm.State, lastBlock *types.Block, lastBlockMeta *types.Bloc lastCommit = types.NewCommit(vote.Height, vote.Round, lastBlockMeta.BlockID, []types.CommitSig{vote.CommitSig()}) } - - return state.MakeBlock( + block := state.MakeBlock( height, []types.Tx{}, nil, @@ -1011,6 +1010,11 @@ func makeBlock(state sm.State, lastBlock *types.Block, lastBlockMeta *types.Bloc lastCommit, state.Validators.GetProposer().Address, ) + _, err := block.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + panic(err) + } + return block, block.MakePartSet(types.BlockPartSizeBytes) } type badApp struct { diff --git a/consensus/state_test.go b/consensus/state_test.go index e713917dd5..cd47dc1fc9 100644 --- a/consensus/state_test.go +++ b/consensus/state_test.go @@ -194,7 +194,7 @@ func TestStateBadProposal(t *testing.T) { proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2) // make the second validator the proposer by incrementing round round++ @@ -255,7 +255,7 @@ func TestStateOversizedBlock(t *testing.T) { timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _ := cs1.createProposalBlock() + propBlock, _, _ := cs1.createProposalBlock() propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)} propBlock.Header.DataHash = propBlock.DataAvailabilityHeader.Hash() diff --git a/evidence/pool_test.go b/evidence/pool_test.go index 0c5a64a51f..180a005d92 100644 --- a/evidence/pool_test.go +++ b/evidence/pool_test.go @@ -1,6 +1,7 @@ package evidence_test import ( + "context" "os" "testing" "time" @@ -175,6 +176,8 @@ func TestEvidencePoolUpdate(t *testing.T) { val, evidenceChainID) lastCommit := makeCommit(height, val.PrivKey.PubKey().Address()) block := types.MakeBlock(height+1, []types.Tx{}, []types.Evidence{ev}, nil, types.Messages{}, lastCommit) + _, err = block.RowSet(context.TODO(), mdutils.Mock()) + require.NoError(t, err) // update state (partially) state.LastBlockHeight = height + 1 state.LastBlockTime = defaultEvidenceTime.Add(22 * time.Minute) @@ -400,13 +403,16 @@ func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) *store.Bloc for i := int64(1); i <= state.LastBlockHeight; i++ { lastCommit := makeCommit(i-1, valAddr) - block, _ := state.MakeBlock(i, []types.Tx{}, nil, nil, + block := state.MakeBlock(i, []types.Tx{}, nil, nil, types.Messages{}, lastCommit, state.Validators.GetProposer().Address) block.Header.Time = defaultEvidenceTime.Add(time.Duration(i) * time.Minute) block.Header.Version = tmversion.Consensus{Block: version.BlockProtocol, App: 1} const parts = 1 partSet := block.MakePartSet(parts) - + _, err := block.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + panic(err) + } seenCommit := makeCommit(i, valAddr) blockStore.SaveBlock(block, partSet, seenCommit) } diff --git a/light/client.go b/light/client.go index fca018058a..cecfc429fa 100644 --- a/light/client.go +++ b/light/client.go @@ -9,7 +9,6 @@ import ( format "github.com/ipfs/go-ipld-format" "github.com/ipfs/go-merkledag" - "github.com/lazyledger/nmt/namespace" "github.com/lazyledger/lazyledger-core/libs/log" tmmath "github.com/lazyledger/lazyledger-core/libs/math" @@ -700,7 +699,7 @@ func (c *Client) verifySequential( c.dag, interimBlock.DataAvailabilityHeader, numSamples, - func(data namespace.PrefixedData8) {}, // noop + func(ipld.NamespacedShare) {}, // noop ) if err != nil { return fmt.Errorf("data availability sampling failed; ipld.ValidateAvailability: %w", err) diff --git a/light/provider/http/http.go b/light/provider/http/http.go index 566f4f85a6..c52e0db37c 100644 --- a/light/provider/http/http.go +++ b/light/provider/http/http.go @@ -10,6 +10,7 @@ import ( "time" "github.com/lazyledger/lazyledger-core/light/provider" + "github.com/lazyledger/lazyledger-core/p2p/ipld" rpcclient "github.com/lazyledger/lazyledger-core/rpc/client" rpchttp "github.com/lazyledger/lazyledger-core/rpc/client/http" "github.com/lazyledger/lazyledger-core/types" @@ -181,7 +182,7 @@ func (p *http) signedHeader(ctx context.Context, height *int64) (*types.SignedHe return nil, provider.ErrNoResponse } -func (p *http) daHeader(ctx context.Context, height *int64) (*types.DataAvailabilityHeader, error) { +func (p *http) daHeader(ctx context.Context, height *int64) (*ipld.DataAvailabilityHeader, error) { for attempt := 1; attempt <= maxRetryAttempts; attempt++ { daHeaderRes, err := p.client.DataAvailabilityHeader(ctx, height) if err != nil { diff --git a/node/node_test.go b/node/node_test.go index b2d4d560a2..b7b8dde040 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -322,7 +322,7 @@ func TestCreateProposalBlock(t *testing.T) { ) commit := types.NewCommit(height-1, 0, types.BlockID{}, nil) - block, _ := blockExec.CreateProposalBlock( + block, _, _ := blockExec.CreateProposalBlock( height, state, commit, proposerAddr, @@ -391,7 +391,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) { ) commit := types.NewCommit(height-1, 0, types.BlockID{}, nil) - block, _ := blockExec.CreateProposalBlock( + block, _, _ := blockExec.CreateProposalBlock( height, state, commit, proposerAddr, @@ -498,7 +498,7 @@ func TestMaxProposalBlockSize(t *testing.T) { commit.Signatures = append(commit.Signatures, cs) } - block, partSet := blockExec.CreateProposalBlock( + block, partSet, _ := blockExec.CreateProposalBlock( math.MaxInt64, state, commit, proposerAddr, diff --git a/privval/file_test.go b/privval/file_test.go index 9ddde34c84..ebaa56bfb9 100644 --- a/privval/file_test.go +++ b/privval/file_test.go @@ -15,6 +15,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto/tmhash" tmjson "github.com/lazyledger/lazyledger-core/libs/json" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" tmtime "github.com/lazyledger/lazyledger-core/types/time" @@ -350,6 +351,6 @@ func newProposal(height int64, round int32, blockID types.BlockID) *types.Propos Round: round, BlockID: blockID, Timestamp: tmtime.Now(), - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } } diff --git a/privval/msgs_test.go b/privval/msgs_test.go index a11e4221df..35eca0d725 100644 --- a/privval/msgs_test.go +++ b/privval/msgs_test.go @@ -12,6 +12,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto/ed25519" cryptoenc "github.com/lazyledger/lazyledger-core/crypto/encoding" "github.com/lazyledger/lazyledger-core/crypto/tmhash" + "github.com/lazyledger/lazyledger-core/p2p/ipld" cryptoproto "github.com/lazyledger/lazyledger-core/proto/tendermint/crypto" privproto "github.com/lazyledger/lazyledger-core/proto/tendermint/privval" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" @@ -54,7 +55,7 @@ func exampleProposal() *types.Proposal { Hash: tmhash.Sum([]byte("blockID_part_set_header_hash")), }, }, - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } } diff --git a/privval/signer_client_test.go b/privval/signer_client_test.go index 645e7ecb97..c51b483526 100644 --- a/privval/signer_client_test.go +++ b/privval/signer_client_test.go @@ -11,6 +11,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/crypto/tmhash" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" + "github.com/lazyledger/lazyledger-core/p2p/ipld" cryptoproto "github.com/lazyledger/lazyledger-core/proto/tendermint/crypto" privvalproto "github.com/lazyledger/lazyledger-core/proto/tendermint/privval" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" @@ -125,7 +126,7 @@ func TestSignerProposal(t *testing.T) { POLRound: 2, BlockID: types.BlockID{Hash: hash, PartSetHeader: types.PartSetHeader{Hash: hash, Total: 2}}, Timestamp: ts, - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } want := &types.Proposal{ Type: tmproto.ProposalType, @@ -134,7 +135,7 @@ func TestSignerProposal(t *testing.T) { POLRound: 2, BlockID: types.BlockID{Hash: hash, PartSetHeader: types.PartSetHeader{Hash: hash, Total: 2}}, Timestamp: ts, - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } tc := tc @@ -342,7 +343,7 @@ func TestSignerSignProposalErrors(t *testing.T) { BlockID: types.BlockID{Hash: hash, PartSetHeader: types.PartSetHeader{Hash: hash, Total: 2}}, Timestamp: ts, Signature: []byte("signature"), - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } p, err := proposal.ToProto() diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index bb206333f2..a191079ae2 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -8,6 +8,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/libs/bytes" "github.com/lazyledger/lazyledger-core/p2p" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" ) @@ -36,7 +37,7 @@ type ResultCommit struct { } type ResultDataAvailabilityHeader struct { - types.DataAvailabilityHeader `json:"data_availability_header"` + ipld.DataAvailabilityHeader `json:"data_availability_header"` } // ABCI results from a block diff --git a/state/execution_test.go b/state/execution_test.go index b6ea333d14..5c393746fd 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -100,7 +100,7 @@ func TestBeginBlockValidators(t *testing.T) { lastCommit := types.NewCommit(1, 0, prevBlockID, tc.lastCommitSigs) // block for height 2 - block, _ := state.MakeBlock(2, makeTxs(2), nil, nil, + block := state.MakeBlock(2, makeTxs(2), nil, nil, types.Messages{}, lastCommit, state.Validators.GetProposer().Address) _, err = sm.ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), stateStore, 1) diff --git a/state/helpers_test.go b/state/helpers_test.go index 32a3c78cf8..5a713244ea 100644 --- a/state/helpers_test.go +++ b/state/helpers_test.go @@ -2,9 +2,12 @@ package state_test import ( "bytes" + "context" "fmt" "time" + mdutils "github.com/ipfs/go-merkledag/test" + abci "github.com/lazyledger/lazyledger-core/abci/types" "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/crypto/ed25519" @@ -54,7 +57,7 @@ func makeAndCommitGoodBlock( func makeAndApplyGoodBlock(state sm.State, height int64, lastCommit *types.Commit, proposerAddr []byte, blockExec *sm.BlockExecutor, evidence []types.Evidence) (sm.State, types.BlockID, error) { - block, _ := state.MakeBlock( + block := state.MakeBlock( height, makeTxs(height), evidence, @@ -63,12 +66,16 @@ func makeAndApplyGoodBlock(state sm.State, height int64, lastCommit *types.Commi lastCommit, proposerAddr, ) + _, err := block.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + return sm.State{}, types.BlockID{}, err + } if err := blockExec.ValidateBlock(state, block); err != nil { return state, types.BlockID{}, err } blockID := types.BlockID{Hash: block.Hash(), PartSetHeader: types.PartSetHeader{Total: 3, Hash: tmrand.Bytes(32)}} - state, _, err := blockExec.ApplyBlock(state, blockID, block) + state, _, err = blockExec.ApplyBlock(state, blockID, block) if err != nil { return state, types.BlockID{}, err } @@ -140,7 +147,7 @@ func makeState(nVals, height int) (sm.State, dbm.DB, map[string]types.PrivValida } func makeBlock(state sm.State, height int64) *types.Block { - block, _ := state.MakeBlock( + block := state.MakeBlock( height, makeTxs(state.LastBlockHeight), nil, diff --git a/state/validation_test.go b/state/validation_test.go index 1aa1853d60..cd2e9f5a04 100644 --- a/state/validation_test.go +++ b/state/validation_test.go @@ -59,8 +59,6 @@ func TestValidateBlockHeader(t *testing.T) { {"LastBlockID wrong", func(block *types.Block) { block.LastBlockID.PartSetHeader.Total += 10 }}, {"LastCommitHash wrong", func(block *types.Block) { block.LastCommitHash = wrongHash }}, - {"DataHash wrong", func(block *types.Block) { block.DataHash = wrongHash }}, - {"ValidatorsHash wrong", func(block *types.Block) { block.ValidatorsHash = wrongHash }}, {"NextValidatorsHash wrong", func(block *types.Block) { block.NextValidatorsHash = wrongHash }}, {"ConsensusHash wrong", func(block *types.Block) { block.ConsensusHash = wrongHash }}, @@ -84,7 +82,7 @@ func TestValidateBlockHeader(t *testing.T) { Invalid blocks don't pass */ for _, tc := range testCases { - block, _ := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, lastCommit, proposerAddr) + block := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, lastCommit, proposerAddr) tc.malleateBlock(block) err := blockExec.ValidateBlock(state, block) t.Logf("%s: %v", tc.name, err) @@ -101,7 +99,7 @@ func TestValidateBlockHeader(t *testing.T) { } nextHeight := validationTestsStopHeight - block, _ := state.MakeBlock( + block := state.MakeBlock( nextHeight, makeTxs(nextHeight), nil, nil, types.Messages{}, lastCommit, @@ -153,7 +151,7 @@ func TestValidateBlockCommit(t *testing.T) { state.LastBlockID, []types.CommitSig{wrongHeightVote.CommitSig()}, ) - block, _ := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongHeightCommit, proposerAddr) + block := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongHeightCommit, proposerAddr) err = blockExec.ValidateBlock(state, block) _, isErrInvalidCommitHeight := err.(types.ErrInvalidCommitHeight) require.True(t, isErrInvalidCommitHeight, "expected ErrInvalidCommitHeight at height %d but got: %v", height, err) @@ -161,7 +159,7 @@ func TestValidateBlockCommit(t *testing.T) { /* #2589: test len(block.LastCommit.Signatures) == state.LastValidators.Size() */ - block, _ = state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongSigsCommit, proposerAddr) + block = state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongSigsCommit, proposerAddr) err = blockExec.ValidateBlock(state, block) _, isErrInvalidCommitSignatures := err.(types.ErrInvalidCommitSignatures) require.True(t, isErrInvalidCommitSignatures, @@ -270,7 +268,7 @@ func TestValidateBlockEvidence(t *testing.T) { evidence = append(evidence, newEv) currentBytes += int64(len(newEv.Bytes())) } - block, _ := state.MakeBlock(height, makeTxs(height), evidence, nil, types.Messages{}, lastCommit, proposerAddr) + block := state.MakeBlock(height, makeTxs(height), evidence, nil, types.Messages{}, lastCommit, proposerAddr) err := blockExec.ValidateBlock(state, block) if assert.Error(t, err) { _, ok := err.(*types.ErrEvidenceOverflow) diff --git a/store/store_test.go b/store/store_test.go index c7130e9bec..a2fdb7871f 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -2,6 +2,7 @@ package store import ( "bytes" + "context" "crypto/sha256" "fmt" "os" @@ -58,9 +59,13 @@ func makeTxs(height int64) (txs []types.Tx) { } func makeBlock(height int64, state sm.State, lastCommit *types.Commit) *types.Block { - block, _ := state.MakeBlock(height, makeTxs(height), nil, + b := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, lastCommit, state.Validators.GetProposer().Address) - return block + _, err := b.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + panic(err) + } + return b } func makeStateAndBlockStore(logger log.Logger) (sm.State, *BlockStore, cleanupFunc) { diff --git a/tools/tm-signer-harness/internal/test_harness.go b/tools/tm-signer-harness/internal/test_harness.go index e2a4d01532..b7656d38ab 100644 --- a/tools/tm-signer-harness/internal/test_harness.go +++ b/tools/tm-signer-harness/internal/test_harness.go @@ -9,6 +9,7 @@ import ( "time" "github.com/lazyledger/lazyledger-core/crypto/tmhash" + "github.com/lazyledger/lazyledger-core/p2p/ipld" "github.com/lazyledger/lazyledger-core/crypto/ed25519" "github.com/lazyledger/lazyledger-core/privval" @@ -228,7 +229,7 @@ func (th *TestHarness) TestSignProposal() error { }, }, Timestamp: time.Now(), - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } p, err := prop.ToProto() if err != nil {