-
Notifications
You must be signed in to change notification settings - Fork 53
/
data.go
64 lines (52 loc) · 1.53 KB
/
data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package docker
import (
"fmt"
"net"
"github.com/omni-network/omni/e2e/types"
"github.com/omni-network/omni/lib/errors"
e2e "github.com/cometbft/cometbft/test/e2e/pkg"
)
const (
ipPrefix = "10.186.73." // See github.com/cometbft/cometbft/test/e2e/pkg for reference
startIPSuffix = 100
startPort = 8000
)
var localhost = net.ParseIP("127.0.0.1") //nolint:gochecknoglobals // Static IP
// NewInfraData returns a new InfrastructureData for the given manifest.
// In addition to normal.
func NewInfraData(manifest types.Manifest) (types.InfrastructureData, error) {
infd, err := e2e.NewDockerInfrastructureData(manifest.Manifest)
if err != nil {
return types.InfrastructureData{}, errors.Wrap(err, "creating docker infrastructure data")
}
// IP generator
ipSuffix := startIPSuffix
nextInternalIP := func() net.IP {
defer func() { ipSuffix++ }()
return net.ParseIP(fmt.Sprintf(ipPrefix+"%d", ipSuffix))
}
// Port generator
port := startPort
nextPort := func() uint32 {
defer func() { port++ }()
return uint32(port)
}
for name := range manifest.OmniEVMs() {
infd.Instances[name] = e2e.InstanceData{
IPAddress: nextInternalIP(),
ExtIPAddress: localhost,
Port: nextPort(),
}
}
for _, name := range manifest.AnvilChains {
infd.Instances[name] = e2e.InstanceData{
IPAddress: nextInternalIP(),
ExtIPAddress: localhost,
Port: nextPort(),
}
}
// No IP for relayer required since it doesn't serve an API.
return types.InfrastructureData{
InfrastructureData: infd,
}, nil
}