Skip to content

Commit

Permalink
remove unnecessary condition and improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed May 10, 2023
1 parent 398fe54 commit ec83ca2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 2 additions & 3 deletions x/globalfee/ante/antetest/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
Expand Down Expand Up @@ -764,8 +763,8 @@ func (s *IntegrationTestSuite) TestGetTxFeeRequired() {
// setup tests with default global fee i.e. "0uatom" and empty local min gas prices
feeDecorator, _ := s.SetupTestGlobalFeeStoreAndMinGasPrice([]sdk.DecCoin{}, globalfeeParamsEmpty)

// reset decorator staking subspace
feeDecorator.StakingSubspace = paramtypes.Subspace{}
// set a subspace that doesn't have the stakingtypes.KeyBondDenom key registred
feeDecorator.StakingSubspace = s.app.GetSubspace(globfeetypes.ModuleName)

// check that an error is returned when staking subspace isn't set
_, err := feeDecorator.GetTxFeeRequired(s.ctx, nil)
Expand Down
7 changes: 1 addition & 6 deletions x/globalfee/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,8 @@ func (mfd FeeDecorator) DefaultZeroGlobalFee(ctx sdk.Context) ([]sdk.DecCoin, er
}

func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) string {
// prevent the getter above to panic
// when the staking subspace isn't set
if !mfd.StakingSubspace.HasKeyTable() {
return ""
}

var bondDenom string

if mfd.StakingSubspace.Has(ctx, stakingtypes.KeyBondDenom) {
mfd.StakingSubspace.Get(ctx, stakingtypes.KeyBondDenom, &bondDenom)
}
Expand Down

0 comments on commit ec83ca2

Please sign in to comment.