Skip to content

Commit 407b2a2

Browse files
authored
retry LINK token deployment (#1503)
1 parent 44afa4e commit 407b2a2

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

integration-tests/devenv/products/solana/configurator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ func (m *Configurator) ConfigureJobsAndContracts(
186186
if err := sg.DeployLinkToken(); err != nil {
187187
return fmt.Errorf("failed to deploy link token: %w", err)
188188
}
189+
if sg.LinkAddress == "" || sg.VaultAddress == "" {
190+
return fmt.Errorf("deploy link token returned empty addresses: link=%q vault=%q", sg.LinkAddress, sg.VaultAddress)
191+
}
189192

190193
if err := sg.G.WriteNetworkConfigVar(sg.NetworkFilePath, "PROGRAM_ID_OCR2", cfg.ProgramAddresses.OCR2); err != nil {
191194
return fmt.Errorf("failed to write PROGRAM_ID_OCR2: %w", err)

integration-tests/gauntlet/gauntlet_solana.go

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"os"
7+
"time"
78

89
ocr2_config "github.com/smartcontractkit/chainlink-solana/integration-tests/config"
910

@@ -143,6 +144,26 @@ func (sg *SolanaGauntlet) exec(args []string, options gauntlet.ExecCommandOption
143144
return out, err
144145
}
145146

147+
func (sg *SolanaGauntlet) execWithRetries(args []string, options gauntlet.ExecCommandOptions) (string, error) {
148+
updatedArgs := []string{"--cwd", sg.Dir, sg.G.Command, args[0], sg.G.Flag("network", sg.G.Network)}
149+
if len(args) > 1 {
150+
updatedArgs = append(updatedArgs, args[1:]...)
151+
}
152+
153+
if options.RetryCount == 0 {
154+
options.RetryCount = 4
155+
}
156+
if options.RetryDelay == 0 {
157+
options.RetryDelay = 2 * time.Second
158+
}
159+
160+
out, err := sg.G.ExecCommandWithRetries(updatedArgs, options)
161+
if err != nil {
162+
err = fmt.Errorf("%w\ngauntlet command: %s\nstdout: %s", err, updatedArgs, out)
163+
}
164+
return out, err
165+
}
166+
146167
func (sg *SolanaGauntlet) InitializeAccessController() (string, error) {
147168
_, err := sg.exec([]string{"access_controller:initialize"}, *sg.options)
148169
if err != nil {
@@ -156,14 +177,26 @@ func (sg *SolanaGauntlet) InitializeAccessController() (string, error) {
156177
}
157178

158179
func (sg *SolanaGauntlet) DeployLinkToken() error {
159-
_, err := sg.exec([]string{"token:deploy"}, *sg.options)
180+
opts := *sg.options
181+
opts.RetryCount = 4
182+
opts.RetryDelay = 2 * time.Second
183+
184+
_, err := sg.execWithRetries([]string{"token:deploy"}, opts)
160185
if err != nil {
161186
return err
162187
}
163188
sg.gr, err = sg.FetchGauntletJSONOutput()
164189
if err != nil {
165190
return err
166191
}
192+
193+
if sg.gr.Data.Vault == nil || *sg.gr.Data.Vault == "" {
194+
return fmt.Errorf("token:deploy succeeded but vault address missing in report.json")
195+
}
196+
if len(sg.gr.Responses) == 0 || sg.gr.Responses[0].Contract == "" {
197+
return fmt.Errorf("token:deploy succeeded but link token address missing in report.json")
198+
}
199+
167200
sg.VaultAddress = *sg.gr.Data.Vault
168201
sg.LinkAddress = sg.gr.Responses[0].Contract
169202

0 commit comments

Comments
 (0)