Skip to content

fix(CCIP): increase timeout for cross-chain Aptos token transfer test#22221

Open
sebawo wants to merge 2 commits intodevelopfrom
fix/ccip-11174-aptos-timeout
Open

fix(CCIP): increase timeout for cross-chain Aptos token transfer test#22221
sebawo wants to merge 2 commits intodevelopfrom
fix/ccip-11174-aptos-timeout

Conversation

@sebawo
Copy link
Copy Markdown
Contributor

@sebawo sebawo commented Apr 28, 2026

Summary

Fixes flaky test CCIP-11174: Test_CCIP_TokenTransfer_BnM_Aptos2EVM

Problem

The test is flaky due to insufficient context timeout for cross-chain finality. When transferring BnM tokens from Aptos to EVM, the
test performs sequential waits across heterogeneous blockchains:

  1. ConfirmMultipleCommits - Waits for Aptos consensus confirmation
  2. ConfirmExecWithSeqNrsForAll - Waits for cross-chain attestation finality
  3. WaitForTokenBalances - Waits for token balance updates across chains

Aptos and EVM have different consensus times and finality guarantees. The sequential nature of these operations can exceed Go's
default context timeout in slow/congested network conditions.

Solution

Increased context timeout from default to 10 minutes (10*time.Minute).

This conservative estimate accommodates:

  • Worst-case Aptos consensus finality (~30-60 seconds)
  • Cross-chain message relay delay (~2-3 minutes in slow conditions)
  • EVM confirmation time (~30-60 seconds)
  • Network latency and processing overhead

The 10-minute window is safe for production environments while preventing test timeouts during normal operation.

Changes

  • Added context and time imports
  • Wrapped test context with explicit timeout using context.WithTimeout
  • Added defer cancel() for proper resource cleanup

Testing

This fix enables the test to run reliably in CI/CD pipelines against testnet environments with variable network conditions.

  Test_CCIP_TokenTransfer_BnM_Aptos2EVM flakes due to insufficient context timeout.
  Cross-chain finality requires sequential waits across heterogeneous blockchains:
  - ConfirmMultipleCommits (Aptos consensus)
  - ConfirmExecWithSeqNrsForAll (cross-chain attestation)
  - WaitForTokenBalances (token availability across chains)

  These operations can exceed Go's default context timeout since Aptos and EVM
  have different consensus finality times.

  Increase context timeout to 10 minutes to accommodate worst-case cross-chain
  finality latency.

  Fixes: CCIP-11174
Copilot AI review requested due to automatic review settings April 28, 2026 15:06
@sebawo sebawo requested review from a team as code owners April 28, 2026 15:06
@github-actions
Copy link
Copy Markdown
Contributor

👋 sebawo, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

✅ No conflicts with other open PRs targeting develop

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Risk Rating: LOW (test-only change), but currently introduces a compile error.

Increases the context timeout for the flaky cross-chain Aptos→EVM token transfer smoke test to reduce timeouts during slow finality/relay conditions.

Changes:

  • Add context/time imports.
  • Wrap t.Context() with context.WithTimeout(..., 10*time.Minute) and defer cancel() in Test_CCIP_TokenTransfer_BnM_Aptos2EVM.

// can exceed default context timeout. Allow up to 10 minutes for all confirmations.
rootCtx := t.Context()
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(rootCtx, 10*time.Minute)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx is no longer declared after removing ctx := t.Context(), but the new code uses assignment (ctx, cancel = ...). This won’t compile unless ctx is declared earlier in the function. Use a short declaration (ctx, cancel := context.WithTimeout(...)) or explicitly declare var ctx context.Context before assigning.

Suggested change
ctx, cancel = context.WithTimeout(rootCtx, 10*time.Minute)
ctx, cancel := context.WithTimeout(rootCtx, 10*time.Minute)

Copilot uses AI. Check for mistakes.
@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Apr 28, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

Use short variable declaration (:=) instead of assignment (=) so ctx
is properly declared in scope.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@cl-sonarqube-production
Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants