Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 committed May 21, 2024
1 parent 83239d1 commit f7ae48c
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 106 deletions.
42 changes: 22 additions & 20 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,41 @@ import (
"testing"
"time"

"github.com/gagliardetto/solana-go"
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/rs/zerolog/log"
"golang.org/x/crypto/curve25519"
"gopkg.in/guregu/null.v4"

"github.com/gagliardetto/solana-go"
"github.com/smartcontractkit/libocr/offchainreporting2/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2/types"

"github.com/smartcontractkit/chainlink-common/pkg/config"
chainConfig "github.com/smartcontractkit/chainlink-solana/integration-tests/config"
tc "github.com/smartcontractkit/chainlink-solana/integration-tests/testconfig"
ctfconfig "github.com/smartcontractkit/chainlink-testing-framework/config"
ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/environment"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink"
mock_adapter "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mock-adapter"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/sol"
"github.com/smartcontractkit/chainlink-testing-framework/utils/ptr"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
"github.com/smartcontractkit/chainlink/integration-tests/types/config/node"

cl "github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/store/models"

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

chainConfig "github.com/smartcontractkit/chainlink-solana/integration-tests/config"
test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/testenv"
"github.com/smartcontractkit/chainlink-solana/integration-tests/solclient"
tc "github.com/smartcontractkit/chainlink-solana/integration-tests/testconfig"
cl_solana "github.com/smartcontractkit/chainlink-solana/pkg/solana"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
)
Expand All @@ -66,7 +68,7 @@ type TestEnvDetails struct {

type ChainDetails struct {
ChainName string
ChainId string
ChainID string
RPCUrl string
RPCURLExternal string
WSURLExternal string
Expand Down Expand Up @@ -141,20 +143,20 @@ func New(testConfig *tc.TestConfig) *Common {
config = chainConfig.DevnetConfig()
privateKeyString = *testConfig.Common.PrivateKey

if *testConfig.Common.RPC_URL != "" {
config.RPCUrl = *testConfig.Common.RPC_URL
config.WSUrl = *testConfig.Common.WS_URL
if *testConfig.Common.RPCURL != "" {
config.RPCUrl = *testConfig.Common.RPCURL
config.WSUrl = *testConfig.Common.WsURL
config.ProgramAddresses = &chainConfig.ProgramAddresses{
OCR2: *testConfig.SolanaConfig.OCR2ProgramId,
AccessController: *testConfig.SolanaConfig.AccessControllerProgramId,
Store: *testConfig.SolanaConfig.StoreProgramId,
OCR2: *testConfig.SolanaConfig.OCR2ProgramID,
AccessController: *testConfig.SolanaConfig.AccessControllerProgramID,
Store: *testConfig.SolanaConfig.StoreProgramID,
}
}
}

c = &Common{
ChainDetails: &ChainDetails{
ChainId: config.ChainID,
ChainID: config.ChainID,
RPCUrl: config.RPCUrl,
ChainName: config.ChainName,
ProgramAddresses: config.ProgramAddresses,
Expand Down Expand Up @@ -182,7 +184,7 @@ func (c *Common) CreateNodeKeysBundle(nodes []*client.ChainlinkClient) ([]client
}

peerID := p2pkeys.Data[0].Attributes.PeerID
txKey, _, err := n.CreateTxKey(c.ChainDetails.ChainName, c.ChainDetails.ChainId)
txKey, _, err := n.CreateTxKey(c.ChainDetails.ChainName, c.ChainDetails.ChainID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -286,7 +288,7 @@ func OffChainConfigParamsFromNodes(nodeCount int, nkb []client.NodeKeysBundle) (
}, nil
}

func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, mockUrl string, isK8s bool) error {
func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, mockURL string, isK8s bool) error {
for i, nodesInfo := range ContractsIdxMapToContractsNodeInfo {
// Bootstrap node first
var err error
Expand All @@ -301,7 +303,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo,
}
sourceValueBridge := client.BridgeTypeAttributes{
Name: nodeContractPairID,
URL: fmt.Sprintf("%s/%s", mockUrl, "five"),
URL: fmt.Sprintf("%s/%s", mockURL, "five"),
RequestData: "{}",
}
observationSource := client.ObservationSourceSpecBridge(&sourceValueBridge)
Expand All @@ -315,7 +317,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo,
}
juelsBridge := client.BridgeTypeAttributes{
Name: nodeContractPairID + "juels",
URL: fmt.Sprintf("%s/%s", mockUrl, "five"),
URL: fmt.Sprintf("%s/%s", mockURL, "five"),
RequestData: "{}",
}
juelsSource := client.ObservationSourceSpecBridge(&juelsBridge)
Expand Down Expand Up @@ -348,7 +350,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo,
}
sourceValueBridge := client.BridgeTypeAttributes{
Name: nodeContractPairID,
URL: fmt.Sprintf("%s/%s", mockUrl, "five"),
URL: fmt.Sprintf("%s/%s", mockURL, "five"),
RequestData: "{}",
}
observationSource := client.ObservationSourceSpecBridge(&sourceValueBridge)
Expand All @@ -362,7 +364,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo,
}
juelsBridge := client.BridgeTypeAttributes{
Name: nodeContractPairID + "juels",
URL: fmt.Sprintf("%s/%s", mockUrl, "five"),
URL: fmt.Sprintf("%s/%s", mockURL, "five"),
RequestData: "{}",
}
juelsSource := client.ObservationSourceSpecBridge(&juelsBridge)
Expand Down Expand Up @@ -401,7 +403,7 @@ func (c *Common) CreateJobsForContract(contractNodeInfo *ContractNodeInfo) error
"ocr2ProgramID": contractNodeInfo.OCR2.ProgramAddress(),
"transmissionsID": contractNodeInfo.Store.TransmissionsAddress(),
"storeProgramID": contractNodeInfo.Store.ProgramAddress(),
"chainID": c.ChainDetails.ChainId,
"chainID": c.ChainDetails.ChainID,
}
bootstrapPeers := []client.P2PData{
{
Expand Down Expand Up @@ -485,7 +487,7 @@ func BuildNodeContractPairID(node *client.ChainlinkClient, ocr2Addr string) (str
func (c *Common) DefaultNodeConfig() *cl.Config {
solConfig := cl_solana.TOMLConfig{
Enabled: ptr.Ptr(true),
ChainID: ptr.Ptr(c.ChainDetails.ChainId),
ChainID: ptr.Ptr(c.ChainDetails.ChainID),
Nodes: []*solcfg.Node{
{
Name: ptr.Ptr("primary"),
Expand Down
38 changes: 17 additions & 21 deletions integration-tests/common/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ import (
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/rs/zerolog/log"
"github.com/smartcontractkit/chainlink-solana/integration-tests/gauntlet"
"github.com/smartcontractkit/chainlink-solana/integration-tests/testconfig"
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"

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"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"

"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/store/models"

test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/testenv"
"github.com/smartcontractkit/chainlink-solana/integration-tests/gauntlet"
"github.com/smartcontractkit/chainlink-solana/integration-tests/solclient"
"github.com/smartcontractkit/chainlink-solana/integration-tests/testconfig"
)

type OCRv2TestState struct {
Expand All @@ -50,8 +52,6 @@ type ChainlinkClient struct {
ChainlinkClientK8s []*client.ChainlinkK8sClient
ChainlinkNodes []*client.ChainlinkClient
NKeys []client.NodeKeysBundle
bTypeAttr *client.BridgeTypeAttributes
bootstrapPeers []client.P2PData
AccountAddresses []string
}

Expand All @@ -63,7 +63,6 @@ type Config struct {
}

func NewOCRv2State(t *testing.T, contracts int, namespacePrefix string, testConfig *testconfig.TestConfig) (*OCRv2TestState, error) {

c, err := New(testConfig).Default(t, namespacePrefix)
if err != nil {
return nil, err
Expand Down Expand Up @@ -113,9 +112,9 @@ func (m *OCRv2TestState) DeployCluster(contractsDir string) {
m.Common.ChainDetails.WSURLExternal = m.Common.Env.URLs["sol"][1]

if *m.Config.TestConfig.Common.Network == "devnet" {
m.Common.ChainDetails.RPCUrl = *m.Config.TestConfig.Common.RPC_URL
m.Common.ChainDetails.RPCURLExternal = *m.Config.TestConfig.Common.RPC_URL
m.Common.ChainDetails.WSURLExternal = *m.Config.TestConfig.Common.WS_URL
m.Common.ChainDetails.RPCUrl = *m.Config.TestConfig.Common.RPCURL
m.Common.ChainDetails.RPCURLExternal = *m.Config.TestConfig.Common.RPCURL
m.Common.ChainDetails.WSURLExternal = *m.Config.TestConfig.Common.WsURL
}

m.Common.ChainDetails.MockserverURLInternal = m.Common.Env.URLs["qa_mock_adapter_internal"][0]
Expand All @@ -133,9 +132,9 @@ func (m *OCRv2TestState) DeployCluster(contractsDir string) {
m.Common.ChainDetails.WSURLExternal = sol.ExternalWsURL

if *m.Config.TestConfig.Common.Network == "devnet" {
m.Common.ChainDetails.RPCUrl = *m.Config.TestConfig.Common.RPC_URL
m.Common.ChainDetails.RPCURLExternal = *m.Config.TestConfig.Common.RPC_URL
m.Common.ChainDetails.WSURLExternal = *m.Config.TestConfig.Common.WS_URL
m.Common.ChainDetails.RPCUrl = *m.Config.TestConfig.Common.RPCURL
m.Common.ChainDetails.RPCURLExternal = *m.Config.TestConfig.Common.RPCURL
m.Common.ChainDetails.WSURLExternal = *m.Config.TestConfig.Common.WsURL
}

b, err := test_env.NewCLTestEnvBuilder().
Expand All @@ -162,7 +161,6 @@ func (m *OCRv2TestState) DeployCluster(contractsDir string) {
m.Common.ChainDetails.MockServerEndpoint = "mockserver-bridge"
err = m.Clients.KillgraveClient.SetAdapterBasedIntValuePath("/mockserver-bridge", []string{http.MethodGet, http.MethodPost}, 5)
require.NoError(m.Config.T, err, "Failed to set mock adapter value")

}

m.SetupClients()
Expand Down Expand Up @@ -230,21 +228,22 @@ func (m *OCRv2TestState) DeployContracts(contractsDir string) {
} else {
err = cd.DeployAnchorProgramsRemoteDocker(contractsDir, m.Common.DockerEnv.Sol)
}
require.NoError(m.Config.T, err)
}

// CreateJobs creating OCR jobs and EA stubs
func (m *OCRv2TestState) CreateJobs() {
// Setting up RPC
c := rpc.New(*m.Config.TestConfig.Common.RPC_URL)
wsc, err := ws.Connect(testcontext.Get(m.Config.T), *m.Config.TestConfig.Common.WS_URL)
c := rpc.New(*m.Config.TestConfig.Common.RPCURL)
wsc, err := ws.Connect(testcontext.Get(m.Config.T), *m.Config.TestConfig.Common.WsURL)
require.NoError(m.Config.T, err, "Error connecting to websocket client")

relayConfig := job.JSONConfig{
"nodeEndpointHTTP": m.Common.ChainDetails.RPCUrl,
"ocr2ProgramID": m.Common.ChainDetails.ProgramAddresses.OCR2,
"transmissionsID": m.Gauntlet.FeedAddress,
"storeProgramID": m.Common.ChainDetails.ProgramAddresses.Store,
"chainID": m.Common.ChainDetails.ChainId,
"chainID": m.Common.ChainDetails.ChainID,
}
boostratInternalIP := m.Clients.ChainlinkClient.ChainlinkNodes[0].InternalIP()
bootstrapPeers := []client.P2PData{
Expand Down Expand Up @@ -291,7 +290,6 @@ func (m *OCRv2TestState) CreateJobs() {
if *m.Config.TestConfig.Common.Network == "localnet" {
err = m.Clients.SolanaClient.Fund(m.Clients.ChainlinkClient.NKeys[nIdx].TXKey.Data.ID, big.NewFloat(1e4))
require.NoError(m.Config.T, err, "Error sending funds")

} else {
err = solclient.SendFunds(*m.Config.TestConfig.Common.PrivateKey, m.Clients.ChainlinkClient.NKeys[nIdx].TXKey.Data.ID, 100000000, c, wsc)
require.NoError(m.Config.T, err, "Error sending funds")
Expand Down Expand Up @@ -336,9 +334,7 @@ func (m *OCRv2TestState) SetChainlinkNodes() {
chainlinkNodes = append(chainlinkNodes, m.Clients.ChainlinkClient.ChainlinkClientK8s[i].ChainlinkClient)
}
} else {
for _, node := range m.Clients.ChainlinkClient.ChainlinkClientDocker.NodeAPIs() {
chainlinkNodes = append(chainlinkNodes, node)
}
chainlinkNodes = append(chainlinkNodes, m.Clients.ChainlinkClient.ChainlinkClientDocker.NodeAPIs()...)
}
m.Clients.ChainlinkClient.ChainlinkNodes = chainlinkNodes
}
Expand Down
22 changes: 11 additions & 11 deletions integration-tests/config/ocr2_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type OCR2Config struct {
NodeKeys []client.NodeKeysBundle
VaultAddress string
Secret string
ProposalId string
ProposalID string
}

type OCR2OnChainConfig struct {
Oracles []Operator `json:"oracles"`
F int `json:"f"`
ProposalId string `json:"proposalId"`
ProposalID string `json:"proposalId"`
}

type OffchainConfig struct {
Expand Down Expand Up @@ -53,7 +53,7 @@ type ReportingPluginConfig struct {

// TODO - Decouple all OCR2 config structs to be reusable between chains
type OCROffChainConfig struct {
ProposalId string `json:"proposalId"`
ProposalID string `json:"proposalId"`
OffchainConfig OffchainConfig `json:"offchainConfig"`
UserSecret string `json:"userSecret"`
}
Expand All @@ -66,11 +66,11 @@ type Operator struct {

type PayeeConfig struct {
Operators []Operator `json:"operators"`
ProposalId string `json:"proposalId"`
ProposalID string `json:"proposalId"`
}

type ProposalAcceptConfig struct {
ProposalId string `json:"proposalId"`
ProposalID string `json:"proposalId"`
Version int `json:"version"`
F int `json:"f"`
Oracles []Operator `json:"oracles"`
Expand Down Expand Up @@ -101,7 +101,7 @@ type StoreWriterConfig struct {
Transmissions string `json:"transmissions"`
}

func NewOCR2Config(nodeKeys []client.NodeKeysBundle, proposalId string, vaultAddress string, secret string) *OCR2Config {
func NewOCR2Config(nodeKeys []client.NodeKeysBundle, proposalID string, vaultAddress string, secret string) *OCR2Config {
var oracles []Operator

nodeKeysSorted := make([]client.NodeKeysBundle, len(nodeKeys))
Expand All @@ -124,15 +124,15 @@ func NewOCR2Config(nodeKeys []client.NodeKeysBundle, proposalId string, vaultAdd
OnChainConfig: &OCR2OnChainConfig{
Oracles: oracles,
F: 1,
ProposalId: proposalId,
ProposalID: proposalID,
},
OffChainConfig: &OCROffChainConfig{},
PayeeConfig: &PayeeConfig{},
ProposalAcceptConfig: &ProposalAcceptConfig{},
NodeKeys: nodeKeysSorted,
VaultAddress: vaultAddress,
Secret: secret,
ProposalId: proposalId,
ProposalID: proposalID,
}
}

Expand Down Expand Up @@ -160,7 +160,7 @@ func (o *OCR2Config) Default() {
}
o.OffChainConfig = &OCROffChainConfig{
UserSecret: o.Secret,
ProposalId: o.ProposalId,
ProposalID: o.ProposalID,
OffchainConfig: OffchainConfig{
DeltaProgressNanoseconds: int64(20000000000),
DeltaResendNanoseconds: int64(50000000000),
Expand All @@ -182,10 +182,10 @@ func (o *OCR2Config) Default() {
}
o.PayeeConfig = &PayeeConfig{
Operators: o.OnChainConfig.Oracles,
ProposalId: o.ProposalId,
ProposalID: o.ProposalID,
}
o.ProposalAcceptConfig = &ProposalAcceptConfig{
ProposalId: o.ProposalId,
ProposalID: o.ProposalID,
Version: 2,
F: 1,
Oracles: o.OnChainConfig.Oracles,
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/gauntlet/gauntlet_solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (sg *SolanaGauntlet) DeployLinkToken() error {
return err
}
sg.VaultAddress = *sg.gr.Data.Vault
sg.LinkAddress = *&sg.gr.Responses[0].Contract
sg.LinkAddress = sg.gr.Responses[0].Contract

return nil
}
Expand Down Expand Up @@ -495,10 +495,10 @@ func (sg *SolanaGauntlet) DeployOCR2() (string, error) {
if err != nil {
return "", err
}
sg.OCR2Config.OnChainConfig.ProposalId = sg.ProposalAddress
sg.OCR2Config.OffChainConfig.ProposalId = sg.ProposalAddress
sg.OCR2Config.PayeeConfig.ProposalId = sg.ProposalAddress
sg.OCR2Config.ProposalAcceptConfig.ProposalId = sg.ProposalAddress
sg.OCR2Config.OnChainConfig.ProposalID = sg.ProposalAddress
sg.OCR2Config.OffChainConfig.ProposalID = sg.ProposalAddress
sg.OCR2Config.PayeeConfig.ProposalID = sg.ProposalAddress
sg.OCR2Config.ProposalAcceptConfig.ProposalID = sg.ProposalAddress

return "", nil
}
Expand Down
Loading

0 comments on commit f7ae48c

Please sign in to comment.