Skip to content

Commit f3a2a36

Browse files
authored
chore: adjustments to sui CTF container loading in the test engine (#586)
This commit updates the sui CTF container loading in the test engine to use a random Ed25519 private key for the deployer signer rather than a fixed one. This also adjusts the container image and platform to the latest devnet image and platform, rather than using the default provided by CTF.
1 parent 6634b58 commit f3a2a36

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

.changeset/slimy-ducks-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chainlink-deployments-framework": minor
3+
---
4+
5+
Updates Test Engine Sui container to use a specific devnet image and generate different deploy keys for each container

engine/test/onchain/sui.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
package onchain
33

44
import (
5+
"crypto/ed25519"
6+
"crypto/rand"
7+
"encoding/hex"
8+
"fmt"
59
"testing"
610

711
chainselectors "github.com/smartcontractkit/chain-selectors"
@@ -12,8 +16,15 @@ import (
1216

1317
// NewSuiContainerLoader creates a new Sui chain loader with default configuration using CTF.
1418
func NewSuiContainerLoader() *ChainLoader {
15-
// testPrivateKey is a valid Sui Ed25519 private key for testing purposes (32 bytes, 64 hex chars)
16-
testPrivateKey := "E4FD0E90D32CB98DC6AD64516A421E8C2731870217CDBA64203CEB158A866304"
19+
// Generate a random Sui Ed25519 private key for testing
20+
seeded := ed25519.NewKeyFromSeed(suiRandomSeed()) // 64 bytes: seed||pub
21+
seed := seeded[:32] // or: seeded.Seed() if available
22+
testPrivateKey := hex.EncodeToString(seed) // 64 hex chars
23+
24+
var (
25+
suiContainerImage = "mysten/sui-tools:devnet"
26+
suiContainerPlatform = "linux/amd64"
27+
)
1728

1829
return &ChainLoader{
1930
selectors: getTestSelectorsByFamily(chainselectors.FamilySui),
@@ -23,7 +34,20 @@ func NewSuiContainerLoader() *ChainLoader {
2334
return suiprov.NewCTFChainProvider(t, selector, suiprov.CTFChainProviderConfig{
2435
Once: once,
2536
DeployerSignerGen: suiprov.AccountGenPrivateKey(testPrivateKey),
37+
Image: &suiContainerImage,
38+
Platform: &suiContainerPlatform,
2639
}).Initialize(t.Context())
2740
},
2841
}
2942
}
43+
44+
// randomSeed generates a random seed for the Sui Ed25519 private key.
45+
func suiRandomSeed() []byte {
46+
seed := make([]byte, ed25519.SeedSize)
47+
_, err := rand.Read(seed)
48+
if err != nil {
49+
panic(fmt.Sprintf("failed to generate random seed: %+v", err)) // This should never happen unless using a legacy Linux system
50+
}
51+
52+
return seed
53+
}

0 commit comments

Comments
 (0)