44 "context"
55 "fmt"
66 "os"
7+ "os/exec"
78 "time"
89
9- "github.com/docker/docker/api/types/network"
1010 "github.com/testcontainers/testcontainers-go"
1111 "github.com/testcontainers/testcontainers-go/wait"
1212
@@ -47,16 +47,15 @@ var (
4747)
4848
4949type containerTemplate struct {
50- Name string
51- Image string
52- Env map [string ]string
53- Mounts []testcontainers.ContainerMount
54- Ports []string
55- WaitFor wait.Strategy
56- Command []string
57- Network string
58- Alias string
59- EndpointSettingsModifier func (m map [string ]* network.EndpointSettings )
50+ Name string
51+ Image string
52+ Env map [string ]string
53+ Mounts []testcontainers.ContainerMount
54+ Ports []string
55+ WaitFor wait.Strategy
56+ Command []string
57+ Network string
58+ Alias string
6059}
6160
6261func commonContainer (
@@ -70,7 +69,6 @@ func commonContainer(
7069 command []string ,
7170 network string ,
7271 alias string ,
73- endpointModifier func (m map [string ]* network.EndpointSettings ),
7472) (testcontainers.Container , error ) {
7573 req := testcontainers.ContainerRequest {
7674 Name : name ,
@@ -83,9 +81,8 @@ func commonContainer(
8381 NetworkAliases : map [string ][]string {
8482 network : {alias },
8583 },
86- WaitingFor : waitStrategy ,
87- EndpointSettingsModifier : endpointModifier ,
88- Cmd : command ,
84+ WaitingFor : waitStrategy ,
85+ Cmd : command ,
8986 }
9087 return testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
9188 ContainerRequest : req ,
@@ -105,25 +102,24 @@ func newTon(in *Input) (*Output, error) {
105102 ctx := context .Background ()
106103
107104 networkName := "ton"
108- lightClientIP := "172.28.1.1"
109105 lightCLientSubNet := "172.28.0.0/16"
110- _ , err := testcontainers .GenericNetwork (ctx , testcontainers.GenericNetworkRequest {
111- NetworkRequest : testcontainers.NetworkRequest {
112- Name : networkName ,
113- Labels : framework .DefaultTCLabels (),
114- Driver : "bridge" ,
115- Attachable : true ,
116- IPAM : & network.IPAM {
117- Config : []network.IPAMConfig {
118- {Subnet : lightCLientSubNet },
119- },
120- },
121- },
122- })
106+
107+ cmd := exec .Command ("docker" , "network" , "create" ,
108+ "--driver=bridge" ,
109+ "--attachable" ,
110+ fmt .Sprintf ("--subnet=%s" , lightCLientSubNet ),
111+ "--label=framework=ctf" ,
112+ networkName ,
113+ )
114+
115+ output , err := cmd .CombinedOutput ()
123116 if err != nil {
124117 return nil , err
125118 }
126119
120+ fmt .Printf ("Network '%s' created successfully\n " , networkName )
121+ fmt .Println ("Command output:" , string (output ))
122+
127123 tonServices := []containerTemplate {
128124 {
129125 Image : "ghcr.io/neodix42/mylocalton-docker:latest" ,
@@ -139,11 +135,6 @@ func newTon(in *Input) (*Output, error) {
139135 }).WithStartupTimeout (2 * time .Minute ),
140136 Network : networkName ,
141137 Alias : "genesis" ,
142- EndpointSettingsModifier : func (m map [string ]* network.EndpointSettings ) {
143- m [networkName ].IPAMConfig = & network.EndpointIPAMConfig {
144- IPv4Address : lightClientIP ,
145- }
146- },
147138 Mounts : testcontainers.ContainerMounts {
148139 {
149140 Source : testcontainers.GenericVolumeMountSource {Name : "shared-data" },
@@ -289,7 +280,7 @@ func newTon(in *Input) (*Output, error) {
289280
290281 containers := make ([]testcontainers.Container , 0 )
291282 for _ , s := range tonServices {
292- c , err := commonContainer (ctx , s .Name , s .Image , s .Env , s .Mounts , s .Ports , s .WaitFor , s .Command , s .Network , s .Alias , s . EndpointSettingsModifier )
283+ c , err := commonContainer (ctx , s .Name , s .Image , s .Env , s .Mounts , s .Ports , s .WaitFor , s .Command , s .Network , s .Alias )
293284 if err != nil {
294285 return nil , fmt .Errorf ("failed to start %s: %v" , s .Name , err )
295286 }
@@ -298,7 +289,7 @@ func newTon(in *Input) (*Output, error) {
298289 // no need for indexers and block explorers in CI
299290 if os .Getenv ("CI" ) != "" {
300291 for _ , s := range tonIndexingAndObservability {
301- c , err := commonContainer (ctx , s .Name , s .Image , s .Env , s .Mounts , s .Ports , s .WaitFor , s .Command , s .Network , s .Alias , s . EndpointSettingsModifier )
292+ c , err := commonContainer (ctx , s .Name , s .Image , s .Env , s .Mounts , s .Ports , s .WaitFor , s .Command , s .Network , s .Alias )
302293 if err != nil {
303294 return nil , fmt .Errorf ("failed to start %s: %v" , s .Name , err )
304295 }
0 commit comments