Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Sep 18, 2024
1 parent f2bd710 commit c9d1ec1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions internal/state/rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/state/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c9d1ec1

Please sign in to comment.