Skip to content

Commit

Permalink
rename testutil suite
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 committed Feb 8, 2024
1 parent 296a017 commit 0d45d11
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion x/evm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
var testTokens = sdkmath.NewIntWithDecimal(1000, 18)

type KeeperTestSuite struct {
testutil.KeeperTestSuite
testutil.TestSuite
}

var s *KeeperTestSuite
Expand Down
12 changes: 6 additions & 6 deletions x/evm/keeper/state_transition_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func newNativeMessage(

func BenchmarkApplyTransaction(b *testing.B) {
suite := KeeperTestSuite{
KeeperTestSuite: testutil.KeeperTestSuite{
TestSuite: testutil.TestSuite{
EnableLondonHF: true,
},
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func BenchmarkApplyTransaction(b *testing.B) {

func BenchmarkApplyTransactionWithLegacyTx(b *testing.B) {
suite := KeeperTestSuite{
KeeperTestSuite: testutil.KeeperTestSuite{
TestSuite: testutil.TestSuite{
EnableLondonHF: true,
},
}
Expand Down Expand Up @@ -220,7 +220,7 @@ func BenchmarkApplyTransactionWithLegacyTx(b *testing.B) {

func BenchmarkApplyTransactionWithDynamicFeeTx(b *testing.B) {
suite := KeeperTestSuite{
KeeperTestSuite: testutil.KeeperTestSuite{
TestSuite: testutil.TestSuite{
EnableFeemarket: true,
EnableLondonHF: true,
},
Expand Down Expand Up @@ -252,7 +252,7 @@ func BenchmarkApplyTransactionWithDynamicFeeTx(b *testing.B) {

func BenchmarkApplyMessage(b *testing.B) {
suite := KeeperTestSuite{
KeeperTestSuite: testutil.KeeperTestSuite{
TestSuite: testutil.TestSuite{
EnableLondonHF: true,
},
}
Expand Down Expand Up @@ -291,7 +291,7 @@ func BenchmarkApplyMessage(b *testing.B) {

func BenchmarkApplyMessageWithLegacyTx(b *testing.B) {
suite := KeeperTestSuite{
KeeperTestSuite: testutil.KeeperTestSuite{
TestSuite: testutil.TestSuite{
EnableLondonHF: true,
},
}
Expand Down Expand Up @@ -330,7 +330,7 @@ func BenchmarkApplyMessageWithLegacyTx(b *testing.B) {

func BenchmarkApplyMessageWithDynamicFeeTx(b *testing.B) {
suite := KeeperTestSuite{
KeeperTestSuite: testutil.KeeperTestSuite{
TestSuite: testutil.TestSuite{
EnableFeemarket: true,
EnableLondonHF: true,
},
Expand Down
6 changes: 3 additions & 3 deletions x/evm/statedb/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ func BenchmarkGetLogs(b *testing.B) {
}
}

func GetTestSuite(b *testing.B) *testutil.KeeperTestSuite {
func GetTestSuite(b *testing.B) *testutil.TestSuite {
// Just reuse the keeper test suite to setup and create a testing app
suite := testutil.KeeperTestSuite{}
suite := testutil.TestSuite{}
suite.SetupTestWithT(b)

return &suite
}

func GetTestKeeper() *keeper.Keeper {
// Just reuse the keeper test suite to setup and create a keeper
suite := testutil.KeeperTestSuite{}
suite := testutil.TestSuite{}
suite.SetupTest()

return suite.App.EvmKeeper
Expand Down
2 changes: 1 addition & 1 deletion x/evm/statedb/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
)

type StateDBTestSuite struct {
testutil.KeeperTestSuite
testutil.TestSuite
}

func (suite *StateDBTestSuite) TestAccount() {
Expand Down
24 changes: 12 additions & 12 deletions x/evm/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import (

var testTokens = sdkmath.NewIntWithDecimal(1000, 18)

Check failure on line 50 in x/evm/testutil/suite.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

var `testTokens` is unused (unused)

type KeeperTestSuite struct {
type TestSuite struct {
suite.Suite

Ctx sdk.Context
Expand All @@ -71,24 +71,24 @@ type KeeperTestSuite struct {
Denom string
}

func (suite *KeeperTestSuite) SetupTest() {
func (suite *TestSuite) SetupTest() {
checkTx := false
suite.App = app.Setup(checkTx, nil)
suite.SetupApp(checkTx)
}

func (suite *KeeperTestSuite) SetupTestWithT(t require.TestingT) {
func (suite *TestSuite) SetupTestWithT(t require.TestingT) {
checkTx := false
suite.App = app.Setup(checkTx, nil)
suite.SetupAppWithT(checkTx, t)
}

func (suite *KeeperTestSuite) SetupApp(checkTx bool) {
func (suite *TestSuite) SetupApp(checkTx bool) {
suite.SetupAppWithT(checkTx, suite.T())
}

// SetupApp setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) {
func (suite *TestSuite) SetupAppWithT(checkTx bool, t require.TestingT) {
// account key, use a constant account to keep unit test deterministic.
ecdsaPriv, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
require.NoError(t, err)
Expand Down Expand Up @@ -209,14 +209,14 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) {
suite.Denom = evmtypes.DefaultEVMDenom
}

func (suite *KeeperTestSuite) EvmDenom() string {
func (suite *TestSuite) EvmDenom() string {
ctx := sdk.WrapSDKContext(suite.Ctx)
rsp, _ := suite.QueryClient.Params(ctx, &types.QueryParamsRequest{})
return rsp.Params.EvmDenom
}

// Commit and begin new block
func (suite *KeeperTestSuite) Commit() {
func (suite *TestSuite) Commit() {
_ = suite.App.Commit()
header := suite.Ctx.BlockHeader()
header.Height += 1

Check warning on line 222 in x/evm/testutil/suite.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

increment-decrement: should replace header.Height += 1 with header.Height++ (revive)
Expand All @@ -232,7 +232,7 @@ func (suite *KeeperTestSuite) Commit() {
suite.QueryClient = types.NewQueryClient(queryHelper)
}

func (suite *KeeperTestSuite) StateDB() vm.StateDB {
func (suite *TestSuite) StateDB() vm.StateDB {
return statedb.New(
suite.Ctx,
suite.App.EvmKeeper,
Expand All @@ -241,7 +241,7 @@ func (suite *KeeperTestSuite) StateDB() vm.StateDB {
}

// DeployTestContract deploy a test erc20 contract and returns the contract address
func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner common.Address, supply *big.Int) common.Address {
func (suite *TestSuite) DeployTestContract(t require.TestingT, owner common.Address, supply *big.Int) common.Address {
ctx := sdk.WrapSDKContext(suite.Ctx)
chainID := suite.App.EvmKeeper.ChainID()

Expand Down Expand Up @@ -298,7 +298,7 @@ func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner commo
return crypto.CreateAddress(suite.Address, nonce)
}

func (suite *KeeperTestSuite) TransferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx {
func (suite *TestSuite) TransferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx {
ctx := sdk.WrapSDKContext(suite.Ctx)
chainID := suite.App.EvmKeeper.ChainID()

Expand Down Expand Up @@ -353,7 +353,7 @@ func (suite *KeeperTestSuite) TransferERC20Token(t require.TestingT, contractAdd
}

// DeployTestMessageCall deploy a test erc20 contract and returns the contract address
func (suite *KeeperTestSuite) DeployTestMessageCall(t require.TestingT) common.Address {
func (suite *TestSuite) DeployTestMessageCall(t require.TestingT) common.Address {
ctx := sdk.WrapSDKContext(suite.Ctx)
chainID := suite.App.EvmKeeper.ChainID()

Expand Down Expand Up @@ -408,7 +408,7 @@ func (suite *KeeperTestSuite) DeployTestMessageCall(t require.TestingT) common.A
return crypto.CreateAddress(suite.Address, nonce)
}

func (suite *KeeperTestSuite) GetAllAccountStorage(
func (suite *TestSuite) GetAllAccountStorage(
ctx sdk.Context,
addr common.Address,
) map[common.Hash]common.Hash {
Expand Down

0 comments on commit 0d45d11

Please sign in to comment.