Skip to content

Commit

Permalink
fix: set the protocol version during integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-forbes committed Nov 21, 2023
1 parent 6c5a86b commit abbbb72
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions test/util/testnode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
10 changes: 10 additions & 0 deletions test/util/testnode/full_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

0 comments on commit abbbb72

Please sign in to comment.