Skip to content

Commit 6ad6c13

Browse files
committed
move ccip suite setup to common. add parallel in independent tests
1 parent 30886af commit 6ad6c13

File tree

4 files changed

+190
-180
lines changed

4 files changed

+190
-180
lines changed

integration-tests/mcms/common.go

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package mcms
44

55
import (
66
"crypto/ecdsa"
7+
"encoding/hex"
78
"slices"
89
"time"
910

@@ -14,6 +15,12 @@ import (
1415
mcmsencoder "github.com/smartcontractkit/chainlink-sui/bindings"
1516
"github.com/smartcontractkit/chainlink-sui/bindings/bind"
1617
"github.com/smartcontractkit/chainlink-sui/bindings/tests/testenv"
18+
"github.com/smartcontractkit/chainlink-sui/deployment"
19+
ccipops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip"
20+
offrampops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_offramp"
21+
onrampops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_onramp"
22+
routerops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_router"
23+
linkops "github.com/smartcontractkit/chainlink-sui/deployment/ops/link"
1724
mcmsops "github.com/smartcontractkit/chainlink-sui/deployment/ops/mcms"
1825
"github.com/smartcontractkit/mcms"
1926
"github.com/smartcontractkit/mcms/sdk"
@@ -23,6 +30,7 @@ import (
2330
"github.com/stretchr/testify/suite"
2431

2532
cselectors "github.com/smartcontractkit/chain-selectors"
33+
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
2634
cld_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations"
2735
sui_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops"
2836
opregistry "github.com/smartcontractkit/chainlink-sui/deployment/ops/registry"
@@ -85,8 +93,30 @@ type MCMSTestSuite struct {
8593
// Ops
8694
deps sui_ops.OpTxDeps
8795
bundle cld_ops.Bundle
96+
97+
// CCIP
98+
// LINK
99+
linkPackageId string
100+
linkObjects linkops.DeployLinkObjects
101+
102+
// CCIP
103+
ccipPackageId string
104+
ccipObjects ccipops.DeployCCIPSeqObjects
105+
106+
// Router
107+
ccipRouterPackageId string
108+
ccipRouterObjects routerops.DeployCCIPRouterObjects
109+
110+
// Onramp
111+
ccipOnrampPackageId string
112+
ccipOnrampObjects onrampops.DeployCCIPOnRampSeqObjects
113+
114+
// offramp
115+
ccipOfframpPackageId string
116+
ccipOfframpObjects offrampops.DeployCCIPOffRampSeqObjects
88117
}
89118

119+
// TODO: refactor so suites are per product
90120
func (s *MCMSTestSuite) SetupSuite() {
91121
signer, client := testenv.SetupEnvironment(s.T())
92122
deps := sui_ops.OpTxDeps{
@@ -169,6 +199,149 @@ func (s *MCMSTestSuite) SetupSuite() {
169199
})
170200
s.Require().NoError(err, "executing ownership transfer to self")
171201
s.T().Logf("✅ Transferred ownership of MCMS to itself in tx: %s", rep.Output.Digest)
202+
203+
s.SetupCCIP()
204+
}
205+
206+
func (s *MCMSTestSuite) SetupCCIP() {
207+
// Deploy LINK
208+
linkReport, err := cld_ops.ExecuteOperation(s.bundle, linkops.DeployLINKOp, s.deps, cld_ops.EmptyInput{})
209+
require.NoError(s.T(), err, "failed to deploy LINK token")
210+
s.linkPackageId = linkReport.Output.PackageId
211+
s.linkObjects = linkReport.Output.Objects
212+
213+
configDigestHex := "e3b1c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
214+
configDigest, err := hex.DecodeString(configDigestHex)
215+
require.NoError(s.T(), err, "failed to decode config digest")
216+
217+
publicKey1Hex := "8a1b2c3d4e5f60718293a4b5c6d7e8f901234567"
218+
publicKey1, err := hex.DecodeString(publicKey1Hex)
219+
require.NoError(s.T(), err, "failed to decode public key 1")
220+
221+
publicKey2Hex := "7b8c9dab0c1d2e3f405162738495a6b7c8d9e0f1"
222+
publicKey2, err := hex.DecodeString(publicKey2Hex)
223+
require.NoError(s.T(), err, "failed to decode public key 2")
224+
225+
publicKey3Hex := "1234567890abcdef1234567890abcdef12345678"
226+
publicKey3, err := hex.DecodeString(publicKey3Hex)
227+
require.NoError(s.T(), err, "failed to decode public key 3")
228+
229+
publicKey4Hex := "90abcdef1234567890abcdef1234567890abcdef"
230+
publicKey4, err := hex.DecodeString(publicKey4Hex)
231+
require.NoError(s.T(), err, "failed to decode public key 4")
232+
233+
// Use the same seq as in production deployment
234+
ccipReport, err := cld_ops.ExecuteSequence(s.bundle, ccipops.DeployAndInitCCIPSequence, s.deps, ccipops.DeployAndInitCCIPSeqInput{
235+
LinkTokenCoinMetadataObjectId: linkReport.Output.Objects.CoinMetadataObjectId,
236+
LocalChainSelector: 1,
237+
DestChainSelector: 2,
238+
DeployCCIPInput: ccipops.DeployCCIPInput{
239+
McmsPackageId: s.mcmsPackageID,
240+
McmsOwner: s.mcmsOwnerAddress,
241+
},
242+
MaxFeeJuelsPerMsg: "100000000",
243+
TokenPriceStalenessThreshold: 60,
244+
// Fee Quoter configuration
245+
AddMinFeeUsdCents: []uint32{3000},
246+
AddMaxFeeUsdCents: []uint32{30000},
247+
AddDeciBps: []uint16{1000},
248+
AddDestGasOverhead: []uint32{1000000},
249+
AddDestBytesOverhead: []uint32{1000},
250+
AddIsEnabled: []bool{true},
251+
RemoveTokens: []string{},
252+
// Fee Quoter destination chain configuration
253+
IsEnabled: true,
254+
MaxNumberOfTokensPerMsg: 2,
255+
MaxDataBytes: 2000,
256+
MaxPerMsgGasLimit: 5000000,
257+
DestGasOverhead: 1000000,
258+
DestGasPerPayloadByteBase: byte(2),
259+
DestGasPerPayloadByteHigh: byte(5),
260+
DestGasPerPayloadByteThreshold: uint16(10),
261+
DestDataAvailabilityOverheadGas: 300000,
262+
DestGasPerDataAvailabilityByte: 4,
263+
DestDataAvailabilityMultiplierBps: 1,
264+
ChainFamilySelector: []byte{0x28, 0x12, 0xd5, 0x2c},
265+
EnforceOutOfOrder: false,
266+
DefaultTokenFeeUsdCents: 3,
267+
DefaultTokenDestGasOverhead: 100000,
268+
DefaultTxGasLimit: 500000,
269+
GasMultiplierWeiPerEth: 100,
270+
GasPriceStalenessThreshold: 1000000000,
271+
NetworkFeeUsdCents: 10,
272+
// Premium multiplier updates
273+
PremiumMultiplierWeiPerEth: []uint64{10},
274+
275+
RmnHomeContractConfigDigest: configDigest,
276+
SignerOnchainPublicKeys: [][]byte{publicKey1, publicKey2, publicKey3, publicKey4},
277+
NodeIndexes: []uint64{0, 1, 2, 3},
278+
FSign: uint64(1),
279+
})
280+
require.NoError(s.T(), err, "failed to execute CCIP deploy sequence")
281+
require.NotEmpty(s.T(), ccipReport.Output.CCIPPackageId, "CCIP package ID should not be empty")
282+
283+
s.linkObjects = linkReport.Output.Objects
284+
s.ccipPackageId = ccipReport.Output.CCIPPackageId
285+
s.ccipObjects = ccipReport.Output.Objects
286+
287+
// Deploy Router
288+
routerReport, err := cld_ops.ExecuteOperation(s.bundle, routerops.DeployCCIPRouterOp, s.deps, routerops.DeployCCIPRouterInput{
289+
McmsPackageId: s.mcmsPackageID,
290+
McmsOwner: s.mcmsOwnerAddress,
291+
})
292+
require.NoError(s.T(), err, "failed to execute CCIP deploy sequence")
293+
294+
s.ccipRouterPackageId = routerReport.Output.PackageId
295+
s.ccipRouterObjects = routerReport.Output.Objects
296+
297+
// Deploy Onramp
298+
ccipOnRampSeqInput := deployment.DefaultOnRampSeqConfig
299+
ccipOnRampSeqInput.DeployCCIPOnRampInput.CCIPPackageId = ccipReport.Output.CCIPPackageId
300+
ccipOnRampSeqInput.DeployCCIPOnRampInput.MCMSPackageId = s.mcmsPackageID
301+
ccipOnRampSeqInput.DeployCCIPOnRampInput.MCMSOwnerPackageId = s.mcmsOwnerAddress
302+
ccipOnRampSeqInput.OnRampInitializeInput.NonceManagerCapId = ccipReport.Output.Objects.NonceManagerCapObjectId
303+
ccipOnRampSeqInput.OnRampInitializeInput.SourceTransferCapId = ccipReport.Output.Objects.SourceTransferCapObjectId
304+
ccipOnRampSeqInput.OnRampInitializeInput.ChainSelector = uint64(s.chainSelector)
305+
ccipOnRampSeqInput.OnRampInitializeInput.FeeAggregator = s.mcmsOwnerAddress
306+
ccipOnRampSeqInput.OnRampInitializeInput.AllowListAdmin = s.mcmsOwnerAddress
307+
ccipOnRampSeqInput.OnRampInitializeInput.DestChainSelectors = []uint64{cselectors.ETHEREUM_MAINNET.Selector}
308+
ccipOnRampSeqInput.OnRampInitializeInput.DestChainRouters = []string{routerReport.Output.PackageId}
309+
ccipOnRampSeqInput.ApplyDestChainConfigureOnRampInput.DestChainSelector = []uint64{cselectors.ETHEREUM_MAINNET.Selector}
310+
ccipOnRampSeqInput.ApplyAllowListUpdatesInput.DestChainSelector = []uint64{cselectors.ETHEREUM_MAINNET.Selector}
311+
ccipOnRampSeqInput.ApplyDestChainConfigureOnRampInput.DestChainRouters = []string{routerReport.Output.PackageId}
312+
ccipOnRampSeqInput.ApplyDestChainConfigureOnRampInput.CCIPObjectRefId = ccipReport.Output.Objects.CCIPObjectRefObjectId
313+
314+
ccipOnRampSeqReport, err := operations.ExecuteSequence(s.bundle, onrampops.DeployAndInitCCIPOnRampSequence, s.deps, ccipOnRampSeqInput)
315+
require.NoError(s.T(), err, "failed to execute CCIP OnRamp deploy sequence")
316+
317+
s.ccipOnrampPackageId = ccipOnRampSeqReport.Output.CCIPOnRampPackageId
318+
s.ccipOnrampObjects = ccipOnRampSeqReport.Output.Objects
319+
320+
// Deploy offramp
321+
ccipOffRampSeqInput := deployment.DefaultOffRampSeqConfig
322+
// note: this is a regression, can't acess other chains state very cleanly
323+
onRampBytes := [][]byte{
324+
{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08},
325+
}
326+
327+
// Inject dynamic values for deployment
328+
ccipOffRampSeqInput.CCIPObjectRefId = ccipReport.Output.Objects.CCIPObjectRefObjectId
329+
ccipOffRampSeqInput.DeployCCIPOffRampInput.CCIPPackageId = ccipReport.Output.CCIPPackageId
330+
ccipOffRampSeqInput.DeployCCIPOffRampInput.MCMSPackageId = s.mcmsPackageID
331+
332+
ccipOffRampSeqInput.InitializeOffRampInput.DestTransferCapId = ccipReport.Output.Objects.DestTransferCapObjectId
333+
ccipOffRampSeqInput.InitializeOffRampInput.FeeQuoterCapId = ccipReport.Output.Objects.FeeQuoterCapObjectId
334+
ccipOffRampSeqInput.InitializeOffRampInput.ChainSelector = uint64(s.chainSelector)
335+
ccipOffRampSeqInput.InitializeOffRampInput.SourceChainSelectors = []uint64{
336+
cselectors.ETHEREUM_MAINNET.Selector,
337+
}
338+
ccipOffRampSeqInput.InitializeOffRampInput.SourceChainsOnRamp = onRampBytes
339+
340+
ccipOffRampSeqReport, err := operations.ExecuteSequence(s.bundle, offrampops.DeployAndInitCCIPOffRampSequence, s.deps, ccipOffRampSeqInput)
341+
require.NoError(s.T(), err, "failed to execute CCIP OffRamp deploy sequence")
342+
343+
s.ccipOfframpPackageId = ccipOffRampSeqReport.Output.CCIPOffRampPackageId
344+
s.ccipOfframpObjects = ccipOffRampSeqReport.Output.Objects
172345
}
173346

174347
func (s *MCMSTestSuite) SignProposal(proposal *mcms.Proposal, roleConfig *RoleConfig) {

0 commit comments

Comments
 (0)