Skip to content

Commit

Permalink
Deploy feed chain in NewEnvironment helper
Browse files Browse the repository at this point in the history
  • Loading branch information
asoliman92 committed Sep 17, 2024
1 parent 9d929fc commit a348b98
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func Test0002_InitialDeploy(t *testing.T) {
lggr := logger.TestLogger(t)
ctx := ccipdeployment.Context(t)
tenv := ccipdeployment.NewEnvironmentWithCR(t, lggr, 3)
tenv := ccipdeployment.NewEnvironmentWithCRAndFeeds(t, lggr, 3)
e := tenv.Env
nodes := tenv.Nodes
chains := e.Chains
Expand All @@ -26,6 +26,7 @@ func Test0002_InitialDeploy(t *testing.T) {
// Apply migration
output, err := Apply0002(tenv.Env, ccipdeployment.DeployCCIPContractConfig{
HomeChainSel: tenv.HomeChainSel,
FeedChainSel: tenv.FeedChainSel,
ChainsToDeploy: tenv.Env.AllChainSelectors(),
// Capreg/config already exist.
CCIPOnChainState: state,
Expand Down
14 changes: 9 additions & 5 deletions integration-tests/deployment/ccip/deploy_feed_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ var (
LINK_PRICE = big.NewInt(5e18)
)

func DeployFeeds(lggr logger.Logger, chain deployment.Chain) (deployment.AddressBook, common.Address, error) {
func DeployFeeds(lggr logger.Logger, chain deployment.Chain) (deployment.AddressBook, map[string]common.Address, error) {
ab := deployment.NewMemoryAddressBook()

//TODO: Maybe append LINK to the contract name
linkTV := deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0)
mockLinkFeed, err := deployContract(lggr, chain, ab,
func(chain deployment.Chain) ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface] {
linkFeed, tx, _, err1 := mock_v3_aggregator_contract.DeployMockV3AggregatorContract(
Expand All @@ -39,16 +40,19 @@ func DeployFeeds(lggr logger.Logger, chain deployment.Chain) (deployment.Address
err = fmt.Errorf("linkFeedError: %v, AggregatorInterfaceError: %v", err1, err2)

Check failure on line 40 in integration-tests/deployment/ccip/deploy_feed_chain.go

View workflow job for this annotation

GitHub Actions / Lint integration-tests

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}
return ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface]{
Address: linkFeed, Contract: aggregatorCr, Tv: deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0), Tx: tx, Err: err,
Address: linkFeed, Contract: aggregatorCr, Tv: linkTV, Tx: tx, Err: err,
}
})

if err != nil {
lggr.Errorw("Failed to deploy link feed", "err", err)
return ab, common.Address{}, err
return ab, nil, err
}

lggr.Infow("deployed mockLinkFeed", "addr", mockLinkFeed.Address)

return ab, mockLinkFeed.Address, nil
tvToAddress := map[string]common.Address{
linkTV.String(): mockLinkFeed.Address,
}
return ab, tvToAddress, nil
}
1 change: 0 additions & 1 deletion integration-tests/deployment/ccip/deploy_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ func BuildAddDONArgs(
RemoteGasPriceBatchWriteFrequency: *commonconfig.MustNewDuration(RemoteGasPriceBatchWriteFrequency),
TokenPriceBatchWriteFrequency: *commonconfig.MustNewDuration(TokenPriceBatchWriteFrequency),
// TODO: Use a specific feed chain
// Use homechain as the feed chain to simplify testing
TokenInfo: map[ocrtypes.Account]pluginconfig.TokenInfo{
//TODO: Add remote chain tokens as keys with their respective aggregate contract on feedChain
},
Expand Down
15 changes: 11 additions & 4 deletions integration-tests/deployment/ccip/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ type DeployedTestEnvironment struct {
Ab deployment.AddressBook
Env deployment.Environment
HomeChainSel uint64
FeedChainSel uint64
Nodes map[string]memory.Node
}

// NewDeployedEnvironment creates a new CCIP environment
// with capreg and nodes set up.
func NewEnvironmentWithCR(t *testing.T, lggr logger.Logger, numChains int) DeployedTestEnvironment {
// NewEnvironmentWithCRAndFeeds creates a new CCIP environment
// with capreg, feeds and nodes set up.
func NewEnvironmentWithCRAndFeeds(t *testing.T, lggr logger.Logger, numChains int) DeployedTestEnvironment {
ctx := Context(t)
chains := memory.NewMemoryChains(t, numChains)
// Lower chainSel is home chain.
Expand All @@ -73,6 +74,11 @@ func NewEnvironmentWithCR(t *testing.T, lggr logger.Logger, numChains int) Deplo
ab, capReg, err := DeployCapReg(lggr, chains[homeChainSel])
require.NoError(t, err)

feedSel := chainSels[FeedChainIndex]
feedAb, _, err := DeployFeeds(lggr, chains[feedSel])
require.NoError(t, err)
require.NoError(t, ab.Merge(feedAb))

nodes := memory.NewNodes(t, zapcore.InfoLevel, chains, 4, 1, deployment.CapabilityRegistryConfig{
EVMChainID: homeChainEVM,
Contract: capReg,
Expand All @@ -89,13 +95,14 @@ func NewEnvironmentWithCR(t *testing.T, lggr logger.Logger, numChains int) Deplo
Ab: ab,
Env: e,
HomeChainSel: homeChainSel,
FeedChainSel: feedSel,
Nodes: nodes,
}
}

func NewEnvironmentWithCRAndJobs(t *testing.T, lggr logger.Logger, numChains int) DeployedTestEnvironment {
ctx := Context(t)
e := NewEnvironmentWithCR(t, lggr, numChains)
e := NewEnvironmentWithCRAndFeeds(t, lggr, numChains)
jbs, err := NewCCIPJobSpecs(e.Env.NodeIDs, e.Env.Offchain)
require.NoError(t, err)
for nodeID, jobs := range jbs {
Expand Down

0 comments on commit a348b98

Please sign in to comment.