diff --git a/app/test/priority_test.go b/app/test/priority_test.go index b615b8e9ac..da7936dd0d 100644 --- a/app/test/priority_test.go +++ b/app/test/priority_test.go @@ -52,7 +52,7 @@ func (s *PriorityTestSuite) SetupSuite() { cfg := testnode.DefaultConfig(). WithFundedAccounts(s.accountNames...). // use a long block time to guarantee that some transactions are included in the same block - WithBlockTime(time.Second) + WithTimeoutCommit(time.Second) cctx, _, _ := testnode.NewNetwork(t, cfg) s.cctx = cctx diff --git a/app/test/square_size_test.go b/app/test/square_size_test.go index 754a5d0adf..b7d147fe0d 100644 --- a/app/test/square_size_test.go +++ b/app/test/square_size_test.go @@ -49,7 +49,7 @@ func (s *SquareSizeIntegrationTest) SetupSuite() { cfg := testnode.DefaultConfig(). WithModifiers(genesis.ImmediateProposals(s.ecfg.Codec)). - WithBlockTime(time.Second) + WithTimeoutCommit(time.Second) cctx, rpcAddr, grpcAddr := testnode.NewNetwork(t, cfg) diff --git a/pkg/appconsts/versioned_consts_test.go b/pkg/appconsts/versioned_consts_test.go index 8f67d4cefd..249dd99805 100644 --- a/pkg/appconsts/versioned_consts_test.go +++ b/pkg/appconsts/versioned_consts_test.go @@ -106,12 +106,6 @@ func TestUpgradeHeightDelay(t *testing.T) { version: v2.Version, expectedUpgradeHeightDelay: v2.UpgradeHeightDelay, }, - { - name: "v2 upgrade delay on an arabica network other than arabica-11", - chainID: "arabica-11", - version: v2.Version, - expectedUpgradeHeightDelay: v3.UpgradeHeightDelay, // falls back to v3 because of arabica bug - }, { name: "v2 upgrade delay on arabica", chainID: "arabica-11", diff --git a/test/txsim/run_test.go b/test/txsim/run_test.go index 2dfa608574..d4cbdf22ba 100644 --- a/test/txsim/run_test.go +++ b/test/txsim/run_test.go @@ -151,7 +151,7 @@ func TestTxSimulator(t *testing.T) { func Setup(t testing.TB) (keyring.Keyring, string, string) { t.Helper() - cfg := testnode.DefaultConfig().WithBlockTime(300 * time.Millisecond).WithFundedAccounts("txsim-master") + cfg := testnode.DefaultConfig().WithTimeoutCommit(300 * time.Millisecond).WithFundedAccounts("txsim-master") cctx, rpcAddr, grpcAddr := testnode.NewNetwork(t, cfg) @@ -165,7 +165,7 @@ func TestTxSimUpgrade(t *testing.T) { cp := app.DefaultConsensusParams() cp.Version.AppVersion = v2.Version cfg := testnode.DefaultConfig(). - WithBlockTime(300 * time.Millisecond). + WithTimeoutCommit(300 * time.Millisecond). WithConsensusParams(cp). WithFundedAccounts("txsim-master") cctx, _, grpcAddr := testnode.NewNetwork(t, cfg) diff --git a/test/util/testnode/config.go b/test/util/testnode/config.go index fff1053494..76508f91d4 100644 --- a/test/util/testnode/config.go +++ b/test/util/testnode/config.go @@ -82,20 +82,10 @@ func (c *Config) WithSuppressLogs(sl bool) *Config { return c } -// WithBlockTime sets the block time and returns the Config. -func (c *Config) WithBlockTime(d time.Duration) *Config { - c.TmConfig.Consensus.TimeoutCommit = d - creator := DefaultAppCreator(d) - c.WithAppCreator(creator) - return c -} - -// Deprecated: use WithBlockTime instead. WithTimeoutCommit sets the timeout -// commit in the cometBFT config and returns the Config. Warning, this won't -// actually change the block time and is being deprecated. +// WithTimeoutCommit sets the timeout commit in the cometBFT config and returns +// the Config. func (c *Config) WithTimeoutCommit(d time.Duration) *Config { - c.TmConfig.Consensus.TimeoutCommit = d - return c + return c.WithAppCreator(DefaultAppCreator(WithTimeoutCommit(d))) } // WithFundedAccounts sets the genesis accounts and returns the Config. @@ -142,7 +132,7 @@ func DefaultConfig() *Config { WithTendermintConfig(DefaultTendermintConfig()). WithAppConfig(DefaultAppConfig()). WithAppOptions(DefaultAppOptions()). - WithAppCreator(DefaultAppCreator(time.Millisecond * 30)). + WithTimeoutCommit(time.Millisecond * 30). WithSuppressLogs(true) } @@ -181,7 +171,15 @@ func DefaultTendermintConfig() *tmconfig.Config { return tmCfg } -func DefaultAppCreator(blockTime time.Duration) srvtypes.AppCreator { +type AppCreationOptions func(app *app.App) + +func WithTimeoutCommit(d time.Duration) AppCreationOptions { + return func(app *app.App) { + app.SetEndBlocker(wrapEndBlocker(app, d)) + } +} + +func DefaultAppCreator(opts ...AppCreationOptions) srvtypes.AppCreator { return func(_ log.Logger, _ tmdb.DB, _ io.Writer, _ srvtypes.AppOptions) srvtypes.Application { encodingConfig := encoding.MakeConfig(app.ModuleEncodingRegisters...) app := app.New( @@ -194,7 +192,11 @@ func DefaultAppCreator(blockTime time.Duration) srvtypes.AppCreator { simapp.EmptyAppOptions{}, baseapp.SetMinGasPrices(fmt.Sprintf("%v%v", appconsts.DefaultMinGasPrice, app.BondDenom)), ) - app.SetEndBlocker(wrapEndBlocker(app, blockTime)) + + for _, opt := range opts { + opt(app) + } + return app } }