Skip to content

Commit

Permalink
deprecated: WithCLNodeConfig in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 committed May 24, 2024
1 parent 6a9c299 commit 3492f69
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 37 deletions.
40 changes: 5 additions & 35 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,18 @@ import (
"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"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
)

type Common struct {
Expand Down Expand Up @@ -153,6 +146,10 @@ func New(testConfig *tc.TestConfig) *Common {
}
}

// provide getters for TestConfig
testConfig.GetChainID = func() string { return config.ChainID }
testConfig.GetURL = func() string { return config.RPCUrl }

c = &Common{
ChainDetails: &ChainDetails{
ChainID: config.ChainID,
Expand Down Expand Up @@ -483,32 +480,6 @@ func BuildNodeContractPairID(node *client.ChainlinkClient, ocr2Addr string) (str
return strings.ToLower(fmt.Sprintf("node_%s_contract_%s", shortNodeAddr, shortOCRAddr)), nil
}

func (c *Common) DefaultNodeConfig() *cl.Config {
solConfig := solcfg.TOMLConfig{
Enabled: ptr.Ptr(true),
ChainID: ptr.Ptr(c.ChainDetails.ChainID),
Nodes: []*solcfg.Node{
{
Name: ptr.Ptr("primary"),
URL: config.MustParseURL(c.ChainDetails.RPCUrl),
},
},
}
baseConfig := node.NewBaseConfig()
baseConfig.Solana = solcfg.TOMLConfigs{
&solConfig,
}
baseConfig.OCR2.Enabled = ptr.Ptr(true)
baseConfig.P2P.V2.Enabled = ptr.Ptr(true)
fiveSecondDuration := commonconfig.MustNewDuration(5 * time.Second)

baseConfig.P2P.V2.DeltaDial = fiveSecondDuration
baseConfig.P2P.V2.DeltaReconcile = fiveSecondDuration
baseConfig.P2P.V2.ListenAddresses = &[]string{"0.0.0.0:6690"}

return baseConfig
}

func (c *Common) Default(t *testing.T, namespacePrefix string) (*Common, error) {
c.TestEnvDetails.K8Config = &environment.Config{
NamespacePrefix: fmt.Sprintf("solana-%s", namespacePrefix),
Expand All @@ -517,8 +488,7 @@ func (c *Common) Default(t *testing.T, namespacePrefix string) (*Common, error)
}

if *c.TestConfig.Common.InsideK8s {
toml := c.DefaultNodeConfig()
tomlString, err := toml.TOMLString()
tomlString, err := c.TestConfig.GetNodeConfigTOML()
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion integration-tests/common/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (m *OCRv2TestState) DeployCluster(contractsDir string) {
WithTestInstance(m.Config.T).
WithTestConfig(m.Config.TestConfig).
WithMockAdapter().
// WithCLNodeConfig(m.Common.DefaultNodeConfig()).
WithCLNodes(*m.Config.TestConfig.OCR2.NodeCount).
WithCLNodeOptions(m.Common.TestEnvDetails.NodeOpts...).
WithStandardCleanup().
Expand Down
54 changes: 53 additions & 1 deletion integration-tests/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"encoding/base64"
"errors"
"fmt"
"log"
"os"
"strings"
"time"

"github.com/barkimedes/go-deepcopy"
"github.com/google/uuid"
Expand All @@ -15,14 +17,18 @@ import (
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink/integration-tests/types/config/node"
"github.com/smartcontractkit/seth"

ctf_config "github.com/smartcontractkit/chainlink-testing-framework/config"
k8s_config "github.com/smartcontractkit/chainlink-testing-framework/k8s/config"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink-testing-framework/utils/osutil"
"github.com/smartcontractkit/chainlink-testing-framework/utils/ptr"

ocr2_config "github.com/smartcontractkit/chainlink-solana/integration-tests/testconfig/ocr2"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
)

type TestConfig struct {
Expand All @@ -34,6 +40,10 @@ type TestConfig struct {
OCR2 *ocr2_config.Config `toml:"OCR2"`
SolanaConfig *SolanaConfig `toml:"SolanaConfig"`
ConfigurationName string `toml:"-"`

// getter funcs for passing parameters
GetChainID func() string
GetURL func() string
}

func (c *TestConfig) GetLoggingConfig() *ctf_config.LoggingConfig {
Expand All @@ -53,7 +63,49 @@ func (c *TestConfig) GetSethConfig() *seth.Config {
}

func (c *TestConfig) GetNodeConfig() *ctf_config.NodeConfig {
return nil
cfgTOML, err := c.GetNodeConfigTOML()
if err != nil {
log.Fatalf("failed to parse TOML config: %s", err)
return nil
}

return &ctf_config.NodeConfig{
BaseConfigTOML: cfgTOML,
}
}

func (c *TestConfig) GetNodeConfigTOML() (string, error) {
var chainID, url string
if c.GetChainID != nil {
chainID = c.GetChainID()
}
if c.GetURL != nil {
url = c.GetURL()
}

solConfig := solcfg.TOMLConfig{
Enabled: ptr.Ptr(true),
ChainID: ptr.Ptr(chainID),
Nodes: []*solcfg.Node{
{
Name: ptr.Ptr("primary"),
URL: config.MustParseURL(url),
},
},
}
baseConfig := node.NewBaseConfig()
baseConfig.Solana = solcfg.TOMLConfigs{
&solConfig,
}
baseConfig.OCR2.Enabled = ptr.Ptr(true)
baseConfig.P2P.V2.Enabled = ptr.Ptr(true)
fiveSecondDuration := config.MustNewDuration(5 * time.Second)

baseConfig.P2P.V2.DeltaDial = fiveSecondDuration
baseConfig.P2P.V2.DeltaReconcile = fiveSecondDuration
baseConfig.P2P.V2.ListenAddresses = &[]string{"0.0.0.0:6690"}

return baseConfig.TOMLString()
}

var embeddedConfigs embed.FS
Expand Down

0 comments on commit 3492f69

Please sign in to comment.