From 81068df640b0ff1be0424b935a786cc91e6be3e4 Mon Sep 17 00:00:00 2001 From: akhilkumarpilli Date: Fri, 25 Oct 2024 11:37:13 +0530 Subject: [PATCH 1/4] test: migrate remaining e2e tests to integration tests --- tests/e2e/genutil/export_test.go | 232 ------------------ .../accounts/account_abstraction_test.go | 0 .../accounts/base_account_test.go | 0 .../lockup/continous_lockup_test_suite.go | 0 .../lockup/delayed_lockup_test_suite.go | 0 .../accounts/lockup/lockup_account_test.go | 0 .../lockup/periodic_lockup_test_suite.go | 0 .../lockup/permanent_lockup_test_suite.go | 0 .../accounts/lockup/utils.go | 0 .../accounts/multisig/account_test.go | 0 .../accounts/multisig/test_suite.go | 0 .../accounts/wiring_test.go | 0 .../auth/keeper/account_retriever_test.go | 5 +- .../auth/keeper/app_config.go | 0 .../auth/keeper/keeper_bench_test.go | 7 +- .../auth/keeper/module_test.go | 5 +- .../tx/benchmarks_test.go | 0 17 files changed, 10 insertions(+), 239 deletions(-) delete mode 100644 tests/e2e/genutil/export_test.go rename tests/{e2e => integration}/accounts/account_abstraction_test.go (100%) rename tests/{e2e => integration}/accounts/base_account_test.go (100%) rename tests/{e2e => integration}/accounts/lockup/continous_lockup_test_suite.go (100%) rename tests/{e2e => integration}/accounts/lockup/delayed_lockup_test_suite.go (100%) rename tests/{e2e => integration}/accounts/lockup/lockup_account_test.go (100%) rename tests/{e2e => integration}/accounts/lockup/periodic_lockup_test_suite.go (100%) rename tests/{e2e => integration}/accounts/lockup/permanent_lockup_test_suite.go (100%) rename tests/{e2e => integration}/accounts/lockup/utils.go (100%) rename tests/{e2e => integration}/accounts/multisig/account_test.go (100%) rename tests/{e2e => integration}/accounts/multisig/test_suite.go (100%) rename tests/{e2e => integration}/accounts/wiring_test.go (100%) rename tests/{e2e => integration}/auth/keeper/account_retriever_test.go (87%) rename tests/{e2e => integration}/auth/keeper/app_config.go (100%) rename tests/{e2e => integration}/auth/keeper/keeper_bench_test.go (92%) rename tests/{e2e => integration}/auth/keeper/module_test.go (85%) rename tests/{e2e => integration}/tx/benchmarks_test.go (100%) diff --git a/tests/e2e/genutil/export_test.go b/tests/e2e/genutil/export_test.go deleted file mode 100644 index 798885c0900f..000000000000 --- a/tests/e2e/genutil/export_test.go +++ /dev/null @@ -1,232 +0,0 @@ -//go:build e2e -// +build e2e - -package genutil_test - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "os" - "path" - "testing" - - abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" - cmtcfg "github.com/cometbft/cometbft/config" - "github.com/spf13/cobra" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "gotest.tools/v3/assert" - - corectx "cosmossdk.io/core/context" - corestore "cosmossdk.io/core/store" - coretesting "cosmossdk.io/core/testing" - "cosmossdk.io/log" - "cosmossdk.io/simapp" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/server/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - gentestutil "github.com/cosmos/cosmos-sdk/testutil/x/genutil" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/genutil" - genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" - genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" -) - -func TestExportCmd_ConsensusParams(t *testing.T) { - tempDir := t.TempDir() - _, ctx, _, cmd := setupApp(t, tempDir) - - output := &bytes.Buffer{} - cmd.SetOut(output) - assert.NilError(t, cmd.ExecuteContext(ctx)) - - var exportedAppGenesis genutiltypes.AppGenesis - err := json.Unmarshal(output.Bytes(), &exportedAppGenesis) - assert.NilError(t, err) - - assert.DeepEqual(t, simtestutil.DefaultConsensusParams.Block.MaxBytes, exportedAppGenesis.Consensus.Params.Block.MaxBytes) - assert.DeepEqual(t, simtestutil.DefaultConsensusParams.Block.MaxGas, exportedAppGenesis.Consensus.Params.Block.MaxGas) - - assert.DeepEqual(t, simtestutil.DefaultConsensusParams.Evidence.MaxAgeDuration, exportedAppGenesis.Consensus.Params.Evidence.MaxAgeDuration) - assert.DeepEqual(t, simtestutil.DefaultConsensusParams.Evidence.MaxAgeNumBlocks, exportedAppGenesis.Consensus.Params.Evidence.MaxAgeNumBlocks) - - assert.DeepEqual(t, simtestutil.DefaultConsensusParams.Validator.PubKeyTypes, exportedAppGenesis.Consensus.Params.Validator.PubKeyTypes) -} - -func TestExportCmd_HomeDir(t *testing.T) { - _, ctx, _, cmd := setupApp(t, t.TempDir()) - - v := ctx.Value(corectx.ViperContextKey) - viper, ok := v.(*viper.Viper) - require.True(t, ok) - viper.Set(flags.FlagHome, "foobar") - - err := cmd.ExecuteContext(ctx) - assert.ErrorContains(t, err, "stat foobar/config/genesis.json: no such file or directory") -} - -func TestExportCmd_Height(t *testing.T) { - testCases := []struct { - name string - flags []string - fastForward int64 - expHeight int64 - }{ - { - "should export correct height", - []string{}, - 5, 6, - }, - { - "should export correct height with --height", - []string{ - fmt.Sprintf("--height=%d", 3), - }, - 5, 4, - }, - { - "should export height 0 with --for-zero-height", - []string{ - fmt.Sprintf("--for-zero-height=%s", "true"), - }, - 2, 0, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - tempDir := t.TempDir() - app, ctx, _, cmd := setupApp(t, tempDir) - - // Fast forward to block `tc.fastForward`. - for i := int64(2); i <= tc.fastForward; i++ { - _, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{ - Height: i, - }) - assert.NilError(t, err) - _, err = app.Commit() - assert.NilError(t, err) - } - - output := &bytes.Buffer{} - cmd.SetOut(output) - cmd.SetArgs(tc.flags) - assert.NilError(t, cmd.ExecuteContext(ctx)) - - var exportedAppGenesis genutiltypes.AppGenesis - err := json.Unmarshal(output.Bytes(), &exportedAppGenesis) - assert.NilError(t, err) - assert.Equal(t, tc.expHeight, exportedAppGenesis.InitialHeight) - }) - } -} - -func TestExportCmd_Output(t *testing.T) { - testCases := []struct { - name string - flags []string - outputDocument string - }{ - { - "should export state to the specified file", - []string{ - fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, "foobar.json"), - }, - "foobar.json", - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - tempDir := t.TempDir() - _, ctx, _, cmd := setupApp(t, tempDir) - - output := &bytes.Buffer{} - cmd.SetOut(output) - cmd.SetArgs(tc.flags) - assert.NilError(t, cmd.ExecuteContext(ctx)) - - var exportedAppGenesis genutiltypes.AppGenesis - f, err := os.ReadFile(tc.outputDocument) - assert.NilError(t, err) - assert.NilError(t, json.Unmarshal(f, &exportedAppGenesis)) - - // Cleanup - assert.NilError(t, os.Remove(tc.outputDocument)) - }) - } -} - -func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, genutiltypes.AppGenesis, *cobra.Command) { - t.Helper() - - logger := log.NewTestLogger(t) - err := createConfigFolder(tempDir) - assert.NilError(t, err) - - db := coretesting.NewMemDB() - app := simapp.NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir)) - - genesisState := simapp.GenesisStateWithSingleValidator(t, app) - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - assert.NilError(t, err) - - viper := viper.New() - err = gentestutil.WriteAndTrackCometConfig(viper, tempDir, cmtcfg.DefaultConfig()) - assert.NilError(t, err) - - clientCtx := client.Context{}.WithCodec(app.AppCodec()) - appGenesis := genutiltypes.AppGenesis{ - ChainID: "theChainId", - AppState: stateBytes, - Consensus: &genutiltypes.ConsensusGenesis{ - Validators: []sdk.GenesisValidator{}, - }, - } - - // save genesis file - err = genutil.ExportGenesisFile(&appGenesis, client.GetConfigFromViper(viper).GenesisFile()) - assert.NilError(t, err) - - _, err = app.InitChain(&abci.InitChainRequest{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: simtestutil.DefaultConsensusParams, - AppStateBytes: appGenesis.AppState, - }) - assert.NilError(t, err) - _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{ - Height: 1, - }) - assert.NilError(t, err) - _, err = app.Commit() - assert.NilError(t, err) - - cmd := genutilcli.ExportCmd(func(_ log.Logger, _ corestore.KVStoreWithBatch, _ io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOptions types.AppOptions, modulesToExport []string) (types.ExportedApp, error) { - var simApp *simapp.SimApp - if height != -1 { - simApp = simapp.NewSimApp(logger, db, nil, false, appOptions) - if err := simApp.LoadHeight(height); err != nil { - return types.ExportedApp{}, err - } - } else { - simApp = simapp.NewSimApp(logger, db, nil, true, appOptions) - } - - return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) - }) - - ctx := context.Background() - ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) - ctx = context.WithValue(ctx, corectx.ViperContextKey, viper) - - return app, ctx, appGenesis, cmd -} - -func createConfigFolder(dir string) error { - return os.Mkdir(path.Join(dir, "config"), 0o700) -} diff --git a/tests/e2e/accounts/account_abstraction_test.go b/tests/integration/accounts/account_abstraction_test.go similarity index 100% rename from tests/e2e/accounts/account_abstraction_test.go rename to tests/integration/accounts/account_abstraction_test.go diff --git a/tests/e2e/accounts/base_account_test.go b/tests/integration/accounts/base_account_test.go similarity index 100% rename from tests/e2e/accounts/base_account_test.go rename to tests/integration/accounts/base_account_test.go diff --git a/tests/e2e/accounts/lockup/continous_lockup_test_suite.go b/tests/integration/accounts/lockup/continous_lockup_test_suite.go similarity index 100% rename from tests/e2e/accounts/lockup/continous_lockup_test_suite.go rename to tests/integration/accounts/lockup/continous_lockup_test_suite.go diff --git a/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go b/tests/integration/accounts/lockup/delayed_lockup_test_suite.go similarity index 100% rename from tests/e2e/accounts/lockup/delayed_lockup_test_suite.go rename to tests/integration/accounts/lockup/delayed_lockup_test_suite.go diff --git a/tests/e2e/accounts/lockup/lockup_account_test.go b/tests/integration/accounts/lockup/lockup_account_test.go similarity index 100% rename from tests/e2e/accounts/lockup/lockup_account_test.go rename to tests/integration/accounts/lockup/lockup_account_test.go diff --git a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go b/tests/integration/accounts/lockup/periodic_lockup_test_suite.go similarity index 100% rename from tests/e2e/accounts/lockup/periodic_lockup_test_suite.go rename to tests/integration/accounts/lockup/periodic_lockup_test_suite.go diff --git a/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go b/tests/integration/accounts/lockup/permanent_lockup_test_suite.go similarity index 100% rename from tests/e2e/accounts/lockup/permanent_lockup_test_suite.go rename to tests/integration/accounts/lockup/permanent_lockup_test_suite.go diff --git a/tests/e2e/accounts/lockup/utils.go b/tests/integration/accounts/lockup/utils.go similarity index 100% rename from tests/e2e/accounts/lockup/utils.go rename to tests/integration/accounts/lockup/utils.go diff --git a/tests/e2e/accounts/multisig/account_test.go b/tests/integration/accounts/multisig/account_test.go similarity index 100% rename from tests/e2e/accounts/multisig/account_test.go rename to tests/integration/accounts/multisig/account_test.go diff --git a/tests/e2e/accounts/multisig/test_suite.go b/tests/integration/accounts/multisig/test_suite.go similarity index 100% rename from tests/e2e/accounts/multisig/test_suite.go rename to tests/integration/accounts/multisig/test_suite.go diff --git a/tests/e2e/accounts/wiring_test.go b/tests/integration/accounts/wiring_test.go similarity index 100% rename from tests/e2e/accounts/wiring_test.go rename to tests/integration/accounts/wiring_test.go diff --git a/tests/e2e/auth/keeper/account_retriever_test.go b/tests/integration/auth/keeper/account_retriever_test.go similarity index 87% rename from tests/e2e/auth/keeper/account_retriever_test.go rename to tests/integration/auth/keeper/account_retriever_test.go index 7fcfcaa98c2b..68481cdebc5c 100644 --- a/tests/e2e/auth/keeper/account_retriever_test.go +++ b/tests/integration/auth/keeper/account_retriever_test.go @@ -1,16 +1,17 @@ -package keeper +package keeper_test import ( "testing" "github.com/stretchr/testify/require" + authTest "github.com/cosmos/cosmos-sdk/tests/integration/auth/keeper" "github.com/cosmos/cosmos-sdk/testutil/network" "github.com/cosmos/cosmos-sdk/x/auth/types" ) func TestAccountRetriever(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(AppConfig) + cfg, err := network.DefaultConfigWithAppConfig(authTest.AppConfig) require.NoError(t, err) cfg.NumValidators = 1 diff --git a/tests/e2e/auth/keeper/app_config.go b/tests/integration/auth/keeper/app_config.go similarity index 100% rename from tests/e2e/auth/keeper/app_config.go rename to tests/integration/auth/keeper/app_config.go diff --git a/tests/e2e/auth/keeper/keeper_bench_test.go b/tests/integration/auth/keeper/keeper_bench_test.go similarity index 92% rename from tests/e2e/auth/keeper/keeper_bench_test.go rename to tests/integration/auth/keeper/keeper_bench_test.go index 345c46ae9d5d..09bde3bd7e80 100644 --- a/tests/e2e/auth/keeper/keeper_bench_test.go +++ b/tests/integration/auth/keeper/keeper_bench_test.go @@ -1,4 +1,4 @@ -package keeper +package keeper_test import ( "testing" @@ -8,6 +8,7 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/log" + authTest "github.com/cosmos/cosmos-sdk/tests/integration/auth/keeper" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/keeper" @@ -19,7 +20,7 @@ func BenchmarkAccountMapperGetAccountFound(b *testing.B) { app, err := simtestutil.Setup( depinject.Configs( depinject.Supply(log.NewNopLogger()), - AppConfig, + authTest.AppConfig, ), &accountKeeper, ) @@ -48,7 +49,7 @@ func BenchmarkAccountMapperSetAccount(b *testing.B) { app, err := simtestutil.Setup( depinject.Configs( depinject.Supply(log.NewNopLogger()), - AppConfig, + authTest.AppConfig, ), &accountKeeper) require.NoError(b, err) diff --git a/tests/e2e/auth/keeper/module_test.go b/tests/integration/auth/keeper/module_test.go similarity index 85% rename from tests/e2e/auth/keeper/module_test.go rename to tests/integration/auth/keeper/module_test.go index d9724bde6267..3937da28912c 100644 --- a/tests/e2e/auth/keeper/module_test.go +++ b/tests/integration/auth/keeper/module_test.go @@ -1,4 +1,4 @@ -package keeper +package keeper_test import ( "testing" @@ -8,6 +8,7 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/log" + authTest "github.com/cosmos/cosmos-sdk/tests/integration/auth/keeper" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -17,7 +18,7 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { var accountKeeper keeper.AccountKeeper app, err := simtestutil.SetupAtGenesis( depinject.Configs( - AppConfig, + authTest.AppConfig, depinject.Supply(log.NewNopLogger()), ), &accountKeeper) diff --git a/tests/e2e/tx/benchmarks_test.go b/tests/integration/tx/benchmarks_test.go similarity index 100% rename from tests/e2e/tx/benchmarks_test.go rename to tests/integration/tx/benchmarks_test.go From 1ac31158934bf487e03f6cc5a0eae48c69d46687 Mon Sep 17 00:00:00 2001 From: akhilkumarpilli Date: Fri, 25 Oct 2024 12:48:35 +0530 Subject: [PATCH 2/4] remove e2e --- tests/Makefile | 6 ----- .../lockup/continous_lockup_test_suite.go | 2 +- .../lockup/delayed_lockup_test_suite.go | 2 +- .../accounts/lockup/lockup_account_test.go | 4 ++-- .../lockup/periodic_lockup_test_suite.go | 2 +- .../lockup/permanent_lockup_test_suite.go | 2 +- tests/integration/accounts/lockup/utils.go | 22 +++++++++---------- .../accounts/multisig/account_test.go | 8 +++---- .../accounts/multisig/test_suite.go | 22 +++++++++---------- tests/integration/tx/benchmarks_test.go | 14 ++++++------ 10 files changed, 39 insertions(+), 45 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 95df468c7728..04266002f7e8 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -3,9 +3,3 @@ test-integration: test-integration-cov: go test ./integration/... -timeout 30m -coverpkg=../... -coverprofile=integration-profile.out -covermode=atomic - -test-e2e: - go test ./e2e/... -mod=readonly -timeout 30m -race -tags='e2e' - -test-e2e-cov: - go test ./e2e/... -mod=readonly -timeout 30m -race -tags='e2e' -coverpkg=../... -coverprofile=e2e-profile.out -covermode=atomic \ No newline at end of file diff --git a/tests/integration/accounts/lockup/continous_lockup_test_suite.go b/tests/integration/accounts/lockup/continous_lockup_test_suite.go index 654cb055f7f1..40da6a5a9ad0 100644 --- a/tests/integration/accounts/lockup/continous_lockup_test_suite.go +++ b/tests/integration/accounts/lockup/continous_lockup_test_suite.go @@ -16,7 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (s *E2ETestSuite) TestContinuousLockingAccount() { +func (s *IntegrationTestSuite) TestContinuousLockingAccount() { t := s.T() app := setupApp(t) currentTime := time.Now() diff --git a/tests/integration/accounts/lockup/delayed_lockup_test_suite.go b/tests/integration/accounts/lockup/delayed_lockup_test_suite.go index 27f7c9202e63..09aa153a468f 100644 --- a/tests/integration/accounts/lockup/delayed_lockup_test_suite.go +++ b/tests/integration/accounts/lockup/delayed_lockup_test_suite.go @@ -16,7 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (s *E2ETestSuite) TestDelayedLockingAccount() { +func (s *IntegrationTestSuite) TestDelayedLockingAccount() { t := s.T() app := setupApp(t) currentTime := time.Now() diff --git a/tests/integration/accounts/lockup/lockup_account_test.go b/tests/integration/accounts/lockup/lockup_account_test.go index 38d4893e8606..c8f409d7985e 100644 --- a/tests/integration/accounts/lockup/lockup_account_test.go +++ b/tests/integration/accounts/lockup/lockup_account_test.go @@ -6,6 +6,6 @@ import ( "github.com/stretchr/testify/suite" ) -func TestE2ETestSuite(t *testing.T) { - suite.Run(t, NewE2ETestSuite()) +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, NewIntegrationTestSuite()) } diff --git a/tests/integration/accounts/lockup/periodic_lockup_test_suite.go b/tests/integration/accounts/lockup/periodic_lockup_test_suite.go index 0bce9a267558..f0f1937b623d 100644 --- a/tests/integration/accounts/lockup/periodic_lockup_test_suite.go +++ b/tests/integration/accounts/lockup/periodic_lockup_test_suite.go @@ -16,7 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (s *E2ETestSuite) TestPeriodicLockingAccount() { +func (s *IntegrationTestSuite) TestPeriodicLockingAccount() { t := s.T() app := setupApp(t) currentTime := time.Now() diff --git a/tests/integration/accounts/lockup/permanent_lockup_test_suite.go b/tests/integration/accounts/lockup/permanent_lockup_test_suite.go index f1d4b33f3bd5..e94107f668d8 100644 --- a/tests/integration/accounts/lockup/permanent_lockup_test_suite.go +++ b/tests/integration/accounts/lockup/permanent_lockup_test_suite.go @@ -16,7 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (s *E2ETestSuite) TestPermanentLockingAccount() { +func (s *IntegrationTestSuite) TestPermanentLockingAccount() { t := s.T() app := setupApp(t) currentTime := time.Now() diff --git a/tests/integration/accounts/lockup/utils.go b/tests/integration/accounts/lockup/utils.go index 79658d236036..a0ce8f4e0c23 100644 --- a/tests/integration/accounts/lockup/utils.go +++ b/tests/integration/accounts/lockup/utils.go @@ -20,23 +20,23 @@ var ( accOwner = sdk.AccAddress(ownerAddr) ) -type E2ETestSuite struct { +type IntegrationTestSuite struct { suite.Suite app *simapp.SimApp } -func NewE2ETestSuite() *E2ETestSuite { - return &E2ETestSuite{} +func NewIntegrationTestSuite() *IntegrationTestSuite { + return &IntegrationTestSuite{} } -func (s *E2ETestSuite) SetupSuite() { - s.T().Log("setting up e2e test suite") +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") s.app = setupApp(s.T()) } -func (s *E2ETestSuite) TearDownSuite() { - s.T().Log("tearing down e2e test suite") +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") } func setupApp(t *testing.T) *simapp.SimApp { @@ -45,21 +45,21 @@ func setupApp(t *testing.T) *simapp.SimApp { return app } -func (s *E2ETestSuite) executeTx(ctx sdk.Context, msg sdk.Msg, app *simapp.SimApp, accAddr, sender []byte) error { +func (s *IntegrationTestSuite) executeTx(ctx sdk.Context, msg sdk.Msg, app *simapp.SimApp, accAddr, sender []byte) error { _, err := app.AccountsKeeper.Execute(ctx, accAddr, sender, msg, nil) return err } -func (s *E2ETestSuite) queryAcc(ctx sdk.Context, req sdk.Msg, app *simapp.SimApp, accAddr []byte) (transaction.Msg, error) { +func (s *IntegrationTestSuite) queryAcc(ctx sdk.Context, req sdk.Msg, app *simapp.SimApp, accAddr []byte) (transaction.Msg, error) { resp, err := app.AccountsKeeper.Query(ctx, accAddr, req) return resp, err } -func (s *E2ETestSuite) fundAccount(app *simapp.SimApp, ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) { +func (s *IntegrationTestSuite) fundAccount(app *simapp.SimApp, ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) { require.NoError(s.T(), testutil.FundAccount(ctx, app.BankKeeper, addr, amt)) } -func (s *E2ETestSuite) queryLockupAccInfo(ctx sdk.Context, app *simapp.SimApp, accAddr []byte) *types.QueryLockupAccountInfoResponse { +func (s *IntegrationTestSuite) queryLockupAccInfo(ctx sdk.Context, app *simapp.SimApp, accAddr []byte) *types.QueryLockupAccountInfoResponse { req := &types.QueryLockupAccountInfoRequest{} resp, err := s.queryAcc(ctx, req, app, accAddr) require.NoError(s.T(), err) diff --git a/tests/integration/accounts/multisig/account_test.go b/tests/integration/accounts/multisig/account_test.go index f3fc0c8da926..8e03674ec480 100644 --- a/tests/integration/accounts/multisig/account_test.go +++ b/tests/integration/accounts/multisig/account_test.go @@ -18,12 +18,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func TestE2ETestSuite(t *testing.T) { - suite.Run(t, NewE2ETestSuite()) +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, NewIntegrationTestSuite()) } // TestSimpleSendProposal creates a multisig account with 1 member, sends a tx, votes and executes it. -func (s *E2ETestSuite) TestSimpleSendProposal() { +func (s *IntegrationTestSuite) TestSimpleSendProposal() { ctx := sdk.NewContext(s.app.CommitMultiStore(), false, s.app.Logger()).WithHeaderInfo(header.Info{ Time: time.Now(), }) @@ -110,7 +110,7 @@ func (s *E2ETestSuite) TestSimpleSendProposal() { // TestConfigUpdate creates a multisig with 1 member, adds 2 more members and // changes the config to require 2/3 majority (also through a proposal). -func (s *E2ETestSuite) TestConfigUpdate() { +func (s *IntegrationTestSuite) TestConfigUpdate() { ctx := sdk.NewContext(s.app.CommitMultiStore(), false, s.app.Logger()).WithHeaderInfo(header.Info{ Time: time.Now(), }) diff --git a/tests/integration/accounts/multisig/test_suite.go b/tests/integration/accounts/multisig/test_suite.go index d2e6debb6de6..e22fd9ed3365 100644 --- a/tests/integration/accounts/multisig/test_suite.go +++ b/tests/integration/accounts/multisig/test_suite.go @@ -18,7 +18,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -type E2ETestSuite struct { +type IntegrationTestSuite struct { suite.Suite app *simapp.SimApp @@ -26,11 +26,11 @@ type E2ETestSuite struct { membersAddr []string } -func NewE2ETestSuite() *E2ETestSuite { - return &E2ETestSuite{} +func NewIntegrationTestSuite() *IntegrationTestSuite { + return &IntegrationTestSuite{} } -func (s *E2ETestSuite) SetupSuite() { +func (s *IntegrationTestSuite) SetupSuite() { s.app = setupApp(s.T()) s.members = []sdk.AccAddress{} @@ -43,7 +43,7 @@ func (s *E2ETestSuite) SetupSuite() { } } -func (s *E2ETestSuite) TearDownSuite() {} +func (s *IntegrationTestSuite) TearDownSuite() {} func setupApp(t *testing.T) *simapp.SimApp { t.Helper() @@ -51,23 +51,23 @@ func setupApp(t *testing.T) *simapp.SimApp { return app } -func (s *E2ETestSuite) executeTx(ctx context.Context, msg sdk.Msg, accAddr, sender []byte) error { +func (s *IntegrationTestSuite) executeTx(ctx context.Context, msg sdk.Msg, accAddr, sender []byte) error { _, err := s.app.AccountsKeeper.Execute(ctx, accAddr, sender, msg, nil) return err } -func (s *E2ETestSuite) queryAcc(ctx context.Context, req sdk.Msg, accAddr []byte) (transaction.Msg, error) { +func (s *IntegrationTestSuite) queryAcc(ctx context.Context, req sdk.Msg, accAddr []byte) (transaction.Msg, error) { resp, err := s.app.AccountsKeeper.Query(ctx, accAddr, req) return resp, err } -func (s *E2ETestSuite) fundAccount(ctx context.Context, addr sdk.AccAddress, amt sdk.Coins) { +func (s *IntegrationTestSuite) fundAccount(ctx context.Context, addr sdk.AccAddress, amt sdk.Coins) { require.NoError(s.T(), testutil.FundAccount(ctx, s.app.BankKeeper, addr, amt)) } // initAccount initializes a multisig account with the given members and powers // and returns the account address -func (s *E2ETestSuite) initAccount(ctx context.Context, sender []byte, membersPowers map[string]uint64) ([]byte, string) { +func (s *IntegrationTestSuite) initAccount(ctx context.Context, sender []byte, membersPowers map[string]uint64) ([]byte, string) { s.fundAccount(ctx, sender, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000000))}) members := []*v1.Member{} @@ -95,7 +95,7 @@ func (s *E2ETestSuite) initAccount(ctx context.Context, sender []byte, membersPo } // createProposal -func (s *E2ETestSuite) createProposal(ctx context.Context, accAddr, sender []byte, msgs ...*codectypes.Any) { +func (s *IntegrationTestSuite) createProposal(ctx context.Context, accAddr, sender []byte, msgs ...*codectypes.Any) { propReq := &v1.MsgCreateProposal{ Proposal: &v1.Proposal{ Title: "test", @@ -107,7 +107,7 @@ func (s *E2ETestSuite) createProposal(ctx context.Context, accAddr, sender []byt s.NoError(err) } -func (s *E2ETestSuite) executeProposal(ctx context.Context, accAddr, sender []byte, proposalID uint64) error { +func (s *IntegrationTestSuite) executeProposal(ctx context.Context, accAddr, sender []byte, proposalID uint64) error { execReq := &v1.MsgExecuteProposal{ ProposalId: proposalID, } diff --git a/tests/integration/tx/benchmarks_test.go b/tests/integration/tx/benchmarks_test.go index e16850f61952..de5454f70528 100644 --- a/tests/integration/tx/benchmarks_test.go +++ b/tests/integration/tx/benchmarks_test.go @@ -21,7 +21,7 @@ import ( authclient "github.com/cosmos/cosmos-sdk/x/auth/client" ) -type E2EBenchmarkSuite struct { +type TxBenchmarkSuite struct { cfg network.Config network network.NetworkI @@ -29,7 +29,7 @@ type E2EBenchmarkSuite struct { queryClient tx.ServiceClient } -// BenchmarkTx is lifted from E2ETestSuite from this package, with irrelevant state checks removed. +// BenchmarkTx is lifted from TestSuite from this package, with irrelevant state checks removed. // // Benchmark results: // @@ -41,7 +41,7 @@ type E2EBenchmarkSuite struct { // // BenchmarkTx-8 3772 301750 ns/op func BenchmarkTx(b *testing.B) { - s := NewE2EBenchmarkSuite(b) + s := NewTxBenchmarkSuite(b) b.Cleanup(s.Close) val := s.network.GetValidators()[0] @@ -82,10 +82,10 @@ func BenchmarkTx(b *testing.B) { } } -func NewE2EBenchmarkSuite(tb testing.TB) *E2EBenchmarkSuite { +func NewTxBenchmarkSuite(tb testing.TB) *TxBenchmarkSuite { tb.Helper() - s := new(E2EBenchmarkSuite) + s := new(TxBenchmarkSuite) cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) cfg.NumValidators = 1 @@ -151,11 +151,11 @@ func NewE2EBenchmarkSuite(tb testing.TB) *E2EBenchmarkSuite { return s } -func (s *E2EBenchmarkSuite) Close() { +func (s *TxBenchmarkSuite) Close() { s.network.Cleanup() } -func mkTxBuilder(tb testing.TB, s *E2EBenchmarkSuite) client.TxBuilder { +func mkTxBuilder(tb testing.TB, s *TxBenchmarkSuite) client.TxBuilder { tb.Helper() val := s.network.GetValidators()[0] From 7682f92afe831d25d33c8c250d5fbb91a0c64a56 Mon Sep 17 00:00:00 2001 From: akhilkumarpilli Date: Fri, 25 Oct 2024 14:57:26 +0530 Subject: [PATCH 3/4] fix test and remove workflow --- .github/workflows/test.yml | 31 ------------------- .../tx/{ => benchmark}/benchmarks_test.go | 2 +- 2 files changed, 1 insertion(+), 32 deletions(-) rename tests/integration/tx/{ => benchmark}/benchmarks_test.go (99%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48c7e82a9677..490afee744dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -113,37 +113,6 @@ jobs: name: "${{ github.sha }}-integration-coverage" path: ./tests/integration-profile.out - test-e2e: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: "1.23" - check-latest: true - cache: true - cache-dependency-path: go.sum - - uses: technote-space/get-diff-action@v6.1.2 - id: git_diff - with: - PATTERNS: | - **/*.go - go.mod - go.sum - **/go.mod - **/go.sum - **/Makefile - Makefile - - name: e2e tests - if: env.GIT_DIFF - run: | - make test-e2e-cov - - uses: actions/upload-artifact@v3 - if: env.GIT_DIFF - with: - name: "${{ github.sha }}-e2e-coverage" - path: ./tests/e2e-profile.out - test-system: # v2 system tests are in v2-test.yml runs-on: ubuntu-latest steps: diff --git a/tests/integration/tx/benchmarks_test.go b/tests/integration/tx/benchmark/benchmarks_test.go similarity index 99% rename from tests/integration/tx/benchmarks_test.go rename to tests/integration/tx/benchmark/benchmarks_test.go index de5454f70528..4d26bc3e3d53 100644 --- a/tests/integration/tx/benchmarks_test.go +++ b/tests/integration/tx/benchmark/benchmarks_test.go @@ -1,4 +1,4 @@ -package tx_test +package benchmark_test import ( "context" From d3b7855e488d0135db4190bd4a408c897e3bdd55 Mon Sep 17 00:00:00 2001 From: akhilkumarpilli Date: Fri, 25 Oct 2024 21:15:35 +0530 Subject: [PATCH 4/4] remove test-e2e --- .github/workflows/test.yml | 2 +- scripts/build/testing.mk | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 490afee744dd..2a215b89747a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -155,7 +155,7 @@ jobs: repo-analysis: runs-on: ubuntu-latest - needs: [tests, test-integration, test-e2e] + needs: [tests, test-integration] steps: - uses: actions/checkout@v4 - uses: technote-space/get-diff-action@v6.1.2 diff --git a/scripts/build/testing.mk b/scripts/build/testing.mk index 8fcdcb7a61f6..2e58da7a4284 100644 --- a/scripts/build/testing.mk +++ b/scripts/build/testing.mk @@ -11,12 +11,6 @@ init-simapp-v2: #? test: Run `make test-unit` test: test-unit -#? test-e2e: Run `make -C tests test-e2e` -test-e2e: - $(MAKE) -C tests test-e2e -#? test-e2e-cov: Run `make -C tests test-e2e-cov` -test-e2e-cov: - $(MAKE) -C tests test-e2e-cov #? test-integration: Run `make -C tests test-integration` test-integration: $(MAKE) -C tests test-integration @@ -24,7 +18,7 @@ test-integration: test-integration-cov: $(MAKE) -C tests test-integration-cov #? test-all: Run all test -test-all: test-unit test-e2e test-integration test-ledger-mock test-race +test-all: test-unit test-integration test-ledger-mock test-race .PHONY: test-system test-system: build