diff --git a/ante/evm/fee_market_test.go b/ante/evm/fee_market_test.go index d577810a..eeff5bcc 100644 --- a/ante/evm/fee_market_test.go +++ b/ante/evm/fee_market_test.go @@ -137,6 +137,7 @@ func (suite *AnteTestSuite) TestGasWantedDecorator() { expectedGasWanted += tc.expectedGasWanted suite.Require().Equal(expectedGasWanted, gasWanted) } else { + // TODO: check for specific error message suite.Require().Error(err) } }) diff --git a/ante/evm/utils_test.go b/ante/evm/utils_test.go index 63e478b5..800df225 100644 --- a/ante/evm/utils_test.go +++ b/ante/evm/utils_test.go @@ -143,7 +143,7 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator2(from sdk.AccAddr privEd.PubKey(), sdk.NewCoin(suite.GetNetwork().GetDenom(), sdkmath.NewInt(20)), // Ensure optional fields can be left blank - stakingtypes.NewDescription("moniker", "indentity", "", "", ""), + stakingtypes.NewDescription("moniker", "identity", "", "", ""), stakingtypes.NewCommissionRates(sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec()), sdkmath.OneInt(), ) diff --git a/example_chain/ante/evm_benchmark_test.go b/example_chain/ante/evm_benchmark_test.go index c4e4a20e..43a52cf8 100644 --- a/example_chain/ante/evm_benchmark_test.go +++ b/example_chain/ante/evm_benchmark_test.go @@ -7,6 +7,7 @@ import ( "math/big" "testing" + "cosmossdk.io/errors" "cosmossdk.io/math" sdktypes "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -58,11 +59,12 @@ var table = []struct { } func BenchmarkAnteHandler(b *testing.B) { + keyring := testkeyring.New(2) + for _, v := range table { // Reset chain on every tx type to have a clean state // and a fair benchmark b.StopTimer() - keyring := testkeyring.New(2) unitNetwork := network.NewUnitTestNetwork( network.WithPreFundedAccounts(keyring.GetAllAccAddrs()...), ) @@ -85,24 +87,21 @@ func BenchmarkAnteHandler(b *testing.B) { b.StopTimer() // Start with a clean block if err := unitNetwork.NextBlock(); err != nil { - fmt.Println(err) - break + b.Fatal(errors.Wrap(err, "failed to create block")) } ctx := unitNetwork.GetContext() // Generate fresh tx type tx, err := suite.generateTxType(v.txType) if err != nil { - fmt.Println(err) - break + b.Fatal(errors.Wrap(err, "failed to generate tx type")) } b.StartTimer() // Run benchmark _, err = ante(ctx, tx, v.simulate) if err != nil { - fmt.Println(err) - break + b.Fatal(errors.Wrap(err, "failed to run ante handler")) } } }) diff --git a/example_chain/ante/integration_test.go b/example_chain/ante/integration_test.go index 4533f90b..5575b81d 100644 --- a/example_chain/ante/integration_test.go +++ b/example_chain/ante/integration_test.go @@ -13,6 +13,7 @@ import ( "github.com/evmos/os/testutil/integration/os/network" integrationutils "github.com/evmos/os/testutil/integration/os/utils" testutiltx "github.com/evmos/os/testutil/tx" + //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/ginkgo/v2" //nolint:revive // dot imports are fine for Ginkgo @@ -86,6 +87,7 @@ var _ = Describe("when sending a Cosmos transaction", Label("AnteHandler"), Orde baseFeeRes, err := s.grpcHandler.GetBaseFee() Expect(err).To(BeNil()) + Expect(baseFeeRes).ToNot(BeNil(), "baseFeeRes is nil") res, err := s.factory.ExecuteCosmosTx( priv, @@ -102,6 +104,8 @@ var _ = Describe("when sending a Cosmos transaction", Label("AnteHandler"), Orde Expect(err).To(BeNil()) // fees should be deducted from balance + Expect(baseFeeRes.BaseFee).ToNot(BeNil(), "baseFeeRes.BaseFee is nil") + feesAmt := sdkmath.NewInt(res.GasWanted).Mul(*baseFeeRes.BaseFee) balanceRes, err := s.grpcHandler.GetBalance(addr, s.network.GetDenom()) Expect(err).To(BeNil()) diff --git a/precompiles/bank/integration_test.go b/precompiles/bank/integration_test.go index a15191b2..75810db3 100644 --- a/precompiles/bank/integration_test.go +++ b/precompiles/bank/integration_test.go @@ -11,7 +11,7 @@ import ( "github.com/evmos/os/precompiles/bank" "github.com/evmos/os/precompiles/bank/testdata" "github.com/evmos/os/precompiles/testutil" - evmostestutil "github.com/evmos/os/testutil/constants" + testconstants "github.com/evmos/os/testutil/constants" "github.com/evmos/os/testutil/integration/os/factory" "github.com/evmos/os/testutil/integration/os/grpc" "github.com/evmos/os/testutil/integration/os/keyring" @@ -187,7 +187,7 @@ var _ = Describe("Bank Extension -", func() { err = is.precompile.UnpackIntoInterface(&balances, bank.BalancesMethod, ethRes.Ret) Expect(err).ToNot(HaveOccurred(), "failed to unpack balances") - balanceAfter, err := is.grpcHandler.GetBalance(receiver.Bytes(), evmostestutil.ExampleAttoDenom) + balanceAfter, err := is.grpcHandler.GetBalance(receiver.Bytes(), testconstants.ExampleAttoDenom) Expect(err).ToNot(HaveOccurred(), "failed to get balance") Expect(math.NewInt(balances[0].Amount.Int64())).To(Equal(balanceAfter.Balance.Amount)) @@ -330,7 +330,7 @@ var _ = Describe("Bank Extension -", func() { err = is.precompile.UnpackIntoInterface(&balances, bank.BalancesMethod, ethRes.Ret) Expect(err).ToNot(HaveOccurred(), "failed to unpack balances") - balanceAfter, err := is.grpcHandler.GetBalance(receiver.Bytes(), evmostestutil.ExampleAttoDenom) + balanceAfter, err := is.grpcHandler.GetBalance(receiver.Bytes(), testconstants.ExampleAttoDenom) Expect(err).ToNot(HaveOccurred(), "failed to get balance") Expect(math.NewInt(balances[0].Amount.Int64())).To(Equal(balanceAfter.Balance.Amount)) diff --git a/precompiles/distribution/integration_test.go b/precompiles/distribution/integration_test.go index 69516b34..43decdb2 100644 --- a/precompiles/distribution/integration_test.go +++ b/precompiles/distribution/integration_test.go @@ -16,7 +16,7 @@ import ( "github.com/evmos/os/precompiles/staking" "github.com/evmos/os/precompiles/testutil" "github.com/evmos/os/precompiles/testutil/contracts" - evmostestutil "github.com/evmos/os/testutil/constants" + testconstants "github.com/evmos/os/testutil/constants" "github.com/evmos/os/testutil/integration/os/factory" testutils "github.com/evmos/os/testutil/integration/os/utils" testutiltx "github.com/evmos/os/testutil/tx" @@ -50,7 +50,7 @@ var ( txArgs evmtypes.EvmTxArgs // minExpRewardOrCommission is the minimun coins expected for validator's rewards or commission // required for the tests - minExpRewardOrCommission = sdk.NewDecCoins(sdk.NewDecCoin(evmostestutil.ExampleAttoDenom, testRewardsAmt)) + minExpRewardOrCommission = sdk.NewDecCoins(sdk.NewDecCoin(testconstants.ExampleAttoDenom, testRewardsAmt)) ) func TestPrecompileIntegrationTestSuite(t *testing.T) { diff --git a/precompiles/distribution/tx_test.go b/precompiles/distribution/tx_test.go index 5a7d5c4d..267ca903 100644 --- a/precompiles/distribution/tx_test.go +++ b/precompiles/distribution/tx_test.go @@ -4,7 +4,7 @@ import ( "fmt" "math/big" - evmostestutil "github.com/evmos/os/testutil/constants" + testconstants "github.com/evmos/os/testutil/constants" "cosmossdk.io/math" "github.com/evmos/os/precompiles/testutil" @@ -198,10 +198,10 @@ func (s *PrecompileTestSuite) TestWithdrawDelegatorRewards() { var coins []cmn.Coin err := s.precompile.UnpackIntoInterface(&coins, distribution.WithdrawDelegatorRewardsMethod, data) s.Require().NoError(err, "failed to unpack output") - s.Require().Equal(coins[0].Denom, evmostestutil.ExampleAttoDenom) + s.Require().Equal(coins[0].Denom, testconstants.ExampleAttoDenom) s.Require().Equal(coins[0].Amount.Int64(), expRewardsAmt.Int64()) // Check bank balance after the withdrawal of rewards - balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), evmostestutil.ExampleAttoDenom) + balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconstants.ExampleAttoDenom) s.Require().True(balance.Amount.GT(network.PrefundedAccountInitialBalance)) }, 20000, @@ -274,14 +274,14 @@ func (s *PrecompileTestSuite) TestWithdrawValidatorCommission() { valAddr, err := sdk.ValAddressFromBech32(operatorAddress) s.Require().NoError(err) amt := math.LegacyNewDecWithPrec(1000000000000000000, 1) - valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(evmostestutil.ExampleAttoDenom, amt)} + valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(testconstants.ExampleAttoDenom, amt)} // set outstanding rewards s.Require().NoError(s.network.App.DistrKeeper.SetValidatorOutstandingRewards(ctx, valAddr, types.ValidatorOutstandingRewards{Rewards: valCommission})) // set commission s.Require().NoError(s.network.App.DistrKeeper.SetValidatorAccumulatedCommission(ctx, valAddr, types.ValidatorAccumulatedCommission{Commission: valCommission})) // fund distr mod to pay for rewards + commission - coins := sdk.NewCoins(sdk.NewCoin(evmostestutil.ExampleAttoDenom, amt.Mul(math.LegacyNewDec(2)).RoundInt())) + coins := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, amt.Mul(math.LegacyNewDec(2)).RoundInt())) err = s.mintCoinsForDistrMod(ctx, coins) s.Require().NoError(err) return []interface{}{ @@ -293,15 +293,15 @@ func (s *PrecompileTestSuite) TestWithdrawValidatorCommission() { amt := math.NewInt(100000000000000000) err := s.precompile.UnpackIntoInterface(&coins, distribution.WithdrawValidatorCommissionMethod, data) s.Require().NoError(err, "failed to unpack output") - s.Require().Equal(coins[0].Denom, evmostestutil.ExampleAttoDenom) + s.Require().Equal(coins[0].Denom, testconstants.ExampleAttoDenom) s.Require().Equal(coins[0].Amount, amt.BigInt()) // Check bank balance after the withdrawal of commission valAddr, err := sdk.ValAddressFromBech32(s.network.GetValidators()[0].GetOperator()) s.Require().NoError(err) - balance := s.network.App.BankKeeper.GetBalance(ctx, valAddr.Bytes(), evmostestutil.ExampleAttoDenom) + balance := s.network.App.BankKeeper.GetBalance(ctx, valAddr.Bytes(), testconstants.ExampleAttoDenom) s.Require().Equal(balance.Amount, prevBalance.Amount.Add(amt)) - s.Require().Equal(balance.Denom, evmostestutil.ExampleAttoDenom) + s.Require().Equal(balance.Denom, testconstants.ExampleAttoDenom) }, 20000, false, @@ -317,7 +317,7 @@ func (s *PrecompileTestSuite) TestWithdrawValidatorCommission() { valAddr, err := sdk.ValAddressFromBech32(s.network.GetValidators()[0].GetOperator()) s.Require().NoError(err) - prevBalance = s.network.App.BankKeeper.GetBalance(ctx, valAddr.Bytes(), evmostestutil.ExampleAttoDenom) + prevBalance = s.network.App.BankKeeper.GetBalance(ctx, valAddr.Bytes(), testconstants.ExampleAttoDenom) validatorAddress := common.BytesToAddress(valAddr.Bytes()) var contract *vm.Contract @@ -408,7 +408,7 @@ func (s *PrecompileTestSuite) TestClaimRewards() { } }, func(_ []byte) { - balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAccAddr(0), evmostestutil.ExampleAttoDenom) + balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAccAddr(0), testconstants.ExampleAttoDenom) // rewards from 3 validators - 5% commission expRewards := expRewardsAmt.Mul(math.NewInt(3)) s.Require().Equal(balance.Amount, prevBalance.Amount.Add(expRewards)) @@ -426,7 +426,7 @@ func (s *PrecompileTestSuite) TestClaimRewards() { } }, func([]byte) { - balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAccAddr(0), evmostestutil.ExampleAttoDenom) + balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAccAddr(0), testconstants.ExampleAttoDenom) // rewards from 3 validators - 5% commission expRewards := expRewardsAmt.Mul(math.NewInt(3)) s.Require().Equal(balance.Amount, prevBalance.Amount.Add(expRewards)) @@ -444,7 +444,7 @@ func (s *PrecompileTestSuite) TestClaimRewards() { } }, func([]byte) { - balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAccAddr(0), evmostestutil.ExampleAttoDenom) + balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAccAddr(0), testconstants.ExampleAttoDenom) s.Require().Equal(balance.Amount, prevBalance.Amount.Add(expRewardsAmt)) }, 20000, @@ -479,7 +479,7 @@ func (s *PrecompileTestSuite) TestClaimRewards() { s.Require().NoError(err) // get previous balance to compare final balance in the postCheck func - prevBalance = s.network.App.BankKeeper.GetBalance(ctx, addr.Bytes(), evmostestutil.ExampleAttoDenom) + prevBalance = s.network.App.BankKeeper.GetBalance(ctx, addr.Bytes(), testconstants.ExampleAttoDenom) bz, err := s.precompile.ClaimRewards(ctx, addr, contract, s.network.GetStateDB(), &method, tc.malleate()) @@ -541,8 +541,8 @@ func (s *PrecompileTestSuite) TestFundCommunityPool() { s.Require().NoError(err) coins := pool.CommunityPool expectedAmount := new(big.Int).Mul(big.NewInt(1e18), new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(math.LegacyPrecision)), nil)) - s.Require().Equal(expectedAmount, coins.AmountOf(evmostestutil.ExampleAttoDenom).BigInt()) - userBalance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), evmostestutil.ExampleAttoDenom) + s.Require().Equal(expectedAmount, coins.AmountOf(testconstants.ExampleAttoDenom).BigInt()) + userBalance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconstants.ExampleAttoDenom) s.Require().Equal(network.PrefundedAccountInitialBalance.Sub(math.NewInt(1e18)), userBalance.Amount) }, 20000, @@ -560,7 +560,7 @@ func (s *PrecompileTestSuite) TestFundCommunityPool() { contract, ctx = testutil.NewPrecompileContract(s.T(), ctx, s.keyring.GetAddr(0), s.precompile, tc.gas) // Sanity check to make sure the starting balance is always 100k EVMOS - balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), evmostestutil.ExampleAttoDenom) + balance := s.network.App.BankKeeper.GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconstants.ExampleAttoDenom) s.Require().Equal(balance.Amount, network.PrefundedAccountInitialBalance) bz, err := s.precompile.FundCommunityPool(ctx, s.keyring.GetAddr(0), contract, s.network.GetStateDB(), &method, tc.malleate()) diff --git a/rpc/backend/node_info_test.go b/rpc/backend/node_info_test.go index c4bcb6b2..b0b5182c 100644 --- a/rpc/backend/node_info_test.go +++ b/rpc/backend/node_info_test.go @@ -281,7 +281,7 @@ func (suite *BackendTestSuite) TestSetEtherbase() { // queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) // RegisterStatus(client) // RegisterValidatorAccount(queryClient, suite.acc) - // c := sdk.NewDecCoin(testutil.ExampleAttoDenom, math.NewIntFromBigInt(big.NewInt(1))) + // c := sdk.NewDecCoin(testconstants.ExampleAttoDenom, math.NewIntFromBigInt(big.NewInt(1))) // suite.backend.cfg.SetMinGasPrices(sdk.DecCoins{c}) // delAddr, _ := suite.backend.GetCoinbase() // account, _ := suite.backend.clientCtx.AccountRetriever.GetAccount(suite.backend.clientCtx, delAddr) diff --git a/testutil/integration/os/utils/bank.go b/testutil/integration/os/utils/bank.go index bc8014e5..36cc2c3c 100644 --- a/testutil/integration/os/utils/bank.go +++ b/testutil/integration/os/utils/bank.go @@ -32,7 +32,7 @@ func CheckBalances(ctx context.Context, client banktypes.QueryClient, balances [ return err } - if !balance.Balance.IsEqual(coin) { + if !balance.Balance.Equal(coin) { return fmt.Errorf( "expected balance %s, got %s for address %s", coin, balance.Balance, addr, diff --git a/testutil/network/network.go b/testutil/network/network.go index 2fa855c1..a376c5ec 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -20,7 +20,7 @@ import ( "testing" "time" - evmostestutil "github.com/evmos/os/testutil/constants" + testconstants "github.com/evmos/os/testutil/constants" "cosmossdk.io/log" "cosmossdk.io/math" @@ -121,7 +121,7 @@ func DefaultConfig() Config { ChainID: chainID, NumValidators: 4, BondDenom: "aevmos", - MinGasPrices: fmt.Sprintf("0.000006%s", evmostestutil.ExampleAttoDenom), + MinGasPrices: fmt.Sprintf("0.000006%s", testconstants.ExampleAttoDenom), AccountTokens: sdk.TokensFromConsensusPower(1000000000000000000, evmostypes.AttoPowerReduction), StakingTokens: sdk.TokensFromConsensusPower(500000000000000000, evmostypes.AttoPowerReduction), BondedTokens: sdk.TokensFromConsensusPower(100000000000000000, evmostypes.AttoPowerReduction), @@ -476,7 +476,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { return nil, err } - customAppTemplate, _ := chaincmd.InitAppConfig(evmostestutil.ExampleAttoDenom) + customAppTemplate, _ := chaincmd.InitAppConfig(testconstants.ExampleAttoDenom) srvconfig.SetConfigTemplate(customAppTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appCfg) diff --git a/testutil/tx/eth.go b/testutil/tx/eth.go index ca42094b..40e39803 100644 --- a/testutil/tx/eth.go +++ b/testutil/tx/eth.go @@ -8,7 +8,7 @@ import ( "encoding/json" "math/big" - evmostestutil "github.com/evmos/os/testutil/constants" + testconstants "github.com/evmos/os/testutil/constants" errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" @@ -57,7 +57,7 @@ func PrepareEthTx( msg.From = "" txGasLimit += msg.GetGas() - txFee = txFee.Add(sdk.Coin{Denom: evmostestutil.ExampleAttoDenom, Amount: sdkmath.NewIntFromBigInt(msg.GetFee())}) + txFee = txFee.Add(sdk.Coin{Denom: testconstants.ExampleAttoDenom, Amount: sdkmath.NewIntFromBigInt(msg.GetFee())}) } if err := txBuilder.SetMsgs(msgs...); err != nil {