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: nil pointer for gas_prices query #146

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions x/feemarket/keeper/feemarket.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func (k *Keeper) GetMinGasPrices(ctx sdk.Context) (sdk.DecCoins, error) {
minGasPrice := sdk.NewDecCoinFromDec(params.FeeDenom, baseGasPrice)
minGasPrices := sdk.NewDecCoins(minGasPrice)

if k.resolver == nil {

Choose a reason for hiding this comment

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

if this is a required item we should panic at the start of the node if it is not set. ideally here

func NewKeeper(
or we set the default if its nil by the app dev

Copy link
Author

Choose a reason for hiding this comment

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

it does not seem like a required item. The current default TestDenomResolver is not meant for production and there are no other resolvers. Feemarket still functions as expected without it except for this small bug in the query_server

return minGasPrices, nil
}

extraDenoms, err := k.resolver.ExtraDenoms(ctx)
if err != nil {
return sdk.NewDecCoins(), err
Expand Down
15 changes: 15 additions & 0 deletions x/feemarket/keeper/query_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,19 @@ func (s *KeeperTestSuite) TestBaseFeeRequest() {

s.Require().Equal(resp.GetPrice(), fee)
})

s.Run("can get gas prices", func() {
// set denom resolver to nil assuming that it is not set
s.feeMarketKeeper.SetDenomResolver(nil)

req := &types.GasPricesRequest{}
resp, err := s.queryServer.GasPrices(s.ctx, req)
s.Require().NoError(err)
s.Require().NotNil(resp)

gasPrices, err := s.feeMarketKeeper.GetMinGasPrices(s.ctx)
s.Require().NoError(err)

s.Require().Equal(resp.GetPrices(), gasPrices)
})
}
Loading