diff --git a/core/services/ocr3/plugins/ccip_integration_tests/chainreader/chainreader_test.go b/core/services/ocr3/plugins/ccip_integration_tests/chainreader/chainreader_test.go index 93517c3c95..1550132f17 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/chainreader/chainreader_test.go +++ b/core/services/ocr3/plugins/ccip_integration_tests/chainreader/chainreader_test.go @@ -68,7 +68,7 @@ func TestChainReader(t *testing.T) { }, } - d := helpers.SetupChainReaderTest[Chainreader](t, ctx, DeployChainreader, NewChainreader, cfg) + d := helpers.SetupChainReaderTest[Chainreader](t, ctx, DeployChainreader, NewChainreader, cfg, ContractNameAlias) cr := *d.ChainReader emitEvents(t, d, ctx) // Calls the contract to emit events diff --git a/core/services/ocr3/plugins/ccip_integration_tests/home_chain/home_chain_test.go b/core/services/ocr3/plugins/ccip_integration_tests/home_chain/home_chain_test.go index 2f1278cace..e127ea72c5 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/home_chain/home_chain_test.go +++ b/core/services/ocr3/plugins/ccip_integration_tests/home_chain/home_chain_test.go @@ -8,30 +8,48 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - - "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" capcfg "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_capability_configuration" helpers "github.com/smartcontractkit/chainlink/v2/core/services/ocr3/plugins/ccip_integration_tests" + "github.com/smartcontractkit/libocr/commontypes" + libocrtypes "github.com/smartcontractkit/libocr/ragep2p/types" evmtypes "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types" "github.com/stretchr/testify/assert" ) -const ( - chainID = 1337 - chainA = ccipocr3.ChainSelector(1) - chainB = ccipocr3.ChainSelector(2) - chainC = ccipocr3.ChainSelector(3) +var ( + chainA uint64 = 1 + nodeAID uint8 = 1 + fChainA uint8 = 1 + oracleAID = commontypes.OracleID(nodeAID) + peerAID = "12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X" + p2pOracleAID = libocrtypes.PeerID{byte(nodeAID)} + + chainB uint64 = 2 + nodeBID uint8 = 2 + fChainB uint8 = 2 + oracleBID = commontypes.OracleID(nodeBID) + p2pOracleBID = libocrtypes.PeerID{byte(nodeBID)} + + chainC uint64 = 3 + nodeCID uint8 = 3 + fChainC uint8 = 3 + oracleCID = commontypes.OracleID(nodeCID) + p2pOracleCID = libocrtypes.PeerID{byte(nodeCID)} ) func TestHomeChainReader(t *testing.T) { deployFunc := func(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *capcfg.CCIPCapabilityConfiguration, error) { return capcfg.DeployCCIPCapabilityConfiguration(auth, backend, common.Address{}) } + const ( + ContractName = "CCIPCapabilityConfiguration" + FnGetChainConfigs = "getAllChainConfigs" + ) // Initialize chainReader cfg := evmtypes.ChainReaderConfig{ Contracts: map[string]evmtypes.ChainContractReader{ - "CCIPCapabilityConfiguration": { + ContractName: { ContractABI: capcfg.CCIPCapabilityConfigurationMetaData.ABI, Configs: map[string]*evmtypes.ChainReaderDefinition{ "ChainConfigSet": { @@ -39,19 +57,27 @@ func TestHomeChainReader(t *testing.T) { ReadType: evmtypes.Event, ConfidenceConfirmations: map[string]int{"0.0": 0, "1.0": 0}, }, - "getAllChainConfigs": { - ChainSpecificName: "getAllChainConfigs", + FnGetChainConfigs: { + ChainSpecificName: FnGetChainConfigs, }, }, }, }, } - d := helpers.SetupChainReaderTest[capcfg.CCIPCapabilityConfiguration](t, context.Background(), deployFunc, capcfg.NewCCIPCapabilityConfiguration, cfg) + d := helpers.SetupChainReaderTest[capcfg.CCIPCapabilityConfiguration](t, context.Background(), deployFunc, capcfg.NewCCIPCapabilityConfiguration, cfg, ContractName) chainReader := *d.ChainReader // Apply chain configs to the contract inputConfig := setupConfigInfo() + //[]capcfg.CCIPCapabilityConfigurationChainConfigInfo{ + // setupConfigInfo(chainA, []uint8{nodeAID, nodeBID, nodeCID}, fChainA, []byte{}), + // setupConfigInfo(chainB, []uint8{nodeAID, nodeBID}, fChainB, []byte{}), + // setupConfigInfo(chainC, []uint8{nodeCID}, fChainC, []byte{}), + //setupConfigInfo(chainA, []byte{'a', 'b', 'c'}, fChainA, []byte{}), + //setupConfigInfo(chainB, []byte{'a', 'b'}, fChainB, []byte{}), + //setupConfigInfo(chainC, []byte{}, fChainC, []byte{}), + //} _, err := d.Contract.ApplyChainConfigUpdates(d.Auth, nil, inputConfig) d.SimulatedBE.Commit() assert.NoError(t, err) @@ -60,8 +86,8 @@ func TestHomeChainReader(t *testing.T) { var allConfigs []capcfg.CCIPCapabilityConfigurationChainConfigInfo err = chainReader.GetLatestValue( context.Background(), - "CCIPCapabilityConfiguration", - "getAllChainConfigs", + ContractName, + FnGetChainConfigs, map[string]interface{}{}, &allConfigs, ) @@ -72,7 +98,7 @@ func TestHomeChainReader(t *testing.T) { func setupConfigInfo() []capcfg.CCIPCapabilityConfigurationChainConfigInfo { return []capcfg.CCIPCapabilityConfigurationChainConfigInfo{ { - ChainSelector: chainID, + ChainSelector: 1, ChainConfig: capcfg.CCIPCapabilityConfigurationChainConfig{ Readers: [][32]byte{}, FChain: 2, diff --git a/core/services/ocr3/plugins/ccip_integration_tests/integration_helpers.go b/core/services/ocr3/plugins/ccip_integration_tests/integration_helpers.go index 05b91d070f..1937ccb6a9 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/integration_helpers.go +++ b/core/services/ocr3/plugins/ccip_integration_tests/integration_helpers.go @@ -39,7 +39,7 @@ type DeployFuncWithCapabilities[T any] func(auth *bind.TransactOpts, backend bin type NewFunc[T any] func(address common.Address, backend bind.ContractBackend) (*T, error) -func SetupChainReaderTest[T any](t *testing.T, _ context.Context, deployFunc DeployFunc[T], newFunc NewFunc[T], chainReaderConfig evmtypes.ChainReaderConfig) *TestSetupData[T] { +func SetupChainReaderTest[T any](t *testing.T, _ context.Context, deployFunc DeployFunc[T], newFunc NewFunc[T], chainReaderConfig evmtypes.ChainReaderConfig, contractName string) *TestSetupData[T] { // Generate a new key pair for the simulated account privateKey, err := crypto.GenerateKey() assert.NoError(t, err) @@ -82,7 +82,7 @@ func SetupChainReaderTest[T any](t *testing.T, _ context.Context, deployFunc Dep err = cr.Bind(context.Background(), []types2.BoundContract{ { Address: address.String(), - Name: "CCIPCapabilityConfiguration", + Name: contractName, Pending: false, }, })