Skip to content

Commit

Permalink
nobuild optimization for running gauntlet within e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 committed May 22, 2024
1 parent cfbd935 commit 431889b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
1 change: 1 addition & 0 deletions gauntlet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"bin": "packages/gauntlet-solana-contracts/dist/cli.js",
"scripts": {
"gauntlet": "yarn build && node ./packages/gauntlet-solana-contracts/dist/cli.js",
"gauntlet-nobuild": "node ./packages/gauntlet-solana-contracts/dist/cli.js",
"gauntlet-serum-multisig": "yarn build && node ./packages/gauntlet-serum-multisig/dist/index.js",
"lint": "tsc -b ./tsconfig.json",
"eslint": "eslint -f json -o eslint-report.json ./packages || true",
Expand Down
56 changes: 35 additions & 21 deletions integration-tests/gauntlet/gauntlet_solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,31 @@ func (sg *SolanaGauntlet) InstallDependencies() error {
if err != nil {
return err
}
sg.G.Command = "gauntlet"
_, err = sg.G.ExecCommand([]string{"build"}, *sg.options) // initial build
if err != nil {
return err
}
sg.G.Command = "gauntlet-nobuild" // optimization to not rebuild packages each time
return nil
}

// exect is a custom wrapper to use custom set gauntlet command + error wrapping
func (sg *SolanaGauntlet) exec(args []string, options gauntlet.ExecCommandOptions) (string, error) {
updatedArgs := []string{sg.G.Command, args[0], sg.G.Flag("network", sg.G.Network)}
if len(args) > 1 {
updatedArgs = append(updatedArgs, args[1:]...)
}

out, err := sg.G.ExecCommand(updatedArgs, options)
// wrapping output into err if err present
if err != nil {
err = fmt.Errorf("%w\ngauntlet command: %s\nstdout: %s", err, updatedArgs, out)
}
return out, err
}

func (sg *SolanaGauntlet) InitializeAccessController() (string, error) {
_, err := sg.G.ExecCommand([]string{"access_controller:initialize"}, *sg.options)
_, err := sg.exec([]string{"access_controller:initialize"}, *sg.options)
if err != nil {
return "", err
}
Expand All @@ -138,7 +157,7 @@ func (sg *SolanaGauntlet) InitializeAccessController() (string, error) {
}

func (sg *SolanaGauntlet) DeployLinkToken() error {
_, err := sg.G.ExecCommand([]string{"token:deploy"}, *sg.options)
_, err := sg.exec([]string{"token:deploy"}, *sg.options)
if err != nil {
return err
}
Expand All @@ -153,7 +172,7 @@ func (sg *SolanaGauntlet) DeployLinkToken() error {
}

func (sg *SolanaGauntlet) InitializeStore(billingController string) (string, error) {
_, err := sg.G.ExecCommand([]string{"store:initialize", fmt.Sprintf("--accessController=%s", billingController)}, *sg.options)
_, err := sg.exec([]string{"store:initialize", fmt.Sprintf("--accessController=%s", billingController)}, *sg.options)
if err != nil {
return "", err
}
Expand All @@ -169,7 +188,7 @@ func (sg *SolanaGauntlet) StoreCreateFeed(length int, feedConfig *ocr2_config.St
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{"store:create_feed", fmt.Sprintf("--length=%d", length), fmt.Sprintf("--input=%v", string(config))}, *sg.options)
_, err = sg.exec([]string{"store:create_feed", fmt.Sprintf("--length=%d", length), fmt.Sprintf("--input=%v", string(config))}, *sg.options)
if err != nil {
return "", err
}
Expand All @@ -182,7 +201,7 @@ func (sg *SolanaGauntlet) StoreCreateFeed(length int, feedConfig *ocr2_config.St
}

func (sg *SolanaGauntlet) StoreSetValidatorConfig(feedAddress string, threshold int) (string, error) {
_, err := sg.G.ExecCommand([]string{"store:set_validator_config", fmt.Sprintf("--feed=%s", feedAddress), fmt.Sprintf("--threshold=%d", threshold)}, *sg.options)
_, err := sg.exec([]string{"store:set_validator_config", fmt.Sprintf("--feed=%s", feedAddress), fmt.Sprintf("--threshold=%d", threshold)}, *sg.options)
if err != nil {
return "", err
}
Expand All @@ -198,7 +217,7 @@ func (sg *SolanaGauntlet) InitializeOCR2(requesterAccessController string, billi
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:initialize",
fmt.Sprintf("--requesterAccessController=%s", requesterAccessController),
fmt.Sprintf("--billingAccessController=%s", billingAccessController),
Expand All @@ -219,7 +238,7 @@ func (sg *SolanaGauntlet) StoreSetWriter(storeConfig *ocr2_config.StoreWriterCon
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"store:set_writer",
fmt.Sprintf("--input=%v", string(config)),
ocrAddress,
Expand All @@ -243,7 +262,7 @@ func (sg *SolanaGauntlet) OCR2SetBilling(ocr2BillingConfig *ocr2_config.OCR2Bill
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:set_billing",
fmt.Sprintf("--input=%v", string(config)),
ocrAddress,
Expand All @@ -263,7 +282,7 @@ func (sg *SolanaGauntlet) OCR2SetBilling(ocr2BillingConfig *ocr2_config.OCR2Bill
}

func (sg *SolanaGauntlet) OCR2CreateProposal(version int) (string, error) {
_, err := sg.G.ExecCommand([]string{
_, err := sg.exec([]string{
"ocr2:create_proposal",
fmt.Sprintf("--version=%d", version),
},
Expand All @@ -286,7 +305,7 @@ func (sg *SolanaGauntlet) ProposeOnChainConfig(proposalID string, onChainConfig
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:propose_config",
fmt.Sprintf("--proposalId=%s", proposalID),
fmt.Sprintf("--input=%v", string(config)),
Expand All @@ -312,7 +331,7 @@ func (sg *SolanaGauntlet) ProposeOffChainConfig(proposalID string, offChainConfi
return "", err
}

_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:propose_offchain_config",
fmt.Sprintf("--proposalId=%s", proposalID),
fmt.Sprintf("--input=%v", string(config)),
Expand All @@ -338,7 +357,7 @@ func (sg *SolanaGauntlet) ProposePayees(proposalID string, payeesConfig ocr2_con
return "", err
}

_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:propose_payees",
fmt.Sprintf("--proposalId=%s", proposalID),
fmt.Sprintf("--input=%v", string(config)),
Expand All @@ -359,7 +378,7 @@ func (sg *SolanaGauntlet) ProposePayees(proposalID string, payeesConfig ocr2_con
}

func (sg *SolanaGauntlet) FinalizeProposal(proposalID string) (string, error) {
_, err := sg.G.ExecCommand([]string{
_, err := sg.exec([]string{
"ocr2:finalize_proposal",
fmt.Sprintf("--proposalId=%s", proposalID),
},
Expand All @@ -383,7 +402,7 @@ func (sg *SolanaGauntlet) AcceptProposal(proposalID string, secret string, propo
return "", err
}

_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:accept_proposal",
fmt.Sprintf("--proposalId=%s", proposalID),
fmt.Sprintf("--secret=%s", secret),
Expand All @@ -406,7 +425,7 @@ func (sg *SolanaGauntlet) AcceptProposal(proposalID string, secret string, propo

// FetchTransmissions returns the last 10 transmissions
func (sg *SolanaGauntlet) FetchTransmissions(ocrState string) ([]Transmission, error) {
_, err := sg.G.ExecCommand([]string{
_, err := sg.exec([]string{
"ocr2:inspect:responses",
ocrState,
},
Expand All @@ -426,11 +445,6 @@ func (sg *SolanaGauntlet) FetchTransmissions(ocrState string) ([]Transmission, e

func (sg *SolanaGauntlet) DeployOCR2() (string, error) {
var err error
err = sg.InstallDependencies()
if err != nil {
return "", err
}

sg.AccessControllerAddress, err = sg.InitializeAccessController()
if err != nil {
return "", err
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func TestSolanaOCRV2Smoke(t *testing.T) {

err = sg.SetupNetwork(gauntletConfig)
require.NoError(t, err, "Error setting gauntlet network")
err = sg.InstallDependencies()
require.NoError(t, err, "Error installing gauntlet dependencies")

if *config.Common.Network == "devnet" {
state.Common.ChainDetails.ProgramAddresses.OCR2 = *config.SolanaConfig.OCR2ProgramID
Expand Down

0 comments on commit 431889b

Please sign in to comment.