-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package antetest | ||
|
||
import ( | ||
"testing" | ||
|
||
feeburnante "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/x/feeburn/ante" | ||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | ||
"github.com/cosmos/cosmos-sdk/testutil/testdata" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/bank/testutil" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
func TestIntegrationTestSuite(t *testing.T) { | ||
suite.Run(t, new(IntegrationTestSuite)) | ||
} | ||
|
||
func (s *IntegrationTestSuite) TestFeeBurnAnteHandler() { | ||
// setup test | ||
s.SetupTest() | ||
s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() | ||
|
||
// keys and addresses | ||
priv1, _, addr1 := testdata.KeyTestPubAddr() | ||
|
||
// msg and signatures | ||
msg := testdata.NewTestMsg(addr1) | ||
feeAmount := testdata.NewTestFeeAmount() | ||
gasLimit := testdata.NewTestGasLimit() | ||
s.Require().NoError(s.txBuilder.SetMsgs(msg)) | ||
s.txBuilder.SetFeeAmount(feeAmount) | ||
s.txBuilder.SetGasLimit(gasLimit) | ||
|
||
privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} | ||
tx, err := s.CreateTestTx(privs, accNums, accSeqs, s.ctx.ChainID()) | ||
s.Require().NoError(err) | ||
|
||
mfd := feeburnante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, nil, s.app.FeeburnKeeper) | ||
antehandler := sdk.ChainAnteDecorators(mfd) | ||
err = testutil.FundAccount(s.app.BankKeeper, s.ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200)))) | ||
s.Require().NoError(err) | ||
_, err = antehandler(s.ctx, tx, false) | ||
s.Require().Error(err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package types | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDefaultParams(t *testing.T) { | ||
p := DefaultParams() | ||
require.EqualValues(t, p.TxFeeBurnPercent, "0") | ||
} | ||
|
||
func TestValidateParams(t *testing.T) { | ||
tests := map[string]struct { | ||
percent interface{} | ||
expectErr bool | ||
}{ | ||
"DafaultParams, pass": { | ||
DefaultParams().TxFeeBurnPercent, | ||
false, | ||
}, | ||
"lower boundary testing, pass": { | ||
"0", | ||
false, | ||
}, | ||
"upper boundary testing, pass": { | ||
"100", | ||
false, | ||
}, | ||
"greater 100%, fail": { | ||
"101", | ||
true, | ||
}, | ||
} | ||
|
||
for name, test := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
err := validateTxFeeBurnPercent(test.percent) | ||
if test.expectErr { | ||
require.Error(t, err) | ||
return | ||
} | ||
require.NoError(t, err) | ||
}) | ||
} | ||
|
||
} |