@@ -14,6 +14,9 @@ import (
1414 "github.com/celestiaorg/go-square/v2/share"
1515 tastoradocker "github.com/celestiaorg/tastora/framework/docker"
1616 "github.com/celestiaorg/tastora/framework/docker/container"
17+ "github.com/celestiaorg/tastora/framework/docker/cosmos"
18+ da "github.com/celestiaorg/tastora/framework/docker/dataavailability"
19+ "github.com/celestiaorg/tastora/framework/docker/evstack"
1720 "github.com/celestiaorg/tastora/framework/testutil/sdkacc"
1821 tastoratypes "github.com/celestiaorg/tastora/framework/types"
1922 sdk "github.com/cosmos/cosmos-sdk/types"
@@ -23,7 +26,6 @@ import (
2326 banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
2427 dockerclient "github.com/moby/moby/client"
2528 "github.com/stretchr/testify/suite"
26- "go.uber.org/zap/zaptest"
2729)
2830
2931const (
@@ -49,48 +51,21 @@ func TestDockerSuite(t *testing.T) {
4951
5052type DockerTestSuite struct {
5153 suite.Suite
52- provider tastoratypes.Provider
53- celestia tastoratypes.Chain
54- daNetwork tastoratypes.DataAvailabilityNetwork
55- evNodeChain tastoratypes.RollkitChain
54+ celestia * cosmos.Chain
55+ daNetwork * da.Network
56+ evNodeChain * evstack.Chain
5657 dockerClient * dockerclient.Client
5758 dockerNetworkID string
5859}
5960
60- // ConfigOption is a function type for modifying tastoradocker.Config
61- type ConfigOption func (* tastoradocker.Config )
62-
63- // CreateDockerProvider creates a new tastoratypes.Provider with optional configuration modifications
64- func (s * DockerTestSuite ) CreateDockerProvider (opts ... ConfigOption ) tastoratypes.Provider {
61+ // setupDockerEnvironment sets up the basic Docker environment
62+ func (s * DockerTestSuite ) setupDockerEnvironment () {
6563 t := s .T ()
6664 client , network := tastoradocker .DockerSetup (t )
6765
6866 // Store client and network ID in the suite for later use
6967 s .dockerClient = client
7068 s .dockerNetworkID = network
71-
72- cfg := tastoradocker.Config {
73- Logger : zaptest .NewLogger (t ),
74- DockerClient : client ,
75- DockerNetworkID : network ,
76- DataAvailabilityNetworkConfig : & tastoradocker.DataAvailabilityNetworkConfig {
77- BridgeNodeCount : 1 ,
78- Image : container .NewImage ("ghcr.io/celestiaorg/celestia-node" , "v0.25.3" , "10001:10001" ),
79- },
80- RollkitChainConfig : & tastoradocker.RollkitChainConfig {
81- ChainID : "rollkit-test" ,
82- Bin : "testapp" ,
83- AggregatorPassphrase : "12345678" ,
84- NumNodes : 1 ,
85- Image : getEvNodeImage (),
86- },
87- }
88-
89- for _ , opt := range opts {
90- opt (& cfg )
91- }
92-
93- return tastoradocker .NewProvider (cfg , t )
9469}
9570
9671// getGenesisHash returns the genesis hash of the given chain node.
@@ -108,23 +83,23 @@ func (s *DockerTestSuite) getGenesisHash(ctx context.Context) string {
10883 return genesisHash
10984}
11085
111- // SetupDockerResources creates a new provider and chain using the given configuration options .
86+ // SetupDockerResources creates chains using the builder pattern .
11287// none of the resources are started.
113- func (s * DockerTestSuite ) SetupDockerResources (opts ... ConfigOption ) {
114- s .provider = s . CreateDockerProvider ( opts ... )
88+ func (s * DockerTestSuite ) SetupDockerResources () {
89+ s .setupDockerEnvironment ( )
11590 s .celestia = s .CreateChain ()
11691 s .daNetwork = s .CreateDANetwork ()
11792 s .evNodeChain = s .CreateEvolveChain ()
11893}
11994
12095// CreateChain creates a chain using the ChainBuilder pattern.
121- func (s * DockerTestSuite ) CreateChain () tastoratypes .Chain {
96+ func (s * DockerTestSuite ) CreateChain () * cosmos .Chain {
12297 ctx := context .Background ()
12398 t := s .T ()
12499 encConfig := testutil .MakeTestEncodingConfig (auth.AppModuleBasic {}, bank.AppModuleBasic {})
125100
126101 // Create chain using ChainBuilder pattern
127- chain , err := tastoradocker .NewChainBuilder (t ).
102+ chain , err := cosmos .NewChainBuilder (t ).
128103 WithName ("celestia" ).
129104 WithChainID (testChainID ).
130105 WithBinaryName ("celestia-appd" ).
@@ -145,7 +120,7 @@ func (s *DockerTestSuite) CreateChain() tastoratypes.Chain {
145120 ).
146121 WithDockerClient (s .dockerClient ).
147122 WithDockerNetworkID (s .dockerNetworkID ).
148- WithNode (tastoradocker .NewChainNodeConfigBuilder ().
123+ WithNode (cosmos .NewChainNodeConfigBuilder ().
149124 WithNodeType (tastoratypes .NodeTypeValidator ).
150125 Build ()).
151126 Build (ctx )
@@ -154,33 +129,56 @@ func (s *DockerTestSuite) CreateChain() tastoratypes.Chain {
154129 return chain
155130}
156131
157- // CreateDANetwork creates a DA network using the provider
158- func (s * DockerTestSuite ) CreateDANetwork () tastoratypes. DataAvailabilityNetwork {
132+ // CreateDANetwork creates a DA network using the builder pattern
133+ func (s * DockerTestSuite ) CreateDANetwork () * da. Network {
159134 ctx := context .Background ()
135+ t := s .T ()
136+
137+ bridgeNodeConfig := da .NewNodeBuilder ().
138+ WithNodeType (tastoratypes .BridgeNode ).
139+ Build ()
160140
161- daNetwork , err := s .provider .GetDataAvailabilityNetwork (ctx )
141+ daNetwork , err := da .NewNetworkBuilder (t ).
142+ WithDockerClient (s .dockerClient ).
143+ WithDockerNetworkID (s .dockerNetworkID ).
144+ WithImage (container .NewImage ("ghcr.io/celestiaorg/celestia-node" , "v0.25.3" , "10001:10001" )).
145+ WithNode (bridgeNodeConfig ).
146+ Build (ctx )
162147 s .Require ().NoError (err )
163148
164149 return daNetwork
165150}
166151
167- // CreateEvolveChain creates a Rollkit chain using the provider
168- func (s * DockerTestSuite ) CreateEvolveChain () tastoratypes. RollkitChain {
152+ // CreateEvolveChain creates an evstack chain using the builder pattern
153+ func (s * DockerTestSuite ) CreateEvolveChain () * evstack. Chain {
169154 ctx := context .Background ()
155+ t := s .T ()
170156
171- rollkitChain , err := s .provider .GetRollkitChain (ctx )
157+ aggregatorNodeConfig := evstack .NewNodeBuilder ().
158+ WithAggregator (true ).
159+ Build ()
160+
161+ evNodeChain , err := evstack .NewChainBuilder (t ).
162+ WithChainID ("evchain-test" ).
163+ WithBinaryName ("testapp" ).
164+ WithAggregatorPassphrase ("12345678" ).
165+ WithImage (getEvNodeImage ()).
166+ WithDockerClient (s .dockerClient ).
167+ WithDockerNetworkID (s .dockerNetworkID ).
168+ WithNode (aggregatorNodeConfig ).
169+ Build (ctx )
172170 s .Require ().NoError (err )
173171
174- return rollkitChain
172+ return evNodeChain
175173}
176174
177175// StartBridgeNode initializes and starts a bridge node within the data availability network using the given parameters.
178- func (s * DockerTestSuite ) StartBridgeNode (ctx context.Context , bridgeNode tastoratypes. DANode , chainID string , genesisHash string , celestiaNodeHostname string ) {
176+ func (s * DockerTestSuite ) StartBridgeNode (ctx context.Context , bridgeNode * da. Node , chainID string , genesisHash string , celestiaNodeHostname string ) {
179177 s .Require ().Equal (tastoratypes .BridgeNode , bridgeNode .GetType ())
180178 err := bridgeNode .Start (ctx ,
181- tastoratypes .WithChainID (chainID ),
182- tastoratypes .WithAdditionalStartArguments ("--p2p.network" , chainID , "--core.ip" , celestiaNodeHostname , "--rpc.addr" , "0.0.0.0" ),
183- tastoratypes .WithEnvironmentVariables (
179+ da .WithChainID (chainID ),
180+ da .WithAdditionalStartArguments ("--p2p.network" , chainID , "--core.ip" , celestiaNodeHostname , "--rpc.addr" , "0.0.0.0" ),
181+ da .WithEnvironmentVariables (
184182 map [string ]string {
185183 "CELESTIA_CUSTOM" : tastoratypes .BuildCelestiaCustomEnvVar (chainID , genesisHash , "" ),
186184 "P2P_NETWORK" : chainID ,
@@ -191,7 +189,7 @@ func (s *DockerTestSuite) StartBridgeNode(ctx context.Context, bridgeNode tastor
191189}
192190
193191// FundWallet transfers the specified amount of utia from the faucet wallet to the target wallet.
194- func (s * DockerTestSuite ) FundWallet (ctx context.Context , wallet tastoratypes.Wallet , amount int64 ) {
192+ func (s * DockerTestSuite ) FundWallet (ctx context.Context , wallet * tastoratypes.Wallet , amount int64 ) {
195193 fromAddress , err := sdkacc .AddressFromWallet (s .celestia .GetFaucetWallet ())
196194 s .Require ().NoError (err )
197195
@@ -203,53 +201,37 @@ func (s *DockerTestSuite) FundWallet(ctx context.Context, wallet tastoratypes.Wa
203201 s .Require ().NoError (err )
204202}
205203
206- // StartEvNode initializes and starts an Ev node.
207- func (s * DockerTestSuite ) StartEvNode (ctx context.Context , bridgeNode tastoratypes.DANode , evNode tastoratypes.RollkitNode ) {
208- err := evNode .Init (ctx )
209- s .Require ().NoError (err )
210-
211- bridgeNodeHostName , err := bridgeNode .GetInternalHostName ()
212- s .Require ().NoError (err )
213-
214- authToken , err := bridgeNode .GetAuthToken ()
215- s .Require ().NoError (err )
216-
217- daAddress := fmt .Sprintf ("http://%s:26658" , bridgeNodeHostName )
218- err = evNode .Start (ctx ,
219- "--rollkit.da.address" , daAddress ,
220- "--rollkit.da.gas_price" , "0.025" ,
221- "--rollkit.da.auth_token" , authToken ,
222- "--rollkit.rpc.address" , "0.0.0.0:7331" , // bind to 0.0.0.0 so rpc is reachable from test host.
223- "--rollkit.da.namespace" , generateValidNamespaceHex (),
224- "--kv-endpoint" , "0.0.0.0:8080" ,
225- )
226- s .Require ().NoError (err )
204+ // StartEVNode initializes and starts an Ev node.
205+ func (s * DockerTestSuite ) StartEVNode (ctx context.Context , bridgeNode * da.Node , evNode * evstack.Node ) {
206+ s .StartEVNodeWithNamespace (ctx , bridgeNode , evNode , "ev-header" , "ev-data" )
227207}
228208
229- // StartRollkitNodeWithNamespace initializes and starts a Rollkit node with a specific namespace.
230- func (s * DockerTestSuite ) StartRollkitNodeWithNamespace (ctx context.Context , bridgeNode tastoratypes. DANode , rollkitNode tastoratypes. RollkitNode , namespace string ) {
231- err := rollkitNode .Init (ctx )
209+ // StartEVNodeWithNamespace initializes and starts an EV node with a specific namespace.
210+ func (s * DockerTestSuite ) StartEVNodeWithNamespace (ctx context.Context , bridgeNode * da. Node , evNode * evstack. Node , headerNamespace , dataNamespace string ) {
211+ err := evNode .Init (ctx )
232212 s .Require ().NoError (err )
233213
234- bridgeNodeHostName , err := bridgeNode .GetInternalHostName ( )
214+ bridgeNetworkInfo , err := bridgeNode .GetNetworkInfo ( ctx )
235215 s .Require ().NoError (err )
236216
237217 authToken , err := bridgeNode .GetAuthToken ()
238218 s .Require ().NoError (err )
239219
240- daAddress := fmt .Sprintf ("http://%s:26658" , bridgeNodeHostName )
241- err = rollkitNode .Start (ctx ,
242- "--rollkit.da.address" , daAddress ,
243- "--rollkit.da.gas_price" , "0.025" ,
244- "--rollkit.da.auth_token" , authToken ,
245- "--rollkit.rpc.address" , "0.0.0.0:7331" , // bind to 0.0.0.0 so rpc is reachable from test host.
246- "--rollkit.da.namespace" , namespace ,
220+ bridgeRPCAddress := bridgeNetworkInfo .Internal .RPCAddress ()
221+ daAddress := fmt .Sprintf ("http://%s" , bridgeRPCAddress )
222+ err = evNode .Start (ctx ,
223+ "--evnode.da.address" , daAddress ,
224+ "--evnode.da.gas_price" , "0.025" ,
225+ "--evnode.da.auth_token" , authToken ,
226+ "--evnode.rpc.address" , "0.0.0.0:7331" , // bind to 0.0.0.0 so rpc is reachable from test host.
227+ "--evnode.da.namespace" , headerNamespace ,
228+ "--evnode.da.data_namespace" , dataNamespace ,
247229 "--kv-endpoint" , "0.0.0.0:8080" ,
248230 )
249231 s .Require ().NoError (err )
250232}
251233
252- // getEvNodeImage returns the Docker image configuration for Rollkit
234+ // getEvNodeImage returns the Docker image configuration for EV Node
253235// Uses EV_NODE_IMAGE_REPO and EV_NODE_IMAGE_TAG environment variables if set
254236// Defaults to locally built image using a unique tag to avoid registry conflicts
255237func getEvNodeImage () container.Image {
0 commit comments