From 5b8f187d75267934207cbabe7555b7a047cd6cd6 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:21:18 +0700 Subject: [PATCH 01/13] genutil tests --- tests/systemtests/export_test.go | 67 ++++++++++++++++++++++++++++++++ tests/systemtests/system.go | 4 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/systemtests/export_test.go diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go new file mode 100644 index 000000000000..2c9d2851821e --- /dev/null +++ b/tests/systemtests/export_test.go @@ -0,0 +1,67 @@ +//go:build system_test + +package systemtests + +import ( + "fmt" + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tidwall/gjson" +) + +func TestExportCmd(t *testing.T) { + // scenario: test bank send command + // given a running chain + + sut.ResetChain(t) + cli := NewCLIWrapper(t, sut, verbose) + exportFile := "foobar.json" + + sut.StartChain(t) + + testCases := []struct { + name string + args []string + expErr bool + errMsg string + expZeroHeight bool + }{ + {"invalid home dir", []string{"genesis", "export", "--home=foo"}, true, "no such file or directory", false}, + {"should export correct height", []string{"genesis", "export"}, false, "", false}, + {"should export correct height with --height", []string{"genesis", "export", "--height=5"}, false, "", false}, + {"should export height 0 with --for-zero-height", []string{"genesis", "export", "--for-zero-height=true"}, false, "", true}, + {"should export state to the specified file", []string{"genesis", "export", fmt.Sprintf("--output-document=%s", exportFile)}, false, "", false}, + } + + for _, tc := range testCases { + + // fmt.Println(tc.name, res) + if tc.expErr { + assertOutput := func(_ assert.TestingT, gotErr error, gotOutputs ...interface{}) bool { + require.Contains(t, gotOutputs[0], tc.errMsg) + return false + } + cli.WithRunErrorMatcher(assertOutput).RunCommandWithArgs(tc.args...) + } else { + res := cli.RunCommandWithArgs(tc.args...) + if res == "" { + require.FileExists(t, exportFile) + os.Remove(exportFile) + } else { + height := gjson.Get(res, "initial_height").Int() + if tc.expZeroHeight { + require.Equal(t, height, int64(0)) + } else { + require.Greater(t, height, int64(0)) + } + + // Check consensus params of exported state + maxGas := gjson.Get(res, "consensus.params.block.max_gas").Int() + require.Equal(t, maxGas, int64(MaxGas)) + } + } + } +} diff --git a/tests/systemtests/system.go b/tests/systemtests/system.go index adaa6da91d77..7105ff400ed1 100644 --- a/tests/systemtests/system.go +++ b/tests/systemtests/system.go @@ -35,6 +35,8 @@ var ( // ExecBinaryUnversionedRegExp regular expression to extract the unversioned binary name ExecBinaryUnversionedRegExp = regexp.MustCompile(`^(\w+)-?.*$`) + + MaxGas = 10_000_000 ) type TestnetInitializer interface { @@ -130,7 +132,7 @@ func (s *SystemUnderTest) SetupChain() { panic(fmt.Sprintf("failed to load genesis: %s", err)) } - genesisBz, err = sjson.SetRawBytes(genesisBz, "consensus.params.block.max_gas", []byte(fmt.Sprintf(`"%d"`, 10_000_000))) + genesisBz, err = sjson.SetRawBytes(genesisBz, "consensus.params.block.max_gas", []byte(fmt.Sprintf(`"%d"`, MaxGas))) if err != nil { panic(fmt.Sprintf("failed to set block max gas: %s", err)) } From fdd414d19b586cae472d3621f7532d5534eefe34 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:22:24 +0700 Subject: [PATCH 02/13] remove migrated test --- tests/e2e/genutil/export_test.go | 232 ------------------------------- 1 file changed, 232 deletions(-) delete mode 100644 tests/e2e/genutil/export_test.go 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) -} From 0423a83a76e3a611e673141753e382d17bf88b2d Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:57:56 +0700 Subject: [PATCH 03/13] go mod --- tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/go.mod b/tests/go.mod index a01b8a1de45d..3e0bf0bb809a 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -22,7 +22,7 @@ require ( // this version is not used as it is always replaced by the latest Cosmos SDK version github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.7.0 - github.com/spf13/cobra v1.8.1 + github.com/spf13/cobra v1.8.1 // indirect github.com/stretchr/testify v1.9.0 go.uber.org/mock v0.5.0 google.golang.org/grpc v1.67.1 From 243f9c00e4c92108664d2885c5e4a39c4ece5600 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:55:47 +0700 Subject: [PATCH 04/13] refactor --- tests/systemtests/export_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index 2c9d2851821e..44334d822538 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -13,9 +13,6 @@ import ( ) func TestExportCmd(t *testing.T) { - // scenario: test bank send command - // given a running chain - sut.ResetChain(t) cli := NewCLIWrapper(t, sut, verbose) exportFile := "foobar.json" @@ -37,8 +34,6 @@ func TestExportCmd(t *testing.T) { } for _, tc := range testCases { - - // fmt.Println(tc.name, res) if tc.expErr { assertOutput := func(_ assert.TestingT, gotErr error, gotOutputs ...interface{}) bool { require.Contains(t, gotOutputs[0], tc.errMsg) From c0dc7b3e07ef0e32079b89b0605c36f1fb8874f8 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:44:05 +0700 Subject: [PATCH 05/13] split test --- tests/systemtests/export_test.go | 65 ++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index 44334d822538..8df9712a9eb5 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -12,25 +12,52 @@ import ( "github.com/tidwall/gjson" ) -func TestExportCmd(t *testing.T) { +func TestExportCmd_WithHeight(t *testing.T) { sut.ResetChain(t) cli := NewCLIWrapper(t, sut, verbose) - exportFile := "foobar.json" sut.StartChain(t) testCases := []struct { name string args []string - expErr bool - errMsg string expZeroHeight bool }{ - {"invalid home dir", []string{"genesis", "export", "--home=foo"}, true, "no such file or directory", false}, - {"should export correct height", []string{"genesis", "export"}, false, "", false}, - {"should export correct height with --height", []string{"genesis", "export", "--height=5"}, false, "", false}, - {"should export height 0 with --for-zero-height", []string{"genesis", "export", "--for-zero-height=true"}, false, "", true}, - {"should export state to the specified file", []string{"genesis", "export", fmt.Sprintf("--output-document=%s", exportFile)}, false, "", false}, + {"should export correct height", []string{"genesis", "export"}, false}, + {"should export correct height with --height", []string{"genesis", "export", "--height=5"}, false}, + {"should export height 0 with --for-zero-height", []string{"genesis", "export", "--for-zero-height=true"}, true}, + } + + for _, tc := range testCases { + res := cli.RunCommandWithArgs(tc.args...) + height := gjson.Get(res, "initial_height").Int() + if tc.expZeroHeight { + require.Equal(t, height, int64(0)) + } else { + require.Greater(t, height, int64(0)) + } + + // Check consensus params of exported state + maxGas := gjson.Get(res, "consensus.params.block.max_gas").Int() + require.Equal(t, maxGas, int64(MaxGas)) + } +} + +func TestExportCmd_WithFileFlag(t *testing.T) { + sut.ResetChain(t) + cli := NewCLIWrapper(t, sut, verbose) + exportFile := "foobar.json" + + sut.StartChain(t) + + testCases := []struct { + name string + args []string + expErr bool + errMsg string + }{ + {"invalid home dir", []string{"genesis", "export", "--home=foo"}, true, "no such file or directory"}, + {"should export state to the specified file", []string{"genesis", "export", fmt.Sprintf("--output-document=%s", exportFile)}, false, ""}, } for _, tc := range testCases { @@ -41,22 +68,10 @@ func TestExportCmd(t *testing.T) { } cli.WithRunErrorMatcher(assertOutput).RunCommandWithArgs(tc.args...) } else { - res := cli.RunCommandWithArgs(tc.args...) - if res == "" { - require.FileExists(t, exportFile) - os.Remove(exportFile) - } else { - height := gjson.Get(res, "initial_height").Int() - if tc.expZeroHeight { - require.Equal(t, height, int64(0)) - } else { - require.Greater(t, height, int64(0)) - } - - // Check consensus params of exported state - maxGas := gjson.Get(res, "consensus.params.block.max_gas").Int() - require.Equal(t, maxGas, int64(MaxGas)) - } + cli.RunCommandWithArgs(tc.args...) + require.FileExists(t, exportFile) + err := os.Remove(exportFile) + require.NoError(t, err) } } } From 035dd78a1eb8ddba9338d73ad77f23181074b6b9 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:24:12 +0700 Subject: [PATCH 06/13] check --- tests/systemtests/export_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index 8df9712a9eb5..2349960b916d 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -30,6 +30,7 @@ func TestExportCmd_WithHeight(t *testing.T) { for _, tc := range testCases { res := cli.RunCommandWithArgs(tc.args...) + fmt.Println(tc.name, res) height := gjson.Get(res, "initial_height").Int() if tc.expZeroHeight { require.Equal(t, height, int64(0)) From e6f82dc70c5ab51db322eec98387ab165b7de4c0 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:42:34 +0700 Subject: [PATCH 07/13] home path --- tests/systemtests/export_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index 2349960b916d..a5f655dff553 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -23,9 +23,9 @@ func TestExportCmd_WithHeight(t *testing.T) { args []string expZeroHeight bool }{ - {"should export correct height", []string{"genesis", "export"}, false}, - {"should export correct height with --height", []string{"genesis", "export", "--height=5"}, false}, - {"should export height 0 with --for-zero-height", []string{"genesis", "export", "--for-zero-height=true"}, true}, + {"should export correct height", []string{"genesis", "export", "--home", sut.nodePath(0)}, false}, + {"should export correct height with --height", []string{"genesis", "export", "--height=5", "--home", sut.nodePath(0)}, false}, + {"should export height 0 with --for-zero-height", []string{"genesis", "export", "--for-zero-height=true", "--home", sut.nodePath(0)}, true}, } for _, tc := range testCases { @@ -58,7 +58,7 @@ func TestExportCmd_WithFileFlag(t *testing.T) { errMsg string }{ {"invalid home dir", []string{"genesis", "export", "--home=foo"}, true, "no such file or directory"}, - {"should export state to the specified file", []string{"genesis", "export", fmt.Sprintf("--output-document=%s", exportFile)}, false, ""}, + {"should export state to the specified file", []string{"genesis", "export", fmt.Sprintf("--output-document=%s", exportFile), "--home", sut.nodePath(0)}, false, ""}, } for _, tc := range testCases { From cf3e1dcb3720af907879d656424dc9c8838f36dd Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:55:56 +0700 Subject: [PATCH 08/13] sleep --- tests/systemtests/export_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index a5f655dff553..b7e8e61f9e09 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -18,6 +19,11 @@ func TestExportCmd_WithHeight(t *testing.T) { sut.StartChain(t) + // Wait 10s for producing blocks + time.Sleep(10 * time.Second) + + sut.StopChain() + testCases := []struct { name string args []string From 47c47fa4eea4820710b9184fdb77d538e7d5c1f2 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:14:42 +0700 Subject: [PATCH 09/13] check --- tests/systemtests/export_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index b7e8e61f9e09..50b7a8865215 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -38,6 +38,7 @@ func TestExportCmd_WithHeight(t *testing.T) { res := cli.RunCommandWithArgs(tc.args...) fmt.Println(tc.name, res) height := gjson.Get(res, "initial_height").Int() + fmt.Println("height", height) if tc.expZeroHeight { require.Equal(t, height, int64(0)) } else { From 0e28e7bd131d421c408b0423d2370e5bffc22a7c Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:31:03 +0700 Subject: [PATCH 10/13] disable LoadHeight log --- tests/systemtests/export_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index 50b7a8865215..58eb4e1f2f81 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -1,4 +1,4 @@ -//go:build system_test +//go:build !system_test package systemtests @@ -30,7 +30,7 @@ func TestExportCmd_WithHeight(t *testing.T) { expZeroHeight bool }{ {"should export correct height", []string{"genesis", "export", "--home", sut.nodePath(0)}, false}, - {"should export correct height with --height", []string{"genesis", "export", "--height=5", "--home", sut.nodePath(0)}, false}, + {"should export correct height with --height", []string{"genesis", "export", "--height=5", "--home", sut.nodePath(0), "--log_level=disabled"}, false}, {"should export height 0 with --for-zero-height", []string{"genesis", "export", "--for-zero-height=true", "--home", sut.nodePath(0)}, true}, } From 20a7690b10ea39dc240d037481789c1fef1972cd Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:46:04 +0700 Subject: [PATCH 11/13] update --- tests/systemtests/export_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index 58eb4e1f2f81..220988e24f8a 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -58,6 +58,11 @@ func TestExportCmd_WithFileFlag(t *testing.T) { sut.StartChain(t) + // Wait 10s for producing blocks + time.Sleep(10 * time.Second) + + sut.StopChain() + testCases := []struct { name string args []string From c7a2c77d842355bbac8f662a89637823142c272a Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Thu, 24 Oct 2024 20:00:01 +0700 Subject: [PATCH 12/13] un comment --- tests/systemtests/export_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index 220988e24f8a..4c1054d7b5e0 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -1,4 +1,4 @@ -//go:build !system_test +//go:build system_test package systemtests From 94717809cd598118742b25bcedcc42e93119a75b Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Thu, 24 Oct 2024 20:14:46 +0700 Subject: [PATCH 13/13] clean up --- tests/systemtests/export_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/systemtests/export_test.go b/tests/systemtests/export_test.go index 4c1054d7b5e0..5d392d8ce10f 100644 --- a/tests/systemtests/export_test.go +++ b/tests/systemtests/export_test.go @@ -36,9 +36,7 @@ func TestExportCmd_WithHeight(t *testing.T) { for _, tc := range testCases { res := cli.RunCommandWithArgs(tc.args...) - fmt.Println(tc.name, res) height := gjson.Get(res, "initial_height").Int() - fmt.Println("height", height) if tc.expZeroHeight { require.Equal(t, height, int64(0)) } else {