Skip to content

Commit 5ee6609

Browse files
fix(sui): allocate freeport to sui node (#271)
Previously sui node always occupy port 9000 on the host because there was no way to customize it. Since then i have made [a change in CTF](smartcontractkit/chainlink-testing-framework#2044) to allow that ability. JIRA: https://smartcontract-it.atlassian.net/browse/CLD-500
1 parent a62f470 commit 5ee6609

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

chain/sui/provider/ctf_provider.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"strconv"
78
"sync"
89
"testing"
910
"time"
@@ -13,6 +14,7 @@ import (
1314
chain_selectors "github.com/smartcontractkit/chain-selectors"
1415
"github.com/smartcontractkit/chainlink-testing-framework/framework"
1516
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
17+
"github.com/smartcontractkit/freeport"
1618
"github.com/stretchr/testify/require"
1719
"github.com/testcontainers/testcontainers-go"
1820

@@ -154,17 +156,20 @@ func (p *CTFChainProvider) startContainer(
154156
}
155157

156158
result, err := retry.DoWithData(func() (containerResult, error) {
157-
// NOTE: Sui blockchain containers use hardcoded ports (9000/9123) and ignore the Port field
159+
port := freeport.GetOne(p.t)
160+
158161
input := &blockchain.Input{
159162
Image: "", // filled out by defaultSui function
160163
Type: blockchain.TypeSui,
161164
ChainID: chainID,
162165
PublicKey: address,
163-
// Port field is ignored by Sui containers - they always use ports 9000/9123
166+
Port: strconv.Itoa(port),
164167
}
165168

166169
output, rerr := blockchain.NewBlockchainNetwork(input)
167170
if rerr != nil {
171+
// Return the ports to freeport to avoid leaking them during retries
172+
freeport.Return([]int{port})
168173
return containerResult{}, rerr
169174
}
170175

@@ -179,8 +184,11 @@ func (p *CTFChainProvider) startContainer(
179184
retry.Attempts(attempts),
180185
retry.Delay(1*time.Second),
181186
retry.DelayType(retry.FixedDelay),
187+
retry.OnRetry(func(attempt uint, err error) {
188+
p.t.Logf("Attempt %d/%d: Failed to start CTF Sui container: %v", attempt+1, attempts, err)
189+
}),
182190
)
183-
require.NoError(p.t, err)
191+
require.NoError(p.t, err, "Failed to start CTF Sui container after %d attempts", attempts)
184192

185193
url = result.url
186194
containerName = result.containerName

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250425195105-d9eabb4a4519
2222
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20250808121824-2c3544aab8f3
2323
github.com/smartcontractkit/chainlink-protos/job-distributor v0.12.0
24-
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.9
24+
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.12
2525
github.com/smartcontractkit/chainlink-testing-framework/seth v1.51.2
2626
github.com/smartcontractkit/chainlink-tron/relayer v0.0.11-0.20250422175525-b7575d96bd4d
2727
github.com/smartcontractkit/freeport v0.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20250808121824-2c3
657657
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20250808121824-2c3544aab8f3/go.mod h1:3Lsp38qxen9PABVF+O5eocveQev+hyo9HLAgRodBD4Q=
658658
github.com/smartcontractkit/chainlink-protos/job-distributor v0.12.0 h1:/bhoALRzNXZkdzxBkNM505pMofNy0K0eW1nCzXw+AUI=
659659
github.com/smartcontractkit/chainlink-protos/job-distributor v0.12.0/go.mod h1:/dVVLXrsp+V0AbcYGJo3XMzKg3CkELsweA/TTopCsKE=
660-
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.9 h1:0IJFn61lpb3XE+n9q80Q2JuEXc8HI1FfXc9sZUJ8qBg=
661-
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.9/go.mod h1:47sm4C5wBxR8VBAZoDRGSt5wJwDJN3vVeE36l5vQs1g=
660+
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.12 h1:vITyX8uIoUjMGwJXbgE8Cl01oO+5QpbOAVut69Wi9Sc=
661+
github.com/smartcontractkit/chainlink-testing-framework/framework v0.10.12/go.mod h1:gdW2dlrvHcTawMCtAIXQYZcZ9Ggx16L55kA7wONvzJ4=
662662
github.com/smartcontractkit/chainlink-testing-framework/seth v1.51.2 h1:ZJ/8Jx6Be5//TyjPi1pS1uotnmcYq5vVkSyISIymSj8=
663663
github.com/smartcontractkit/chainlink-testing-framework/seth v1.51.2/go.mod h1:kHYJnZUqiPF7/xN5273prV+srrLJkS77GbBXHLKQpx0=
664664
github.com/smartcontractkit/chainlink-tron/relayer v0.0.11-0.20250422175525-b7575d96bd4d h1:Yc1iLWCbgYHJAVrnMfNEVwSspk+dG/yxYmGbz0jeXw8=

0 commit comments

Comments
 (0)