Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smickovskid committed Feb 27, 2024
1 parent e849e64 commit 0a52985
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 43 deletions.
41 changes: 4 additions & 37 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
"os"
"os/exec"
"regexp"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -223,37 +222,6 @@ func (c *Common) TearDownLocalEnvironment(t *testing.T) {
log.Info().Msg("Tear down local stack complete.")
}

// connectChainlinkNodes creates a chainlink client for each node in the environment
// This is a non k8s version of the function in chainlink_k8s.go
// https://github.com/smartcontractkit/chainlink/blob/cosmos-test-keys/integration-tests/client/chainlink_k8s.go#L77
func connectChainlinkNodes(e *environment.Environment) ([]*client.ChainlinkClient, error) {
var clients []*client.ChainlinkClient
for _, nodeDetails := range e.ChainlinkNodeDetails {
c, err := client.NewChainlinkClient(&client.ChainlinkConfig{
URL: nodeDetails.LocalIP,
Email: "[email protected]",
Password: "fj293fbBnlQ!f9vNs",
InternalIP: parseHostname(nodeDetails.InternalIP),
}, log.Logger)
if err != nil {
return nil, err
}
log.Debug().
Str("URL", c.Config.URL).
Str("Internal IP", c.Config.InternalIP).
Str("Chart Name", nodeDetails.ChartName).
Str("Pod Name", nodeDetails.PodName).
Msg("Connected to Chainlink node")
clients = append(clients, c)
}
return clients, nil
}

func parseHostname(s string) string {
r := regexp.MustCompile(`://(?P<Host>.*):`)
return r.FindStringSubmatch(s)[1]
}

func (c *Common) CreateNodeKeysBundle(nodes []*client.ChainlinkClient) ([]client.NodeKeysBundle, error) {
nkb := make([]client.NodeKeysBundle, 0)
for _, n := range nodes {
Expand Down Expand Up @@ -295,8 +263,8 @@ func (c *Common) CreateJobsForContract(cc *ChainlinkClient, observationSource st
// Defining relay config
bootstrapRelayConfig := job.JSONConfig{
"nodeName": fmt.Sprintf("starknet-OCRv2-%s-%s", "node", uuid.New().String()),
"accountAddress": fmt.Sprintf("%s", accountAddresses[0]),
"chainID": fmt.Sprintf("%s", c.ChainDetails.ChainId),
"accountAddress": accountAddresses[0],
"chainID": c.ChainDetails.ChainId,
}

oracleSpec := job.OCR2OracleSpec{
Expand Down Expand Up @@ -325,7 +293,7 @@ func (c *Common) CreateJobsForContract(cc *ChainlinkClient, observationSource st

sourceValueBridge := &client.BridgeTypeAttributes{
Name: "mockserver-bridge",
URL: fmt.Sprintf("%s/%s", c.RPCDetails.MockServerEndpoint, strings.TrimPrefix(c.RPCDetails.MockServerUrl, "/")),
URL: c.RPCDetails.MockServerEndpoint + "/" + strings.TrimPrefix(c.RPCDetails.MockServerUrl, "/"),
}

// Setting up job specs
Expand All @@ -339,7 +307,7 @@ func (c *Common) CreateJobsForContract(cc *ChainlinkClient, observationSource st
}
relayConfig := job.JSONConfig{
"nodeName": bootstrapRelayConfig["nodeName"],
"accountAddress": fmt.Sprintf("%s", accountAddresses[nIdx]),
"accountAddress": accountAddresses[nIdx],
"chainID": bootstrapRelayConfig["chainID"],
}

Expand All @@ -363,7 +331,6 @@ func (c *Common) CreateJobsForContract(cc *ChainlinkClient, observationSource st
OCR2OracleSpec: oracleSpec,
ObservationSource: observationSource,
}
fmt.Println(jobSpec.String())
_, err = n.MustCreateJob(jobSpec)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/docker/test_env/stark.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ func (s *Starknet) StartContainer() error {
return nil
}

func (ms *Starknet) getContainerRequest() (*tc.ContainerRequest, error) {
func (s *Starknet) getContainerRequest() (*tc.ContainerRequest, error) {
return &tc.ContainerRequest{
Name: ms.ContainerName,
Name: s.ContainerName,
Image: "shardlabs/starknet-devnet-rs:b41e566a3f17aa0e51871f02d5165959e50ce358",
ExposedPorts: []string{test_env.NatPortFormat(STARK_HTTP_PORT)},
Networks: ms.Networks,
Networks: s.Networks,
WaitingFor: tcwait.ForLog("Starknet Devnet listening").
WithStartupTimeout(30 * time.Second).
WithPollInterval(100 * time.Millisecond),
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestOCRBasicNew(t *testing.T) {
name string
env map[string]string
}{
{name: "embeded"},
{name: "embedded"},
//{name: "plugins", env: map[string]string{
// "CL_MEDIAN_CMD": "chainlink-feeds",
// "CL_SOLANA_CMD": "chainlink-solana",
Expand All @@ -51,7 +51,7 @@ func TestOCRBasicNew(t *testing.T) {
// K8s specific config and cleanup
if *config.Common.InsideK8s {
t.Cleanup(func() {
if err := actions.TeardownSuite(t, state.Common.Env, state.ChainlinkNodesK8s, nil, zapcore.PanicLevel, nil); err != nil {
if err = actions.TeardownSuite(t, state.Common.Env, state.ChainlinkNodesK8s, nil, zapcore.PanicLevel, nil); err != nil {
state.TestConfig.L.Error().Err(err).Msg("Error tearing down environment")
}
})
Expand All @@ -66,6 +66,7 @@ func TestOCRBasicNew(t *testing.T) {
}
state.DeployCluster()
state.Clients.GauntletClient, err = gauntlet.NewStarknetGauntlet(fmt.Sprintf("%s/", utils.ProjectRoot))
require.NoError(t, err, "Setting up gauntlet should not fail")
err = state.Clients.GauntletClient.SetupNetwork(state.Common.RPCDetails.RPCL2External, state.Account.Account, state.Account.PrivateKey)
require.NoError(t, err, "Setting up gauntlet network should not fail")
err = state.DeployGauntlet(0, 100000000000, decimals, "auto", 1, 1)
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/testconfig/ocr2/ocr2.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func (o *Config) Validate() error {
if o.Smoke == nil {
return errors.New("smoke must be defined")
}
if err := o.Smoke.Validate(); err != nil {
err := o.Smoke.Validate()
if err != nil {
return err
}

Expand Down

0 comments on commit 0a52985

Please sign in to comment.