Skip to content

Commit

Permalink
test: Add additional fee test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 committed Sep 18, 2024
1 parent 0226fba commit e19b808
Showing 1 changed file with 60 additions and 4 deletions.
64 changes: 60 additions & 4 deletions app/ante/fee_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestDeductFees(t *testing.T) {
sdk.NewDecCoins(sdk.NewDecCoinFromDec("ukava", sdk.MustNewDecFromStr("0.001"))),
legacytx.NewStdFee(

Check failure on line 126 in app/ante/fee_checker_test.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

SA1019: legacytx.NewStdFee is deprecated: NewStdFee returns a new instance of StdFee (staticcheck)
100000,
sdk.NewCoins(sdk.NewInt64Coin("ukava", 1000)),
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100)),
),
"insufficient funds: insufficient funds",
},
Expand All @@ -144,12 +144,12 @@ func TestDeductFees(t *testing.T) {
sdk.NewDecCoins(sdk.NewDecCoinFromDec("ukava", sdk.MustNewDecFromStr("0.001"))),
legacytx.NewStdFee(

Check failure on line 145 in app/ante/fee_checker_test.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

SA1019: legacytx.NewStdFee is deprecated: NewStdFee returns a new instance of StdFee (staticcheck)
100000,
sdk.NewCoins(sdk.NewInt64Coin("ukava", 1000)),
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100)), // gasPrice * gas
),
"",
},
{
"valid fees, multiple min gas prices",
"valid single fee, multiple min gas prices",
func(s *AnteTestSuite) {
s.bankKeeper.EXPECT().
SendCoinsFromAccountToModule(
Expand All @@ -166,7 +166,63 @@ func TestDeductFees(t *testing.T) {
),
legacytx.NewStdFee(

Check failure on line 167 in app/ante/fee_checker_test.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

SA1019: legacytx.NewStdFee is deprecated: NewStdFee returns a new instance of StdFee (staticcheck)
100000,
sdk.NewCoins(sdk.NewInt64Coin("ukava", 1000)),
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100)),
),
"",
},
{
"insufficient single fee, multiple min gas prices",
func(_ *AnteTestSuite) {},
sdk.NewDecCoins(
sdk.NewDecCoinFromDec("ukava", sdk.MustNewDecFromStr("0.001")),
sdk.NewDecCoinFromDec("usdt", sdk.MustNewDecFromStr("0.003")),
),
legacytx.NewStdFee(
100000,
sdk.NewCoins(sdk.NewInt64Coin("ukava", 99)), // gasPrice * gas - 1
),
"insufficient fees; got: 99ukava required: 100ukava,300usdt: insufficient fee",
},
{
"insufficient multiple fee, multiple min gas prices",
func(_ *AnteTestSuite) {},
sdk.NewDecCoins(
sdk.NewDecCoinFromDec("ukava", sdk.MustNewDecFromStr("0.001")),
sdk.NewDecCoinFromDec("usdt", sdk.MustNewDecFromStr("0.003")),
),
legacytx.NewStdFee(
100000,
sdk.NewCoins(
// Both fee coins are -1 from the required amount
sdk.NewInt64Coin("ukava", 99), // gasPrice * gas - 1
sdk.NewInt64Coin("usdt", 299), // gasPrice * gas - 1
),
),
"insufficient fees; got: 99ukava,299usdt required: 100ukava,300usdt: insufficient fee",
},
{
"valid multiple fee, multiple min gas prices",
func(s *AnteTestSuite) {
s.bankKeeper.EXPECT().
SendCoinsFromAccountToModule(
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).
Return(nil)
},
sdk.NewDecCoins(
sdk.NewDecCoinFromDec("ukava", sdk.MustNewDecFromStr("0.001")),
sdk.NewDecCoinFromDec("usdt", sdk.MustNewDecFromStr("0.003")),
),
legacytx.NewStdFee(
100000,
sdk.NewCoins(
sdk.NewInt64Coin("ukava", 100),
// insufficient usdt is fine if ukava is sufficient
sdk.NewInt64Coin("usdt", 1),
),
),
"",
},
Expand Down

0 comments on commit e19b808

Please sign in to comment.