Skip to content

Commit

Permalink
fix: tests and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Lockwarr committed Jan 13, 2025
1 parent e4e5a23 commit a348be0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions x/tax/keeper/custom_tx_fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func (k Keeper) CustomTxFeeChecker(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64

// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
gasLimitDec := sdkmath.LegacyNewDec(int64(gas))
minimumFeeRequiredInPaidDenom := gasLimitDec.Mul(minGasPrice)
minimumFeeRequiredInPaidDenom := gasLimitDec.Mul(minGasPrice).RoundInt()
// if the fee provided is greater than the minimum fee required in the paid denom, then it is accepted
if fee.Amount.GT(minimumFeeRequiredInPaidDenom.Ceil().RoundInt()) {
if fee.Amount.GT(minimumFeeRequiredInPaidDenom) {
priority := getTxPriority(feeCoins, int64(gas))
return feeCoins, priority, nil
} else {
return nil, 0, errors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %f%s required: %f%s", fee.Amount.ToLegacyDec().RoundInt(), fee.Denom, minimumFeeRequiredInPaidDenom, fee.Denom)
return nil, 0, errors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %d%s required: %d%s", fee.Amount.ToLegacyDec().RoundInt().Int64(), fee.Denom, minimumFeeRequiredInPaidDenom.Int64(), fee.Denom)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions x/tax/keeper/custom_tx_fee_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestCustomTxFeeCheckerFailDueToHighGasPayingWithUSDC(t *testing.T) {

_, _, err := taxKeeper.CustomTxFeeChecker(ctx, feeTx)
require.Error(t, err)
require.Equal(t, "insufficient fees; got: 1.000000ibc/5DE4FCAF68AE40F81F738C857C0D95F7C1BC47B00FA1026E85C1DD92524D4A11 required: 100029998.779297ibc/5DE4FCAF68AE40F81F738C857C0D95F7C1BC47B00FA1026E85C1DD92524D4A11: insufficient fee", err.Error())
require.Equal(t, "insufficient fees; got: 1ibc/5DE4FCAF68AE40F81F738C857C0D95F7C1BC47B00FA1026E85C1DD92524D4A11 required: 100030000ibc/5DE4FCAF68AE40F81F738C857C0D95F7C1BC47B00FA1026E85C1DD92524D4A11: insufficient fee", err.Error())
}

// Fail to pay fees in ibc/C4C... which represents OSMO. Minimum gas prices set to unls. High gas -> fee amount not enough.
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestCustomTxFeeCheckerFailDueToHighGasPayingWithOSMO(t *testing.T) {

_, _, err := taxKeeper.CustomTxFeeChecker(ctx, feeTx)
require.Error(t, err)
require.Equal(t, "insufficient fees; got: 1.000000ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9y required: 100025001.525879ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9y: insufficient fee", err.Error())
require.Equal(t, "insufficient fees; got: 1ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9y required: 100025000ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9y: insufficient fee", err.Error())
}

// Successfully pay fees in unls which represents NLS. Minimum gas prices set to unls.
Expand Down

0 comments on commit a348be0

Please sign in to comment.