8000 test: add basic docker E2E which writes headers to DA network by chatton · Pull Request #2378 · rollkit/rollkit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: add basic docker E2E which writes headers to DA network #2378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 19, 2025
Merged
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
14 changes: 12 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,25 @@
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ github.repository_owner }}/rollkit:${{ inputs.image-tag }}

upgrade-tests:
docker-tests:
name: Docker E2E Tests
needs: build-docker-image
runs-on: ubuntu-latest
steps:
- run: exit 0 # TODO: add upgrade test uses the image built in the build-docker-image step
- uses: actions/checkout@v4
- name: set up go
uses: actions/setup-go@v5
with:
go-version-file: ./test/docker-e2e/go.mod
- name: Run Docker E2E Tests
run: make test-docker-e2e
env:
ROLLKIT_IMAGE_TAG: ${{ inputs.image-tag }}

build_all-apps:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Build All Rollkit Binaries
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ proto/tendermint
types/pb/tendermint
.vscode/launch.json
.vscode/settings.json
vendor
*/**.html
*.idea
*.env
Expand Down
5 changes: 5 additions & 0 deletions scripts/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ test-cover:
test-evm:
@echo "--> Running EVM tests"
@cd execution/evm && go test -mod=readonly -failfast -timeout=15m ./... -tags=evm

## test-docker-e2e: Running Docker E2E tests
test-docker-e2e:
@echo "--> Running Docker E2E tests"
@cd test/docker-e2e && go test -mod=readonly -failfast -timeout=30m ./...
9 changes: 9 additions & 0 deletions scripts/test_cover.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import (
"os"
"os/exec"
"path/filepath"
"slices"
"strings"
)

func main() {
rootDir := "."

excludeDirs := []string{filepath.ToSlash("test/docker-e2e")}

var coverFiles []string
var testFailures bool

Expand All @@ -37,6 +41,11 @@ func main() {
fullCoverProfilePath := filepath.Join(modDir, "cover.out")
relativeCoverProfileArg := "cover.out"

if slices.Contains(excludeDirs, modDir) {
fmt.Printf("--> Skipping tests in: %s\n as they are marked as excluded", modDir)
return nil
}

fmt.Printf("--> Running tests with coverage in: %s (profile: %s)\n", modDir, relativeCoverProfileArg)
cmd := exec.Command("go", "test", "./...", "-race", "-coverprofile="+relativeCoverProfileArg, "-covermode=atomic")
cmd.Dir = modDir
Expand Down
44 changes: 44 additions & 0 deletions test/docker-e2e/base_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package docker_e2e

import (
"context"
"github.com/celestiaorg/tastora/framework/types"
"testing"
)

func (s *DockerTestSuite) TestBasicDockerE2E() {
ctx := context.Background()
s.SetupDockerResources()

var (
bridgeNode types.DANode
)

s.T().Run("start celestia chain", func(t *testing.T) {
err := s.celestia.Start(ctx)
s.Require().NoError(err)
})

s.T().Run("start bridge node", func(t *testing.T) {
genesisHash := s.getGenesisHash(ctx)

celestiaNodeHostname, err := s.celestia.GetNodes()[0].GetInternalHostName(ctx)
s.Require().NoError(err)

bridgeNode = s.daNetwork.GetBridgeNodes()[0]

s.StartBridgeNode(ctx, bridgeNode, testChainID, genesisHash, celestiaNodeHostname)
})

s.T().Run("fund da wallet", func(t *testing.T) {
daWallet, err := bridgeNode.GetWallet()
s.Require().NoError(err)
s.T().Logf("da node celestia address: %s", daWallet.GetFormattedAddress())

s.FundWallet(ctx, daWallet, 100_000_000_00)
})

s.T().Run("start rollkit chain node", func(t *testing.T) {
s.StartRollkitNode(ctx, bridgeNode, s.rollkitChain.GetNodes()[0])
})
}
270 changes: 270 additions & 0 deletions test/docker-e2e/docker_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
package docker_e2e

import (
"context"
"cosmossdk.io/math"
"encoding/hex"
"fmt"
"github.com/celestiaorg/go-square/v2/share"
tastoradocker "github.com/celestiaorg/tastora/framework/docker"
"github.com/celestiaorg/tastora/framework/testutil/sdkacc"
"github.com/celestiaorg/tastora/framework/testutil/toml"
tastoratypes "github.com/celestiaorg/tastora/framework/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/stretchr/testify/suite"
"go.uber.org/zap/zaptest"
"os"
"strings"
"testing"
)

const (
// testChainID is the chain ID used for testing.
// it must be the string "test" as it is handled explicitly in app/node.
testChainID = "test"
)

func init() {
sdkConf := sdk.GetConfig()
sdkConf.SetBech32PrefixForAccount("celestia", "celestiapub")
sdkConf.Seal()
}

func TestDockerSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping due to short mode")
}
suite.Run(t, new(DockerTestSuite))
}

type DockerTestSuite struct {
suite.Suite
provider tastoratypes.Provider
celestia tastoratypes.Chain
daNetwork tastoratypes.DataAvailabilityNetwork
rollkitChain tastoratypes.RollkitChain
}

// ConfigOption is a function type for modifying tastoradocker.Config
type ConfigOption func(*tastoradocker.Config)

// CreateDockerProvider creates a new tastoratypes.Provider with optional configuration modifications
func (s *DockerTestSuite) CreateDockerProvider(opts ...ConfigOption) tastoratypes.Provider {
t := s.T()
encConfig := testutil.MakeTestEncodingConfig(auth.AppModuleBasic{}, bank.AppModuleBasic{})
numValidators := 1
numFullNodes := 0
client, network := tastoradocker.DockerSetup(t)

cfg := tastoradocker.Config{
Logger: zaptest.NewLogger(t),
DockerClient: client,
DockerNetworkID: network,
ChainConfig: &tastoradocker.ChainConfig{
ConfigFileOverrides: map[string]any{
"config/app.toml": appOverrides(),
"config/config.toml": configOverrides(),
},
Type: "celestia",
Name: "celestia",
Version: "v4.0.0-rc6",
NumValidators: &numValidators,
NumFullNodes: &numFullNodes,
ChainID: testChainID,
Images: []tastoradocker.DockerImage{
{
Repository: "ghcr.io/celestiaorg/celestia-app",
Version: "v4.0.0-rc6",
UIDGID: "10001:10001",
},
},
Bin: "celestia-appd",
Bech32Prefix: "celestia",
Denom: "utia",
CoinType: "118",
GasPrices: "0.025utia",
GasAdjustment: 1.3,
EncodingConfig: &encConfig,
AdditionalStartArgs: []string{
"--force-no-bbr",
"--grpc.enable",
"--grpc.address",
"0.0.0.0:9090",
"--rpc.grpc_laddr=tcp://0.0.0.0:9098",
"--timeout-commit", "1s",
},
},
DataAvailabilityNetworkConfig: &tastoradocker.DataAvailabilityNetworkConfig{
BridgeNodeCount: 1,
Image: tastoradocker.DockerImage{
Repository: "ghcr.io/celestiaorg/celestia-node",
Version: "pr-4283",
Comment on lines +104 to +105
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has a fix which enables the signer type access wallets funded after initialization

UIDGID: "10001:10001",
},
},
RollkitChainConfig: &tastoradocker.RollkitChainConfig{
ChainID: "rollkit-test",
Bin: "testapp",
AggregatorPassphrase: "12345678",
NumNodes: 1,
Image: getRollkitImage(),
},
}

for _, opt := range opts {
opt(&cfg)
}

return tastoradocker.NewProvider(cfg, t)
}

// getGenesisHash returns the genesis hash of the given chain node.
func (s *DockerTestSuite) getGenesisHash(ctx context.Context) string {
node := s.celestia.GetNodes()[0]
c, err := node.GetRPCClient()
s.Require().NoError(err, "failed to get node client")

first := int64(1)
block, err := c.Block(ctx, &first)
s.Require().NoError(err, "failed to get block")

genesisHash := block.Block.Header.Hash().String()
s.Require().NotEmpty(genesisHash, "genesis hash is empty")
return genesisHash
}

// SetupDockerResources creates a new provider and chain using the given configuration options.
// none of the resources are started.
func (s *DockerTestSuite) SetupDockerResources(opts ...ConfigOption) {
s.provider = s.CreateDockerProvider(opts...)
s.celestia = s.CreateChain()
s.daNetwork = s.CreateDANetwork()
s.rollkitChain = s.CreateRollkitChain()
}

// CreateChain creates a chain using the provider.
func (s *DockerTestSuite) CreateChain() tastoratypes.Chain {
ctx := context.Background()

chain, err := s.provider.GetChain(ctx)
s.Require().NoError(err)

return chain
}

// CreateDANetwork creates a DA network using the provider
func (s *DockerTestSuite) CreateDANetwork() tastoratypes.DataAvailabilityNetwork {
ctx := context.Background()

daNetwork, err := s.provider.GetDataAvailabilityNetwork(ctx)
s.Require().NoError(err)

return daNetwork
}

// CreateRollkitChain creates a Rollkit chain using the provider
func (s *DockerTestSuite) CreateRollkitChain() tastoratypes.RollkitChain {
ctx := context.Background()

rollkitChain, err := s.provider.GetRollkitChain(ctx)
s.Require().NoError(err)

return rollkitChain
}

// StartBridgeNode initializes and starts a bridge node within the data availability network using the given parameters.
func (s *DockerTestSuite) StartBridgeNode(ctx context.Context, bridgeNode tastoratypes.DANode, chainID string, genesisHash string, celestiaNodeHostname string) {
s.Require().Equal(tastoratypes.BridgeNode, bridgeNode.GetType())
err := bridgeNode.Start(ctx,
tastoratypes.WithChainID(chainID),
tastoratypes.WithAdditionalStartArguments("--p2p.network", chainID, "--core.ip", celestiaNodeHostname, "--rpc.addr", "0.0.0.0"),
tastoratypes.WithEnvironmentVariables(
map[string]string{
"CELESTIA_CUSTOM": tastoratypes.BuildCelestiaCustomEnvVar(chainID, genesisHash, ""),
"P2P_NETWORK": chainID,
},
),
)
s.Require().NoError(err)
}

// FundWallet transfers the specified amount of utia from the faucet wallet to the target wallet.
func (s *DockerTestSuite) FundWallet(ctx context.Context, wallet tastoratypes.Wallet, amount int64) {
fromAddress, err := sdkacc.AddressFromWallet(s.celestia.GetFaucetWallet())
s.Require().NoError(err)

toAddress, err := sdk.AccAddressFromBech32(wallet.GetFormattedAddress())
s.Require().NoError(err)

bankSend := banktypes.NewMsgSend(fromAddress, toAddress, sdk.NewCoins(sdk.NewCoin("utia", math.NewInt(amount))))
_, err = s.celestia.BroadcastMessages(ctx, s.celestia.GetFaucetWallet(), bankSend)
s.Require().NoError(err)
}

// StartRollkitNode initializes and starts a Rollkit node.
func (s *DockerTestSuite) StartRollkitNode(ctx context.Context, bridgeNode tastoratypes.DANode, rollkitNode tastoratypes.RollkitNode) {
err := rollkitNode.Init(ctx)
s.Require().NoError(err)

bridgeNodeHostName, err := bridgeNode.GetInternalHostName()
s.Require().NoError(err)

authToken, err := bridgeNode.GetAuthToken()
s.Require().NoError(err)

daAddress := fmt.Sprintf("http://%s:26658", bridgeNodeHostName)
err = rollkitNode.Start(ctx,
"--rollkit.da.address", daAddress,
"--rollkit.da.gas_price", "0.025",
"--rollkit.da.auth_token", authToken,
"--rollkit.rpc.address", "0.0.0.0:7331", // bind to 0.0.0.0 so rpc is reachable from test host.
"--rollkit.da.namespace", generateValidNamespaceHex(),
)
s.Require().NoError(err)
}

// getRollkitImage returns the Docker image configuration for Rollkit
// Uses ROLLKIT_IMAGE_REPO and ROLLKIT_IMAGE_TAG environment variables if set
func getRollkitImage() tastoradocker.DockerImage {
repo := strings.TrimSpace(os.Getenv("ROLLKIT_IMAGE_REPO"))
if repo == "" {
repo = "ghcr.io/rollkit/rollkit"
}

tag := strings.TrimSpace(os.Getenv("ROLLKIT_IMAGE_TAG"))
if tag == "" {
tag = "latest"
}

return tastoradocker.DockerImage{
Repository: repo,
Version: tag,
UIDGID: "10001:10001",
}
}

func generateValidNamespaceHex() string {
return hex.EncodeToString(share.RandomBlobNamespaceID())
}

// appOverrides enables indexing of transactions so Broadcasting of transactions works
func appOverrides() toml.Toml {
return toml.Toml{
"tx-index": toml.Toml{
"indexer": "kv",
},
}
}

// configOverrides enables indexing of transactions so Broadcasting of transactions works
func configOverrides() toml.Toml {
return toml.Toml{
"tx_index": toml.Toml{
"indexer": "kv",
},
}
}
Loading
Loading
0