Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(baseapp): fulfil all header.Info fields in test helpers context #23014

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions baseapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package baseapp

import (
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cmttypes "github.com/cometbft/cometbft/types"

coreheader "cosmossdk.io/core/header"
errorsmod "cosmossdk.io/errors"
Expand Down Expand Up @@ -64,11 +65,15 @@ func (app *BaseApp) NewContext(isCheckTx bool) sdk.Context {
}

func (app *BaseApp) NewUncachedContext(isCheckTx bool, header cmtproto.Header) sdk.Context {
cmtHeader, _ := cmttypes.HeaderFromProto(&header)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine to discard error here. If you pass a bad header that's your own fault imo.

Calling cmtHeader.Hash() on nil will produce nil - https://github.com/cometbft/cometbft/blob/main/types/block.go#L447-L449

julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
return sdk.NewContext(app.cms, isCheckTx, app.logger).
WithBlockHeader(header).
WithHeaderInfo(coreheader.Info{
Height: header.Height,
Time: header.Time,
AppHash: cmtHeader.AppHash,
Hash: cmtHeader.Hash(),
ChainID: cmtHeader.ChainID,
Height: cmtHeader.Height,
Time: cmtHeader.Time,
})
}

Expand Down
Loading