Skip to content

Commit

Permalink
Merge branch 'develop' into BCI-2848
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 committed May 21, 2024
2 parents ff1204a + c37a730 commit 83239d1
Show file tree
Hide file tree
Showing 24 changed files with 139 additions and 180 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable
- name: golangci-lint
run: nix develop -c make lint-go-integration-tests
- name: Print lint report artifact
if: failure()
shell: bash
run: cat ./integration-tests/golangci-lint-integration-tests-report.xml
- name: Store lint report artifact
if: always()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
Expand All @@ -35,9 +39,13 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable
- name: golangci-lint
run: nix develop -c make lint-go-relay
- name: Print lint report artifact
if: failure()
shell: bash
run: cat ./pkg/golangci-lint-relay-report.xml
- name: Store lint report artifact
if: always()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: golangci-lint-relay-report
path: ./pkg/golangci-lint-relay-report.xml
path: ./pkg/golangci-lint-relay-report.xml
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
nodejs 18.13.0
yarn 1.22.19
rust 1.59.0
golang 1.21.1
golangci-lint 1.52.1
golang 1.21.6
golangci-lint 1.55.2
pulumi 3.40.1
ginkgo 2.5.1
actionlint 1.6.22
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ gomodtidy:

.PHONY: lint-go-integration-tests
lint-go-integration-tests:
cd ./integration-tests && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run || true
cd ./integration-tests && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run

.PHONY: lint-go-relay
lint-go-relay:
cd ./pkg && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run || true
cd ./pkg && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run

.PHONY: upgrade-e2e-solana-image
upgrade-e2e-solana-image:
Expand Down
30 changes: 15 additions & 15 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/smartcontractkit/chainlink-solana

go 1.21
go 1.21.6

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"

test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/test_env"
test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/testenv"
"github.com/smartcontractkit/chainlink-solana/integration-tests/solclient"
cl_solana "github.com/smartcontractkit/chainlink-solana/pkg/solana"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/common/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"

