Skip to content

Commit

Permalink
[CCIP-2563] [CCIP-2422] Adds Different TransferConfig Scenarios to On…
Browse files Browse the repository at this point in the history
…Ramp and OffRamp Tests (#1030)

## Motivation

Smoke test coverage is light on different transfer configuration
combinations.

## Solution

* Adds a transfer config smoke test to check different combinations of
bps and agg limits to ensure they can transfer properly
* Adds more explicit tests around `Capacity` and `AggregateRateLimits`
for `OffRamp` and `OnRamp` by expanding the `TestSmokeCCIPOnRampLimits`
and `TestSmokeCCIPOffRampLimits` tests.
  • Loading branch information
kalverra authored Jun 27, 2024
1 parent 6374efb commit cf5caf4
Show file tree
Hide file tree
Showing 9 changed files with 362 additions and 234 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,24 @@ jobs:
os: ubuntu-latest
file: ccip
run: -run ^TestSmokeCCIPManuallyExecuteAfterExecutionFailingDueToInsufficientGas$
- name: ccip-smoke-self-serve-offramp-arl
- name: ccip-smoke-on-ramp-limits
nodes: 1
dir: ccip-tests/smoke
os: ubuntu-latest
file: ccip
run: -run ^TestSmokeCCIPSelfServeRateLimitOffRamp$
- name: ccip-smoke-self-serve-onramp-arl
run: -run ^TestSmokeCCIPOnRampLimits$
- name: ccip-smoke-off-ramp-capacity
nodes: 1
dir: ccip-tests/smoke
os: ubuntu-latest
file: ccip
run: -run ^TestSmokeCCIPSelfServeRateLimitOnRamp$
run: -run ^TestSmokeCCIPOffRampCapacityLimit$
- name: ccip-smoke-off-ramp-agg-rate-limit
nodes: 1
dir: ccip-tests/smoke
os: ubuntu-latest
file: ccip
run: -run ^TestSmokeCCIPOffRampAggRateLimit$
- name: runlog
id: runlog
nodes: 2
Expand Down
13 changes: 10 additions & 3 deletions integration-tests/ccip-tests/actions/ccip_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const (

defaultUSDCDestBytesOverhead = 640
defaultUSDCDestGasOverhead = 120_000
DefaultDestinationGasLimit = 600_000
// DefaultResubscriptionTimeout denotes the max backoff duration for resubscription for various watch events
// if the subscription keeps failing even after this duration, the test will fail
DefaultResubscriptionTimeout = 2 * time.Hour
Expand Down Expand Up @@ -1502,6 +1503,9 @@ func (sourceCCIP *SourceCCIPModule) UpdateBalance(
) {
if len(sourceCCIP.TransferAmount) > 0 {
for i := range sourceCCIP.TransferAmount {
if sourceCCIP.TransferAmount[i] == nil { // nil transfer amount means no transfer for this token
continue
}
// if length of sourceCCIP.TransferAmount is more than available bridge token use first bridge token
token := sourceCCIP.Common.BridgeTokens[0]
if i < len(sourceCCIP.Common.BridgeTokens) {
Expand Down Expand Up @@ -1632,7 +1636,7 @@ func (sourceCCIP *SourceCCIPModule) AssertEventCCIPSendRequested(
seqNum := sendRequestedEvent.SequenceNumber
lggr = ptr.Ptr(lggr.With().
Uint64("SequenceNumber", seqNum).
Str("msgId ", fmt.Sprintf("0x%x", sendRequestedEvent.MessageId[:])).
Str("MsgID", fmt.Sprintf("0x%x", sendRequestedEvent.MessageId[:])).
Logger())
// prevEventAt is the time when the message was successful, this should be same as the time when the event was emitted
reqStat[i].UpdateState(lggr, seqNum, testreporters.CCIPSendRe, 0, testreporters.Success,
Expand Down Expand Up @@ -1691,6 +1695,9 @@ func (sourceCCIP *SourceCCIPModule) CCIPMsg(

tokenAndAmounts := []router.ClientEVMTokenAmount{}
for i, amount := range sourceCCIP.TransferAmount {
if amount == nil { // make nil transfer amount 0 to avoid panics
sourceCCIP.TransferAmount[i] = big.NewInt(0)
}
token := sourceCCIP.Common.BridgeTokens[0]
// if length of sourceCCIP.TransferAmount is more than available bridge token use first bridge token
if i < len(sourceCCIP.Common.BridgeTokens) {
Expand Down Expand Up @@ -2755,7 +2762,7 @@ func (lane *CCIPLane) AddToSentReqs(txHash common.Hash, reqStats []*testreporter
func (lane *CCIPLane) Multicall(noOfRequests int, multiSendAddr common.Address) error {
var ccipMultipleMsg []contracts.CCIPMsgData
feeToken := common.HexToAddress(lane.Source.Common.FeeToken.Address())
genericMsg, err := lane.Source.CCIPMsg(lane.Dest.ReceiverDapp.EthAddress, big.NewInt(600_000))
genericMsg, err := lane.Source.CCIPMsg(lane.Dest.ReceiverDapp.EthAddress, big.NewInt(DefaultDestinationGasLimit))
if err != nil {
return fmt.Errorf("failed to form the ccip message: %w", err)
}
Expand Down Expand Up @@ -2984,7 +2991,7 @@ func (lane *CCIPLane) ExecuteManually(options ...ManualExecutionOption) error {
OnRamp: lane.Source.OnRamp.Address(),
OffRamp: lane.Dest.OffRamp.Address(),
SendReqLogIndex: logIndex,
GasLimit: big.NewInt(600_000),
GasLimit: big.NewInt(DefaultDestinationGasLimit),
}
timeNow := time.Now().UTC()
tx, err := args.ExecuteManually()
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/ccip-tests/chaos/ccip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestChaosCCIP(t *testing.T) {

lane.RecordStateBeforeTransfer()
// Send the ccip-request and verify ocr2 is running
err := lane.SendRequests(1, big.NewInt(600_000))
err := lane.SendRequests(1, big.NewInt(actions.DefaultDestinationGasLimit))
require.NoError(t, err)
lane.ValidateRequests(nil)

Expand All @@ -139,7 +139,7 @@ func TestChaosCCIP(t *testing.T) {
})
lane.RecordStateBeforeTransfer()
// Now send the ccip-request while the chaos is at play
err = lane.SendRequests(numOfRequests, big.NewInt(600_000))
err = lane.SendRequests(numOfRequests, big.NewInt(actions.DefaultDestinationGasLimit))
require.NoError(t, err)
if in.waitForChaosRecovery {
// wait for chaos to be recovered before further validation
Expand Down
1 change: 1 addition & 0 deletions integration-tests/ccip-tests/contracts/contract_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,7 @@ func (onRamp *OnRamp) SetNops() error {
return onRamp.client.ProcessTransaction(tx)
}

// SetTokenTransferFeeConfig sets the token transfer fee configuration for the OnRamp
func (onRamp *OnRamp) SetTokenTransferFeeConfig(tokenTransferFeeConfig []evm_2_evm_onramp.EVM2EVMOnRampTokenTransferFeeConfigArgs) error {
opts, err := onRamp.client.TransactionOpts(onRamp.client.GetDefaultWallet())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ccip-tests/load/ccip_loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (c *CCIPE2ELoad) Validate(lggr zerolog.Logger, sendTx *types.Transaction, t
for _, msgLog := range msgLogs {
seqNum := msgLog.SequenceNumber
var reqStat *testreporters.RequestStat
lggr = lggr.With().Str("msgId ", fmt.Sprintf("0x%x", msgLog.MessageId[:])).Logger()
lggr = lggr.With().Str("MsgID", fmt.Sprintf("0x%x", msgLog.MessageId[:])).Logger()
for _, stat := range stats {
if stat.SeqNum == seqNum {
reqStat = stat
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ccip-tests/load/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (l *LoadArgs) ValidateCurseFollowedByUncurse() {
lane.Source.TransferAmount = []*big.Int{}
failedTx, _, _, err := lane.Source.SendRequest(
lane.Dest.ReceiverDapp.EthAddress,
big.NewInt(600_000), // gas limit
big.NewInt(actions.DefaultDestinationGasLimit), // gas limit
)
if lane.Source.Common.ChainClient.GetNetworkConfig().MinimumConfirmations > 0 {
require.Error(l.t, err)
Expand Down
Loading

0 comments on commit cf5caf4

Please sign in to comment.