@@ -14,6 +14,9 @@ import (
14
14
"github.com/celestiaorg/go-square/v2/share"
15
15
tastoradocker "github.com/celestiaorg/tastora/framework/docker"
16
16
"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"
17
20
"github.com/celestiaorg/tastora/framework/testutil/sdkacc"
18
21
tastoratypes "github.com/celestiaorg/tastora/framework/types"
19
22
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -23,7 +26,6 @@ import (
23
26
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
24
27
dockerclient "github.com/moby/moby/client"
25
28
"github.com/stretchr/testify/suite"
26
- "go.uber.org/zap/zaptest"
27
29
)
28
30
29
31
const (
@@ -49,48 +51,21 @@ func TestDockerSuite(t *testing.T) {
49
51
50
52
type DockerTestSuite struct {
51
53
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
56
57
dockerClient * dockerclient.Client
57
58
dockerNetworkID string
58
59
}
59
60
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 () {
65
63
t := s .T ()
66
64
client , network := tastoradocker .DockerSetup (t )
67
65
68
66
// Store client and network ID in the suite for later use
69
67
s .dockerClient = client
70
68
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 )
94
69
}
95
70
96
71
// getGenesisHash returns the genesis hash of the given chain node.
@@ -108,23 +83,23 @@ func (s *DockerTestSuite) getGenesisHash(ctx context.Context) string {
108
83
return genesisHash
109
84
}
110
85
111
- // SetupDockerResources creates a new provider and chain using the given configuration options .
86
+ // SetupDockerResources creates chains using the builder pattern .
112
87
// 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 ( )
115
90
s .celestia = s .CreateChain ()
116
91
s .daNetwork = s .CreateDANetwork ()
117
92
s .evNodeChain = s .CreateEvolveChain ()
118
93
}
119
94
120
95
// CreateChain creates a chain using the ChainBuilder pattern.
121
- func (s * DockerTestSuite ) CreateChain () tastoratypes .Chain {
96
+ func (s * DockerTestSuite ) CreateChain () * cosmos .Chain {
122
97
ctx := context .Background ()
123
98
t := s .T ()
124
99
encConfig := testutil .MakeTestEncodingConfig (auth.AppModuleBasic {}, bank.AppModuleBasic {})
125
100
126
101
// Create chain using ChainBuilder pattern
127
- chain , err := tastoradocker .NewChainBuilder (t ).
102
+ chain , err := cosmos .NewChainBuilder (t ).
128
103
WithName ("celestia" ).
129
104
WithChainID (testChainID ).
130
105
WithBinaryName ("celestia-appd" ).
@@ -145,7 +120,7 @@ func (s *DockerTestSuite) CreateChain() tastoratypes.Chain {
145
120
).
146
121
WithDockerClient (s .dockerClient ).
147
122
WithDockerNetworkID (s .dockerNetworkID ).
148
- WithNode (tastoradocker .NewChainNodeConfigBuilder ().
123
+ WithNode (cosmos .NewChainNodeConfigBuilder ().
149
124
WithNodeType (tastoratypes .NodeTypeValidator ).
150
125
Build ()).
151
126
Build (ctx )
@@ -154,33 +129,56 @@ func (s *DockerTestSuite) CreateChain() tastoratypes.Chain {
154
129
return chain
155
130
}
156
131
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 {
159
134
ctx := context .Background ()
135
+ t := s .T ()
136
+
137
+ bridgeNodeConfig := da .NewNodeBuilder ().
138
+ WithNodeType (tastoratypes .BridgeNode ).
139
+ Build ()
160
140
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 )
162
147
s .Require ().NoError (err )
163
148
164
149
return daNetwork
165
150
}
166
151
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 {
169
154
ctx := context .Background ()
155
+ t := s .T ()
170
156
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 )
172
170
s .Require ().NoError (err )
173
171
174
- return rollkitChain
172
+ return evNodeChain
175
173
}
176
174
177
175
// 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 ) {
179
177
s .Require ().Equal (tastoratypes .BridgeNode , bridgeNode .GetType ())
180
178
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 (
184
182
map [string ]string {
185
183
"CELESTIA_CUSTOM" : tastoratypes .BuildCelestiaCustomEnvVar (chainID , genesisHash , "" ),
186
184
"P2P_NETWORK" : chainID ,
@@ -191,7 +189,7 @@ func (s *DockerTestSuite) StartBridgeNode(ctx context.Context, bridgeNode tastor
191
189
}
192
190
193
191
// 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 ) {
195
193
fromAddress , err := sdkacc .AddressFromWallet (s .celestia .GetFaucetWallet ())
196
194
s .Require ().NoError (err )
197
195
@@ -203,53 +201,37 @@ func (s *DockerTestSuite) FundWallet(ctx context.Context, wallet tastoratypes.Wa
203
201
s .Require ().NoError (err )
204
202
}
205
203
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" )
227
207
}
228
208
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 )
232
212
s .Require ().NoError (err )
233
213
234
- bridgeNodeHostName , err := bridgeNode .GetInternalHostName ( )
214
+ bridgeNetworkInfo , err := bridgeNode .GetNetworkInfo ( ctx )
235
215
s .Require ().NoError (err )
236
216
237
217
authToken , err := bridgeNode .GetAuthToken ()
238
218
s .Require ().NoError (err )
239
219
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 ,
247
229
"--kv-endpoint" , "0.0.0.0:8080" ,
248
230
)
249
231
s .Require ().NoError (err )
250
232
}
251
233
252
- // getEvNodeImage returns the Docker image configuration for Rollkit
234
+ // getEvNodeImage returns the Docker image configuration for EV Node
253
235
// Uses EV_NODE_IMAGE_REPO and EV_NODE_IMAGE_TAG environment variables if set
254
236
// Defaults to locally built image using a unique tag to avoid registry conflicts
255
237
func getEvNodeImage () container.Image {
0 commit comments