Skip to content

Commit

Permalink
Merge branch 'develop' into BCF-3230-add-contract-state-reade-to-relayer
Browse files Browse the repository at this point in the history
# Conflicts:
#	integration-tests/common/common.go
#	integration-tests/go.mod
#	integration-tests/go.sum
  • Loading branch information
george-dorin committed Jul 29, 2024
2 parents e2b960f + 5f11cca commit e7bb84d
Show file tree
Hide file tree
Showing 15 changed files with 317 additions and 276 deletions.
34 changes: 26 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,37 @@
};

outputs = inputs@{ self, nixpkgs, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlays.default ]; };
devnet-hardhat = import ./ops/scripts { inherit pkgs; };
in rec {
pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlays.default ]; };
in
{
devShell = pkgs.callPackage ./shell.nix {
inherit pkgs;
scriptDir = toString ./.; # This converts the flake's root directory to a string
scriptDir = toString ./.; # This converts the flake's root directory to a string
};

apps.starknet-devnet = {
type = "app";
program = "${devnet-hardhat}/ops/scripts/devnet-hardhat.sh";
packages = {
starknet-devnet = pkgs.stdenv.mkDerivation rec {
name = "starknet-devnet";
src = ./ops/scripts;
installPhase = ''
mkdir -p $out/bin
cp $src/devnet-hardhat.sh $out/bin/${name}
cp $src/devnet-hardhat-down.sh $out/bin/
chmod +x $out/bin/${name}
'';
};

starknet-devnet-down = pkgs.stdenv.mkDerivation rec {
name = "starknet-devnet-down";
src = ./ops/scripts;
installPhase = ''
mkdir -p $out/bin
cp $src/devnet-hardhat-down.sh $out/bin/${name}
chmod +x $out/bin/${name}
'';
};
};

formatter = pkgs.nixpkgs-fmt;
Expand Down
45 changes: 10 additions & 35 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,18 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"

common_cfg "github.com/smartcontractkit/chainlink-common/pkg/config"
ctfconfig "github.com/smartcontractkit/chainlink-testing-framework/config"
"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/utils/ptr"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"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/services/relay"

chainconfig "github.com/smartcontractkit/chainlink-starknet/integration-tests/config"
"github.com/smartcontractkit/chainlink-starknet/integration-tests/testconfig"
"github.com/smartcontractkit/chainlink-starknet/ops/devnet"
"github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/config"
"github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet"
)

Expand Down Expand Up @@ -96,6 +91,11 @@ func New(testConfig *testconfig.TestConfig) *Common {
RPCL2InternalAPIKey: chainDetails.L2RPCInternalAPIKey,
},
}
// provide getters for TestConfig (pointers to chain + rpc details)
c.TestConfig.GetChainID = func() string { return c.ChainDetails.ChainID }
c.TestConfig.GetFeederURL = func() string { return c.ChainDetails.FeederURL }
c.TestConfig.GetRPCL2Internal = func() string { return c.RPCDetails.RPCL2Internal }
c.TestConfig.GetRPCL2InternalAPIKey = func() string { return c.RPCDetails.RPCL2InternalAPIKey }

return c
}
Expand All @@ -108,8 +108,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 Expand Up @@ -147,34 +146,6 @@ func (c *Common) Default(t *testing.T, namespacePrefix string) (*Common, error)
return c, nil
}

func (c *Common) DefaultNodeConfig() *cl.Config {
starkConfig := config.TOMLConfig{
Enabled: ptr.Ptr(true),
ChainID: ptr.Ptr(c.ChainDetails.ChainID),
FeederURL: common_cfg.MustParseURL(c.ChainDetails.FeederURL),
Nodes: []*config.Node{
{
Name: ptr.Ptr("primary"),
URL: common_cfg.MustParseURL(c.RPCDetails.RPCL2Internal),
APIKey: ptr.Ptr(c.RPCDetails.RPCL2InternalAPIKey),
},
},
}
baseConfig := node.NewBaseConfig()
baseConfig.Starknet = config.TOMLConfigs{
&starkConfig,
}
baseConfig.OCR2.Enabled = ptr.Ptr(true)
baseConfig.P2P.V2.Enabled = ptr.Ptr(true)
fiveSecondDuration := common_cfg.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) SetLocalEnvironment(t *testing.T) {
// Run scripts to set up local test environment
log.Info().Msg("Starting starknet-devnet container...")
Expand Down Expand Up @@ -274,6 +245,8 @@ func (c *Common) CreateJobsForContract(cc *ChainlinkClient, observationSource st

oracleSpec := job.OCR2OracleSpec{
ContractID: ocrControllerAddress,
Relay: c.ChainDetails.ChainName,
RelayConfig: bootstrapRelayConfig,
ContractConfigConfirmations: 1, // don't wait for confirmation on devnet
}
// Setting up bootstrap node
Expand Down Expand Up @@ -317,6 +290,8 @@ func (c *Common) CreateJobsForContract(cc *ChainlinkClient, observationSource st

oracleSpec = job.OCR2OracleSpec{
ContractID: ocrControllerAddress,
Relay: c.ChainDetails.ChainName,
RelayConfig: relayConfig,
PluginType: "median",
OCRKeyBundleID: null.StringFrom(cc.NKeys[nIdx].OCR2Key.Data.ID),
TransmitterID: null.StringFrom(cc.NKeys[nIdx].TXKey.Data.ID),
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 @@ -175,7 +175,6 @@ func (m *OCRv2TestState) DeployCluster() {
WithTestInstance(m.TestConfig.T).
WithTestConfig(m.TestConfig.TestConfig).
WithMockAdapter().
WithCLNodeConfig(m.Common.DefaultNodeConfig()).
WithCLNodes(*m.Common.TestConfig.OCR2.NodeCount).
WithCLNodeOptions(m.Common.TestEnvDetails.NodeOpts...).
WithStandardCleanup().
Expand Down
Loading

0 comments on commit e7bb84d

Please sign in to comment.