Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions framework/docker/cosmos/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type Chain struct {
started bool
// skipInit indicates whether to skip initialization when starting
skipInit bool
// blockWaitTimeout is the timeout for waiting for blocks after starting the chain.
// If zero, defaults to 120 seconds.
blockWaitTimeout time.Duration
}

func (c *Chain) GetRelayerConfig() types.ChainRelayerConfig {
Expand Down Expand Up @@ -331,8 +334,11 @@ func (c *Chain) startAndInitializeNodes(ctx context.Context) error {
}

// Wait for blocks before considering the chains "started"
// Use a longer timeout for block waiting to handle slow chain startup
blockWaitCtx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
blockWaitTimeout := c.blockWaitTimeout
if blockWaitTimeout == 0 {
blockWaitTimeout = 120 * time.Second
}
blockWaitCtx, cancel := context.WithTimeout(ctx, blockWaitTimeout)
defer cancel()
if err := wait.ForBlocks(blockWaitCtx, 2, c.GetNode()); err != nil {
return err
Expand Down
17 changes: 15 additions & 2 deletions framework/docker/cosmos/chain_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path"
"testing"
"time"

"github.com/celestiaorg/tastora/framework/docker/container"
"github.com/celestiaorg/tastora/framework/types"
Expand Down Expand Up @@ -154,6 +155,9 @@ type ChainBuilder struct {
additionalExposedPorts []string
// skipInit indicates whether to skip node initialization on start (useful when reusing volumes)
skipInit bool
// blockWaitTimeout is the timeout for waiting for blocks after starting the chain.
// If zero, defaults to 120 seconds.
blockWaitTimeout time.Duration
}

// NewChainBuilder initializes and returns a new ChainBuilder with default values for testing purposes.
Expand Down Expand Up @@ -341,6 +345,14 @@ func (b *ChainBuilder) WithSkipInit(skip bool) *ChainBuilder {
return b
}

// WithBlockWaitTimeout sets the timeout for waiting for blocks after starting
// the chain. If not set, defaults to 120 seconds. Use a longer timeout for
// chains that need extra time to start (e.g. state sync nodes).
func (b *ChainBuilder) WithBlockWaitTimeout(timeout time.Duration) *ChainBuilder {
b.blockWaitTimeout = timeout
return b
}

// getImage returns the appropriate Docker image for a node, using node-specific override if available,
// otherwise falling back to the chain's default image
func (b *ChainBuilder) getImage(nodeConfig ChainNodeConfig) container.Image {
Expand Down Expand Up @@ -434,8 +446,9 @@ func (b *ChainBuilder) Build(ctx context.Context) (*Chain, error) {
FullNodes: fullNodes,
cdc: cdc,
log: b.logger,
faucetWallet: b.faucetWallet,
skipInit: b.skipInit,
faucetWallet: b.faucetWallet,
skipInit: b.skipInit,
blockWaitTimeout: b.blockWaitTimeout,
}

return chain, nil
Expand Down
Loading