From c9d1ec188c7186447bbddb3bdf8d88ce25f7282e Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 18 Sep 2024 20:12:20 +0200 Subject: [PATCH] test: fix tests --- internal/state/rollback_test.go | 22 ++++++++++++++-------- internal/state/store.go | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/internal/state/rollback_test.go b/internal/state/rollback_test.go index 51b658fbb..6fca9fe14 100644 --- a/internal/state/rollback_test.go +++ b/internal/state/rollback_test.go @@ -44,24 +44,30 @@ func TestRollback(t *testing.T) { block := &types.BlockMeta{ BlockID: initialState.LastBlockID, Header: types.Header{ - Height: initialState.LastBlockHeight, - AppHash: factory.RandomHash(), - LastBlockID: factory.MakeBlockID(), - ResultsHash: initialState.LastResultsHash, + Height: initialState.LastBlockHeight, + AppHash: factory.RandomHash(), + LastBlockID: factory.MakeBlockID(), + ResultsHash: initialState.LastResultsHash, + ProposerProTxHash: initialState.Validators.Validators[0].ProTxHash, + ValidatorsHash: initialState.Validators.Hash(), + NextValidatorsHash: nextState.Validators.Hash(), }, } nextBlock := &types.BlockMeta{ BlockID: initialState.LastBlockID, Header: types.Header{ - Height: nextState.LastBlockHeight, - AppHash: initialState.LastAppHash, - LastBlockID: block.BlockID, - ResultsHash: nextState.LastResultsHash, + Height: nextState.LastBlockHeight, + AppHash: initialState.LastAppHash, + LastBlockID: block.BlockID, + ResultsHash: nextState.LastResultsHash, + ProposerProTxHash: nextState.Validators.Validators[1].ProTxHash, + ValidatorsHash: nextState.Validators.Hash(), }, } blockStore.On("LoadBlockMeta", height).Return(block) blockStore.On("LoadBlockMeta", nextHeight).Return(nextBlock) blockStore.On("Height").Return(nextHeight) + blockStore.On("Base").Return(height) // rollback the state rollbackHeight, rollbackHash, err := state.Rollback(blockStore, stateStore) diff --git a/internal/state/store.go b/internal/state/store.go index 5024297be..1bd53067b 100644 --- a/internal/state/store.go +++ b/internal/state/store.go @@ -533,7 +533,7 @@ func (store dbStore) LoadValidators(height int64, bs selectproposer.BlockStore) if height == 1 { proposer := valSet.GetByIndex(0) if err := valSet.SetProposer(proposer.ProTxHash); err != nil { - return nil, fmt.Errorf("could not set proposer: %w", err) + return nil, fmt.Errorf("could not set first proposer: %w", err) } return valSet, nil }