Fix units tests

This commit is contained in:
Sergio Mena
2022-11-28 06:27:20 +01:00
parent c855c9d47c
commit 824a58e5be
4 changed files with 13 additions and 10 deletions

View File

@@ -202,10 +202,14 @@ func TestFinalizeBlockValidators(t *testing.T) {
}
for _, tc := range testCases {
lastCommit := types.NewExtendedCommit(1, 0, prevBlockID, tc.lastCommitSigs)
lastCommit := &types.Commit{
Height: 1,
BlockID: prevBlockID,
Signatures: tc.lastCommitSigs,
}
// block for height 2
block := makeBlock(state, 2, lastCommit.StripExtensions())
block := makeBlock(state, 2, lastCommit)
_, err = sm.ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), stateStore, 1)
require.Nil(t, err, tc.desc)

View File

@@ -118,7 +118,7 @@ func TestRollbackHard(t *testing.T) {
partSet, err := block.MakePartSet(types.BlockPartSizeBytes)
require.NoError(t, err)
blockStore.SaveBlock(block, partSet, &types.Commit{Height: block.Height})
blockStore.SaveBlock(block, partSet, &types.ExtendedCommit{Height: block.Height})
currState := state.State{
Version: tmstate.Version{
@@ -160,7 +160,7 @@ func TestRollbackHard(t *testing.T) {
nextPartSet, err := nextBlock.MakePartSet(types.BlockPartSizeBytes)
require.NoError(t, err)
blockStore.SaveBlock(nextBlock, nextPartSet, &types.Commit{Height: nextBlock.Height})
blockStore.SaveBlock(nextBlock, nextPartSet, &types.ExtendedCommit{Height: nextBlock.Height})
rollbackHeight, rollbackHash, err := state.Rollback(blockStore, stateStore, true)
require.NoError(t, err)
@@ -173,7 +173,7 @@ func TestRollbackHard(t *testing.T) {
require.Equal(t, currState, loadedState)
// resave the same block
blockStore.SaveBlock(nextBlock, nextPartSet, &types.Commit{Height: nextBlock.Height})
blockStore.SaveBlock(nextBlock, nextPartSet, &types.ExtendedCommit{Height: nextBlock.Height})
params.Version.App = 11

View File

@@ -233,11 +233,11 @@ func (bs *BlockStore) LoadBlockCommit(height int64) *types.Commit {
}
err = proto.Unmarshal(bz, pbc)
if err != nil {
panic(fmt.Errorf("converting commit to proto: %w", err))
panic(fmt.Sprintf("error reading block commit: %v", err))
}
commit, err := types.CommitFromProto(pbc)
if err != nil {
panic(fmt.Sprintf("Error reading block commit: %v", err))
panic(fmt.Errorf("converting commit to proto: %w", err))
}
return commit
}

View File

@@ -14,7 +14,6 @@ import (
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/internal/test"
"github.com/tendermint/tendermint/libs/log"
@@ -377,7 +376,7 @@ func TestLoadBaseMeta(t *testing.T) {
}
func TestLoadBlockPart(t *testing.T) {
cfg := config.ResetTestRoot("blockchain_reactor_test")
config := test.ResetTestRoot("blockchain_reactor_test")
bs, db := newInMemoryBlockStore()
const height, index = 10, 1
@@ -386,7 +385,7 @@ func TestLoadBlockPart(t *testing.T) {
return part, nil
}
state, err := sm.MakeGenesisStateFromFile(cfg.GenesisFile())
state, err := sm.MakeGenesisStateFromFile(config.GenesisFile())
require.NoError(t, err)
// Initially no contents.