Skip to content

Commit

Permalink
server: test - only init app version when equal or higher than 2
Browse files Browse the repository at this point in the history
  • Loading branch information
najeal committed Jul 23, 2024
1 parent 5e02d0e commit cc1aebf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 35 deletions.
19 changes: 9 additions & 10 deletions server/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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(
Expand Down
25 changes: 0 additions & 25 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -77,9 +55,6 @@ var DefaultConsensusParams = &abci.ConsensusParams{
tmtypes.ABCIPubKeyTypeEd25519,
},
},
Version: &tmproto.VersionParams{
AppVersion: 1,
},
}

// SetupOptions defines arguments that are passed into `Simapp` constructor.
Expand Down

0 comments on commit cc1aebf

Please sign in to comment.