44 "context"
55 "fmt"
66 "path/filepath"
7+ "strings"
78
89 "github.com/docker/docker/api/types/container"
910 "github.com/testcontainers/testcontainers-go"
@@ -12,6 +13,11 @@ import (
1213 "github.com/smartcontractkit/chainlink-testing-framework/framework"
1314)
1415
16+ const (
17+ DefaultAptosAPIPort = "8080"
18+ DefaultAptosFaucetPort = "8081"
19+ )
20+
1521var (
1622 DefaultAptosAccount = "0xa337b42bd0eecf8fb59ee5929ea4541904b3c35a642040223f3d26ab57f59d6e"
1723 DefaultAptosPrivateKey = "0xd477c65f88ed9e6d4ec6e2014755c3cfa3e0c44e521d0111a02868c5f04c41d4"
@@ -21,11 +27,15 @@ func defaultAptos(in *Input) {
2127 if in .Image == "" {
2228 in .Image = "aptoslabs/tools:aptos-node-v1.27.2"
2329 }
24- framework .L .Warn ().Msg ("Aptos node API can only be exposed on port 8080!" )
30+ framework .L .Warn ().Msgf ("Aptos node API can only be exposed on port %s!" , DefaultAptosAPIPort )
31+ if in .Port == "" {
32+ // enable default API exposed port
33+ in .Port = DefaultAptosAPIPort
34+ }
2535 if in .CustomPorts == nil {
26- in .CustomPorts = append (in .CustomPorts , "8080:8080" , "8081:8081" )
36+ // enable default API and faucet forwarding
37+ in .CustomPorts = append (in .CustomPorts , fmt .Sprintf ("%s:%s" , in .Port , DefaultAptosAPIPort ), fmt .Sprintf ("%s:%s" , DefaultAptosFaucetPort , DefaultAptosFaucetPort ))
2738 }
28- in .Port = "8080"
2939}
3040
3141func newAptos (in * Input ) (* Output , error ) {
@@ -42,6 +52,7 @@ func newAptos(in *Input) (*Output, error) {
4252 if err != nil {
4353 return nil , err
4454 }
55+ exposedPorts = append (exposedPorts , in .Port )
4556
4657 cmd := []string {
4758 "aptos" ,
@@ -102,13 +113,20 @@ func newAptos(in *Input) (*Output, error) {
102113 if err != nil {
103114 return nil , err
104115 }
116+ // expose default API port if remapped
117+ var exposedAPIPort string
118+ for _ , portPair := range in .CustomPorts {
119+ if strings .Contains (portPair , fmt .Sprintf (":%s" , DefaultAptosAPIPort )) {
120+ exposedAPIPort = strings .Split (portPair , ":" )[0 ]
121+ }
122+ }
105123 return & Output {
106124 UseCache : true ,
107125 Family : "aptos" ,
108126 ContainerName : containerName ,
109127 Nodes : []* Node {
110128 {
111- ExternalHTTPUrl : fmt .Sprintf ("http://%s:%s" , host , in . Port ),
129+ ExternalHTTPUrl : fmt .Sprintf ("http://%s:%s" , host , exposedAPIPort ),
112130 InternalHTTPUrl : fmt .Sprintf ("http://%s:%s" , containerName , in .Port ),
113131 },
114132 },
0 commit comments