diff --git a/app/app.go b/app/app.go index 1e6d312d2a..25341a17d3 100644 --- a/app/app.go +++ b/app/app.go @@ -108,6 +108,9 @@ const ( BondDenomAlias = "microtia" // DisplayDenom defines the name, symbol, and display value of the Celestia token. DisplayDenom = "TIA" + // SetProtocolVersionOptionKey is the key used to set the protocol version + // to a specific value during tests. + SetProtocolVersionOptionKey = "set-protocol-version" ) // These constants are derived from the above variables. @@ -259,6 +262,15 @@ func New( cdc := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry + // set the protocol version to a specific value if specified. This is used + // for testing purposes. + if pvo := appOpts.Get(SetProtocolVersionOptionKey); pvo != nil { + baseAppOptions = append(baseAppOptions, func(ba *baseapp.BaseApp) { + appVersion := pvo.(uint64) + ba.SetProtocolVersion(appVersion) + }) + } + bApp := baseapp.NewBaseApp(Name, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) diff --git a/test/util/testnode/config.go b/test/util/testnode/config.go index bb04f44ee4..f6242f5684 100644 --- a/test/util/testnode/config.go +++ b/test/util/testnode/config.go @@ -3,6 +3,7 @@ package testnode import ( "time" + "github.com/celestiaorg/celestia-app/app" "github.com/celestiaorg/celestia-app/cmd/celestia-appd/cmd" "github.com/celestiaorg/celestia-app/pkg/appconsts" "github.com/celestiaorg/celestia-app/test/util/genesis" @@ -146,6 +147,7 @@ func (ao *KVAppOptions) Set(o string, v interface{}) { func DefaultAppOptions() *KVAppOptions { opts := &KVAppOptions{options: make(map[string]interface{})} opts.Set(server.FlagPruning, pruningtypes.PruningOptionNothing) + opts.Set(app.SetProtocolVersionOptionKey, appconsts.LatestVersion) return opts } diff --git a/test/util/testnode/full_node_test.go b/test/util/testnode/full_node_test.go index a2e9dca5d8..fd52f95cf9 100644 --- a/test/util/testnode/full_node_test.go +++ b/test/util/testnode/full_node_test.go @@ -13,6 +13,7 @@ import ( "github.com/celestiaorg/celestia-app/test/util/genesis" blobtypes "github.com/celestiaorg/celestia-app/x/blob/types" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" tmrand "github.com/tendermint/tendermint/libs/rand" @@ -132,3 +133,12 @@ func (s *IntegrationTestSuite) Test_FillBlock_InvalidSquareSizeError() { }) } } + +// Test_defaultAppVersion tests that the default app version is set correctly in +// testnode. +func (s *IntegrationTestSuite) Test_defaultAppVersion() { + t := s.T() + blockRes, err := s.cctx.Client.Block(s.cctx.GoContext(), nil) + require.NoError(t, err) + require.Equal(t, appconsts.LatestVersion, blockRes.Block.Version.App) +}