Skip to content

Commit

Permalink
style: Use const gas in test
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 committed Sep 12, 2024
1 parent 72d9e88 commit 6480f76
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions app/ante/eip712_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
ChainID = app.TestChainId
USDCCoinDenom = "erc20/usdc"
USDCCDPType = "erc20-usdc"
TxGas = uint64(sims.DefaultGenTxGas * 10)
)

type EIP712TestSuite struct {
Expand Down Expand Up @@ -75,7 +76,6 @@ func (suite *EIP712TestSuite) createTestEIP712CosmosTxBuilderWithDomain(
from sdk.AccAddress,
priv cryptotypes.PrivKey,
chainID string,
gas uint64,
gasAmount sdk.Coins,
msgs []sdk.Msg,
customDomain *apitypes.TypedDataDomain,
Expand All @@ -90,7 +90,7 @@ func (suite *EIP712TestSuite) createTestEIP712CosmosTxBuilderWithDomain(
ethChainID := pc.Uint64()

// GenerateTypedData TypedData
fee := legacytx.NewStdFee(gas, gasAmount)
fee := legacytx.NewStdFee(TxGas, gasAmount)

Check failure on line 93 in app/ante/eip712_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)
accNumber := suite.tApp.GetAccountKeeper().GetAccount(suite.ctx, from).GetAccountNumber()

data := eip712.ConstructUntypedEIP712Data(chainID, accNumber, nonce, 0, fee, msgs, "", nil)
Expand Down Expand Up @@ -141,7 +141,7 @@ func (suite *EIP712TestSuite) createTestEIP712CosmosTxBuilderWithDomain(

builder.SetExtensionOptions(option)
builder.SetFeeAmount(gasAmount)
builder.SetGasLimit(gas)
builder.SetGasLimit(TxGas)

sigsV2 := signing.SignatureV2{
PubKey: pubKey,
Expand All @@ -164,15 +164,13 @@ func (suite *EIP712TestSuite) createTestEIP712CosmosTxBuilder(
from sdk.AccAddress,
priv cryptotypes.PrivKey,
chainID string,
gas uint64,
gasAmount sdk.Coins,
msgs []sdk.Msg,
) client.TxBuilder {
return suite.createTestEIP712CosmosTxBuilderWithDomain(
from,
priv,
chainID,
gas,
gasAmount,
msgs,
nil,
Expand Down Expand Up @@ -634,7 +632,6 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
suite.testAddr,
suite.testPrivKey,
"kavatest_12-1",
uint64(sims.DefaultGenTxGas*10),
gasAmt,
msgs,
)
Expand All @@ -652,7 +649,6 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
suite.testAddr2,
suite.testPrivKey2,
ChainID,
uint64(sims.DefaultGenTxGas*10),
gasAmt,
msgs,
)
Expand Down Expand Up @@ -707,7 +703,6 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
suite.testAddr,
suite.testPrivKey,
ChainID,
uint64(sims.DefaultGenTxGas*10),
gasAmt,
msgs,
&domain,
Expand Down Expand Up @@ -766,7 +761,6 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
suite.testAddr,
suite.testPrivKey,
ChainID,
uint64(sims.DefaultGenTxGas*10),
gasAmt,
msgs,
&domain,
Expand Down Expand Up @@ -821,7 +815,6 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
suite.testAddr,
suite.testPrivKey,
ChainID,
uint64(sims.DefaultGenTxGas*10),
gasAmt,
msgs,
&domain,
Expand Down Expand Up @@ -865,7 +858,11 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {

gasAmt := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(20)))
txBuilder := suite.createTestEIP712CosmosTxBuilder(
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
suite.testAddr,
suite.testPrivKey,
ChainID,
gasAmt,
msgs,
)
if tc.updateTx != nil {
txBuilder = tc.updateTx(txBuilder, msgs)
Expand Down Expand Up @@ -951,7 +948,11 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
// deliver deposit msg
gasAmt := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(20)))
txBuilder := suite.createTestEIP712CosmosTxBuilder(
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, depositMsgs,
suite.testAddr,
suite.testPrivKey,
ChainID,
gasAmt,
depositMsgs,
)
txBytes, err := encodingConfig.TxConfig.TxEncoder()(txBuilder.GetTx())
suite.Require().NoError(err)
Expand Down Expand Up @@ -996,7 +997,11 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {

// deliver withdraw msg
txBuilder = suite.createTestEIP712CosmosTxBuilder(
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, withdrawMsgs,
suite.testAddr,
suite.testPrivKey,
ChainID,
gasAmt,
withdrawMsgs,
)
txBytes, err = encodingConfig.TxConfig.TxEncoder()(txBuilder.GetTx())
suite.Require().NoError(err)
Expand Down

0 comments on commit 6480f76

Please sign in to comment.