diff --git a/integration-tests/common/gauntlet_plus_plus_common.go b/integration-tests/common/gauntlet_plus_plus_common.go index bf002d0d..e0dafe71 100644 --- a/integration-tests/common/gauntlet_plus_plus_common.go +++ b/integration-tests/common/gauntlet_plus_plus_common.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "os" - + "github.com/smartcontractkit/chainlink-starknet/integration-tests/utils" ) diff --git a/integration-tests/common/test_common.go b/integration-tests/common/test_common.go index f3f706f7..3905451a 100644 --- a/integration-tests/common/test_common.go +++ b/integration-tests/common/test_common.go @@ -242,7 +242,7 @@ func (m *OCRv2TestState) DeployCluster() { func (m *OCRv2TestState) StartGppWithoutNetwork() { gpp := test_env_gauntlet.NewGauntletPlusPlus([]string{}, *m.Common.TestConfig.Common.GauntletPlusPlusImage) url, err := gpp.StartContainer() - m.TestConfig.TestConfig.Common.GauntletPlusPlusUrl = url + m.TestConfig.TestConfig.Common.GauntletPlusPlusURL = url require.NoError(m.TestConfig.T, err) } @@ -250,7 +250,7 @@ func (m *OCRv2TestState) StartGppWithoutNetwork() { func (m *OCRv2TestState) StartGppWithNetwork(networkName string) { gpp := test_env_gauntlet.NewGauntletPlusPlus([]string{networkName}, *m.Common.TestConfig.Common.GauntletPlusPlusImage) url, err := gpp.StartContainer() - m.TestConfig.TestConfig.Common.GauntletPlusPlusUrl = url + m.TestConfig.TestConfig.Common.GauntletPlusPlusURL = url require.NoError(m.TestConfig.T, err) } @@ -289,7 +289,6 @@ func (m *OCRv2TestState) LoadOCR2Config() (*ops.OCR2Config, error) { func (m *OCRv2TestState) removeOCR2PrefixAndAddPrefix(k string, prefix string, newPrefix string) string { // Print k for debugging before the modification if strings.HasPrefix(k, prefix) { - fmt.Println("After:", newPrefix+k[len(prefix):]) return newPrefix + k[len(prefix):] } diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index 5f8c6ceb..d186383f 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -75,7 +75,7 @@ func TestOCRBasic(t *testing.T) { state.DeployCluster() // Setting up G++ Client rpcURL := state.Common.RPCDetails.RPCL2Internal - gppURL := state.TestConfig.TestConfig.Common.GauntletPlusPlusUrl + gppURL := state.TestConfig.TestConfig.Common.GauntletPlusPlusURL state.Clients.GauntletPPClient, err = gauntlet.NewStarknetGauntletPlusPlus(gppURL, rpcURL, state.Account.Account, state.Account.PrivateKey) require.NoError(t, err, "Setting up gauntlet++ should not fail") diff --git a/integration-tests/soak/ocr2_test.go b/integration-tests/soak/ocr2_test.go index c787bca9..a6f0bf90 100644 --- a/integration-tests/soak/ocr2_test.go +++ b/integration-tests/soak/ocr2_test.go @@ -80,7 +80,7 @@ func TestOCRBasicSoak(t *testing.T) { // Setting up G++ Client rpcURL := state.Common.RPCDetails.RPCL2Internal - gppURL := state.TestConfig.TestConfig.Common.GauntletPlusPlusUrl + gppURL := state.TestConfig.TestConfig.Common.GauntletPlusPlusURL state.Clients.GauntletPPClient, err = gauntlet.NewStarknetGauntletPlusPlus(gppURL, rpcURL, state.Account.Account, state.Account.PrivateKey) require.NoError(t, err, "Setting up gauntlet++ should not fail") diff --git a/integration-tests/testconfig/testconfig.go b/integration-tests/testconfig/testconfig.go index c5c629e4..ddb0559c 100644 --- a/integration-tests/testconfig/testconfig.go +++ b/integration-tests/testconfig/testconfig.go @@ -192,7 +192,7 @@ type Common struct { DevnetImage *string `toml:"devnet_image"` GauntletPlusPlusImage *string `toml:"gauntlet_plus_plus_image"` PostgresVersion *string `toml:"postgres_version"` - GauntletPlusPlusUrl string + GauntletPlusPlusURL string } func (c *Common) Validate() error { diff --git a/ops/gauntlet/gauntlet_plus_plus_starknet.go b/ops/gauntlet/gauntlet_plus_plus_starknet.go index a54b2e4a..6437309d 100644 --- a/ops/gauntlet/gauntlet_plus_plus_starknet.go +++ b/ops/gauntlet/gauntlet_plus_plus_starknet.go @@ -95,12 +95,11 @@ func NewStarknetGauntletPlusPlus(gauntletPPEndpoint string, rpcURL string, addre func (sgpp *StarknetGauntletPlusPlus) ExtractValueFromResponseBody(report g.Report, key string) (string, error) { if report.Output != nil { // Log the raw content of Output - outputJSON, err := json.Marshal(report.Output) + _, err := json.Marshal(report.Output) if err != nil { log.Error().Err(err).Msg("Failed to marshal report.Output") return "", err } - log.Info().Str("Report.Output", string(outputJSON)).Msg("Gauntlet++") // Attempt to assert the Output as a map if outputMap, ok := (*report.Output).(map[string]interface{}); ok { @@ -110,9 +109,10 @@ func (sgpp *StarknetGauntletPlusPlus) ExtractValueFromResponseBody(report g.Repo // Assert value to a string if strValue, ok := value.(string); ok { return strValue, nil - } + } else { err := fmt.Errorf("parsed Value is not of type string") return "", err + } } } else { // Log a message if it’s not a map @@ -140,23 +140,48 @@ func (sgpp *StarknetGauntletPlusPlus) BuildRequestBody(request Request) *g.PostE } func (sgpp *StarknetGauntletPlusPlus) execute(request *Request) error { - body := sgpp.BuildRequestBody(*request) + report, err := sgpp.executeReturnsReport(request) - tmp, err := json.Marshal(body) - if err != nil { - return err // Handle marshaling error - } - - // Show request body - log.Info().Str("Request Body: ", string(tmp)).Msg("Gauntlet++") - headers := &g.PostExecuteParams{} - response, err := sgpp.client.PostExecuteWithResponse(context.Background(), headers, *body) if err != nil { return err // Handle post execution error } - // Show Response Status - log.Info().Str("Response Status:", response.Status()).Msg("Gauntlet++") + if report.Output != nil { + _, err := json.Marshal(report.Output) + if err != nil { + log.Error().Err(err).Msg("Failed to marshal report.Output") + return err + } + + // Attempt to assert the Output as a map + if outputMap, ok := (*report.Output).(map[string]interface{}); ok { + log.Info().Interface("Report Response: ", outputMap).Msg("Gauntlet++") + + // Access the 'output' field and then the 'receipt' field + if output, exists := outputMap["receipt"]; exists { + if receiptMap, ok := output.(map[string]interface{}); ok { + log.Info().Interface("Receipt Map: ", receiptMap).Msg("Gauntlet++") + // Access 'execution_status' inside the 'receipt' field + if executionStatus, exists := receiptMap["execution_status"]; exists { + + // Assert value to a string + if strExecutionStatus, ok := executionStatus.(string); ok { + if strExecutionStatus != "SUCCEEDED" { + err := fmt.Errorf("Op was not successful") + return err + } + } else { + err := fmt.Errorf("execution_status is not of type string") + return err + } + } + } + } + } else { + // Log a message if it’s not a map + log.Warn().Msg("Report.Output is not a map[string]interface{}") + } + } return nil } @@ -208,6 +233,11 @@ func (sgpp *StarknetGauntletPlusPlus) executeDeploy(request *Request) (string, e return "", err } + if contractAddress == "" { + log.Err(err).Str("G++ Deploy Requets returned with empty contractAddress", err.Error()).Msg("Gauntlet++") + return "", err + } + log.Info().Str("Contract Address Response: ", contractAddress).Msg("Gauntlet++") return contractAddress, nil }