test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/test_env"
test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/testenv"
"github.com/smartcontractkit/chainlink-solana/integration-tests/solclient"
test_env_ctf "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext"
Expand Down Expand Up @@ -128,9 +128,9 @@ func (m *OCRv2TestState) DeployCluster(contractsDir string) {
require.NoError(m.Config.T, err)

// Setting the External RPC url for Gauntlet
m.Common.ChainDetails.RPCUrl = sol.InternalHttpUrl
m.Common.ChainDetails.RPCURLExternal = sol.ExternalHttpUrl
m.Common.ChainDetails.WSURLExternal = sol.ExternalWsUrl
m.Common.ChainDetails.RPCUrl = sol.InternalHTTPURL
m.Common.ChainDetails.RPCURLExternal = sol.ExternalHTTPURL
m.Common.ChainDetails.WSURLExternal = sol.ExternalWsURL

if *m.Config.TestConfig.Common.Network == "devnet" {
m.Common.ChainDetails.RPCUrl = *m.Config.TestConfig.Common.RPC_URL
Expand Down Expand Up @@ -192,8 +192,8 @@ func (m *OCRv2TestState) NewSolanaClientSetup(networkSettings *solclient.SolNetw
networkSettings.URLs = m.Common.Env.URLs[networkSettings.Name]
} else {
networkSettings.URLs = []string{
m.Common.DockerEnv.Sol.ExternalHttpUrl,
m.Common.DockerEnv.Sol.ExternalWsUrl,
m.Common.DockerEnv.Sol.ExternalHTTPURL,
m.Common.DockerEnv.Sol.ExternalWsURL,
}
}
ec, err := solclient.NewClient(networkSettings)
Expand Down Expand Up @@ -357,7 +357,7 @@ func formatBuffer(buf []byte) string {
func GetLatestRound(transmissions []gauntlet.Transmission) gauntlet.Transmission {
highestRound := transmissions[0]
for _, t := range transmissions[1:] {
if t.RoundId > highestRound.RoundId {
if t.RoundID > highestRound.RoundID {
highestRound = t
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_env
package testenv

import (
"context"
Expand Down Expand Up @@ -28,11 +28,11 @@ import (
)

const (
SOL_HTTP_PORT = "8899"
SOL_WS_PORT = "8900"
SolHTTPPort = "8899"
SolWSPort = "8900"
)

var config_yml = `
var configYmlRaw = `
json_rpc_url: http://0.0.0.0:8899
websocket_url: ws://0.0.0.0:8900
keypair_path: /root/.config/solana/cli/id.json
Expand All @@ -41,16 +41,16 @@ address_labels:
commitment: finalized
`

var id_json = `
var idJSONRaw = `
[94,214,238,83,144,226,75,151,226,20,5,188,42,110,64,180,196,244,6,199,29,231,108,112,67,175,110,182,3,242,102,83,103,72,221,132,137,219,215,192,224,17,146,227,94,4,173,67,173,207,11,239,127,174,101,204,65,225,90,88,224,45,205,117]
`

type Solana struct {
test_env.EnvComponent
ExternalHttpUrl string
ExternalWsUrl string
InternalHttpUrl string
InternalWsUrl string
ExternalHTTPURL string
ExternalWsURL string
InternalHTTPURL string
InternalWsURL string
t *testing.T
l zerolog.Logger
Image string
Expand Down Expand Up @@ -112,29 +112,29 @@ func (s *Solana) StartContainer() error {
if err != nil {
return err
}
httpPort, err := c.MappedPort(testcontext.Get(s.t), test_env.NatPort(SOL_HTTP_PORT))
httpPort, err := c.MappedPort(testcontext.Get(s.t), test_env.NatPort(SolHTTPPort))
if err != nil {
return err
}
wsPort, err := c.MappedPort(testcontext.Get(s.t), test_env.NatPort(SOL_WS_PORT))
wsPort, err := c.MappedPort(testcontext.Get(s.t), test_env.NatPort(SolWSPort))
if err != nil {
return err
}
s.ExternalHttpUrl = fmt.Sprintf("http://%s:%s", host, httpPort.Port())
s.InternalHttpUrl = fmt.Sprintf("http://%s:%s", s.ContainerName, SOL_HTTP_PORT)
s.ExternalWsUrl = fmt.Sprintf("ws://%s:%s", host, wsPort.Port())
s.InternalWsUrl = fmt.Sprintf("ws://%s:%s", s.ContainerName, SOL_WS_PORT)
s.ExternalHTTPURL = fmt.Sprintf("http://%s:%s", host, httpPort.Port())
s.InternalHTTPURL = fmt.Sprintf("http://%s:%s", s.ContainerName, SolHTTPPort)
s.ExternalWsURL = fmt.Sprintf("ws://%s:%s", host, wsPort.Port())
s.InternalWsURL = fmt.Sprintf("ws://%s:%s", s.ContainerName, SolWSPort)

s.l.Info().
Any("ExternalHttpUrl", s.ExternalHttpUrl).
Any("InternalHttpUrl", s.InternalHttpUrl).
Any("ExternalWsUrl", s.ExternalWsUrl).
Any("InternalWsUrl", s.InternalWsUrl).
Any("ExternalHTTPURL", s.ExternalHTTPURL).
Any("InternalHTTPURL", s.InternalHTTPURL).
Any("ExternalWsURL", s.ExternalWsURL).
Any("InternalWsURL", s.InternalWsURL).
Str("containerName", s.ContainerName).
Msgf("Started Solana container")

// validate features are properly set
inactiveLocalFeatures, err := GetInactiveFeatureHashes(s.ExternalHttpUrl)
inactiveLocalFeatures, err := GetInactiveFeatureHashes(s.ExternalHTTPURL)
if err != nil {
return err
}
Expand All @@ -144,33 +144,33 @@ func (s *Solana) StartContainer() error {
return nil
}

func (ms *Solana) getContainerRequest(inactiveFeatures InactiveFeatures) (*tc.ContainerRequest, error) {
func (s *Solana) getContainerRequest(inactiveFeatures InactiveFeatures) (*tc.ContainerRequest, error) {
configYml, err := os.CreateTemp("", "config.yml")
if err != nil {
return nil, err
}
_, err = configYml.WriteString(config_yml)
_, err = configYml.WriteString(configYmlRaw)
if err != nil {
return nil, err
}

idJson, err := os.CreateTemp("", "id.json")
idJSON, err := os.CreateTemp("", "id.json")
if err != nil {
return nil, err
}
_, err = idJson.WriteString(id_json)
_, err = idJSON.WriteString(idJSONRaw)
if err != nil {
return nil, err
}

return &tc.ContainerRequest{
Name: ms.ContainerName,
Image: ms.Image,
ExposedPorts: []string{test_env.NatPortFormat(SOL_HTTP_PORT), test_env.NatPortFormat(SOL_WS_PORT)},
Name: s.ContainerName,
Image: s.Image,
ExposedPorts: []string{test_env.NatPortFormat(SolHTTPPort), test_env.NatPortFormat(SolWSPort)},
Env: map[string]string{
"SERVER_PORT": "1080",
},
Networks: ms.Networks,
Networks: s.Networks,
WaitingFor: tcwait.ForLog("Processed Slot: 1").
WithStartupTimeout(30 * time.Second).
WithPollInterval(100 * time.Millisecond),
Expand All @@ -190,13 +190,13 @@ func (ms *Solana) getContainerRequest(inactiveFeatures InactiveFeatures) (*tc.Co
if err != nil {
return err
}
err = container.CopyFileToContainer(ctx, idJson.Name(), "/root/.config/solana/cli/id.json", 0644)
err = container.CopyFileToContainer(ctx, idJSON.Name(), "/root/.config/solana/cli/id.json", 0644)
return err
},
},
},
},
Entrypoint: []string{"sh", "-c", "mkdir -p /root/.config/solana/cli && solana-test-validator -r --mint=" + ms.PublicKey + " " + inactiveFeatures.CLIString()},
Entrypoint: []string{"sh", "-c", "mkdir -p /root/.config/solana/cli && solana-test-validator -r --mint=" + s.PublicKey + " " + inactiveFeatures.CLIString()},
}, nil
}

Expand All @@ -222,7 +222,7 @@ func (f InactiveFeatures) CLIString() string {
// This is used in conjunction with the solana-test-validator command to produce a solana network that has the same features as mainnet
// the solana-test-validator has all features on by default (released + unreleased)
func GetInactiveFeatureHashes(url string) (output InactiveFeatures, err error) {
cmd := exec.Command("solana", "feature", "status", "-u="+url, "--output=json") // -um is for mainnet url
cmd := exec.Command("solana", "feature", "status", "-u="+url, "--output=json") //nolint:gosec // -um is for mainnet url
stdout, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("Failed to get feature status: %w", err)
Expand Down
Loading

0 comments on commit 83239d1

Please sign in to comment.