github.com/celestiaorg/celestia-node@v0.15.0-beta.1/nodebuilder/tests/swamp/config.go (about)

     1  package swamp
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/celestiaorg/celestia-app/test/util/testnode"
     7  
     8  	"github.com/celestiaorg/celestia-node/core"
     9  )
    10  
    11  // DefaultConfig creates a celestia-app instance with a block time of around
    12  // 100ms
    13  func DefaultConfig() *testnode.Config {
    14  	cfg := core.DefaultTestConfig()
    15  	// timeout commit lower than this tend to be flakier
    16  	cfg.TmConfig.Consensus.TimeoutCommit = 200 * time.Millisecond
    17  	return cfg
    18  }
    19  
    20  // Option for modifying Swamp's Config.
    21  type Option func(*testnode.Config)
    22  
    23  // WithBlockTime sets a custom interval for block creation.
    24  func WithBlockTime(t time.Duration) Option {
    25  	return func(c *testnode.Config) {
    26  		// for empty block
    27  		c.TmConfig.Consensus.CreateEmptyBlocksInterval = t
    28  		// for filled block
    29  		c.TmConfig.Consensus.TimeoutCommit = t
    30  		c.TmConfig.Consensus.SkipTimeoutCommit = false
    31  	}
    32  }