From cc1aebf2f538b66402863052e88dffd40747a9c3 Mon Sep 17 00:00:00 2001 From: Nathan Haim Date: Tue, 23 Jul 2024 10:52:28 +0200 Subject: [PATCH] server: test - only init app version when equal or higher than 2 --- server/export_test.go | 19 +++++++++---------- simapp/test_helpers.go | 25 ------------------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/server/export_test.go b/server/export_test.go index 05029ef55c3f..121dd5431aea 100644 --- a/server/export_test.go +++ b/server/export_test.go @@ -66,13 +66,12 @@ func TestExportCmd_ConsensusParams(t *testing.T) { } exportedGenDoc := getCommandResult(cmd) - consensusParams := simapp.NewDefaultConsensusParams() - require.Equal(t, consensusParams.Block.MaxBytes, exportedGenDoc.ConsensusParams.Block.MaxBytes) - require.Equal(t, consensusParams.Block.MaxGas, exportedGenDoc.ConsensusParams.Block.MaxGas) + require.Equal(t, simapp.DefaultConsensusParams.Block.MaxBytes, exportedGenDoc.ConsensusParams.Block.MaxBytes) + require.Equal(t, simapp.DefaultConsensusParams.Block.MaxGas, exportedGenDoc.ConsensusParams.Block.MaxGas) require.Equal(t, genDoc.ConsensusParams.Block.TimeIotaMs, exportedGenDoc.ConsensusParams.Block.TimeIotaMs) - require.Equal(t, consensusParams.Evidence.MaxAgeDuration, exportedGenDoc.ConsensusParams.Evidence.MaxAgeDuration) - require.Equal(t, consensusParams.Evidence.MaxAgeNumBlocks, exportedGenDoc.ConsensusParams.Evidence.MaxAgeNumBlocks) - require.Equal(t, consensusParams.Validator.PubKeyTypes, exportedGenDoc.ConsensusParams.Validator.PubKeyTypes) + require.Equal(t, simapp.DefaultConsensusParams.Evidence.MaxAgeDuration, exportedGenDoc.ConsensusParams.Evidence.MaxAgeDuration) + require.Equal(t, simapp.DefaultConsensusParams.Evidence.MaxAgeNumBlocks, exportedGenDoc.ConsensusParams.Evidence.MaxAgeNumBlocks) + require.Equal(t, simapp.DefaultConsensusParams.Validator.PubKeyTypes, exportedGenDoc.ConsensusParams.Validator.PubKeyTypes) require.Equal(t, utest.expectedAppVersion, exportedGenDoc.ConsensusParams.Version.AppVersion) }) } @@ -169,16 +168,16 @@ func setupApp(t *testing.T, tempDir string, appVersion uint64) (*simapp.SimApp, genDoc.AppState = stateBytes require.NoError(t, saveGenesisFile(genDoc, serverCtx.Config.GenesisFile())) - consensusParams := simapp.NewDefaultConsensusParams() - consensusParams.Version.AppVersion = appVersion app.InitChain( abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, - ConsensusParams: consensusParams, + ConsensusParams: simapp.DefaultConsensusParams, AppStateBytes: genDoc.AppState, }, ) - app.SetInitialAppVersionInConsensusParams(app.NewContext(false, tmproto.Header{}), consensusParams.Version.AppVersion) + if appVersion >= 2 { + app.SetInitialAppVersionInConsensusParams(app.NewContext(false, tmproto.Header{}), appVersion) + } app.Commit() cmd := server.ExportCmd( diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 78b541a2e8a3..f43d80f710e0 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -38,28 +38,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) -func NewDefaultConsensusParams() *abci.ConsensusParams { - return &abci.ConsensusParams{ - Block: &abci.BlockParams{ - MaxBytes: 200000, - MaxGas: 2000000, - }, - Evidence: &tmproto.EvidenceParams{ - MaxAgeNumBlocks: 302400, - MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration - MaxBytes: 10000, - }, - Validator: &tmproto.ValidatorParams{ - PubKeyTypes: []string{ - tmtypes.ABCIPubKeyTypeEd25519, - }, - }, - Version: &tmproto.VersionParams{ - AppVersion: 1, - }, - } -} - // DefaultConsensusParams defines the default Tendermint consensus params used in // SimApp testing. var DefaultConsensusParams = &abci.ConsensusParams{ @@ -77,9 +55,6 @@ var DefaultConsensusParams = &abci.ConsensusParams{ tmtypes.ABCIPubKeyTypeEd25519, }, }, - Version: &tmproto.VersionParams{ - AppVersion: 1, - }, } // SetupOptions defines arguments that are passed into `Simapp` constructor.