8000 Refactor XCM tests to consolidate versions 3, 4, and 5 by RomarQ · Pull Request #3322 · moonbeam-foundation/moonbeam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor XCM tests to consolidate versions 3, 4, and 5 #3322

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RomarQ
Copy link
Contributor
@RomarQ RomarQ commented Jun 21, 2025

Summary

This PR refactors the XCM test files to consolidate duplicated tests for versions 3, 4, and 5 into single test files that iterate through all supported XCM versions, as suggested in PR #3311 review comment.

Changes

  • Added XCM_VERSIONS constant to /test/helpers/xcm.ts for centralized version management
  • Refactored 14 test files in /test/suites/dev/moonbase/test-xcm/ to use version iteration loops
  • Removed 31 redundant version-specific test files from test-xcm-v3, test-xcm-v4, and test-xcm-v5 directories
  • Fixed balance accumulation issues in tests by tracking initial balances and checking differences
  • Added TODO comments for HRMP transact ethereum tests that need fixes for v4/v5

Technical Details

The refactoring pattern uses a for loop to iterate through XCM versions:

for (const xcmVersion of XCM_VERSIONS) {
  it({
    id: `T01-XCM-v${xcmVersion}`,
    title: `Test description (XCM v${xcmVersion})`,
    test: async function () {
      // Test logic with version-specific handling
      if (xcmVersion === 3) {
        xcmMessage = xcmMessage.as_v3();
      } else if (xcmVersion === 4) {
        xcmMessage = xcmMessage.as_v4();
      } else if (xcmVersion === 5) {
        xcmMessage = xcmMessage.as_v5();
      }
    }
  });
}

Test Results

All refactored tests pass successfully, except for known issues with HRMP transact ethereum tests for v4/v5 which have been temporarily limited to v3 only.

Benefits

  • Reduces code duplication by ~66%
  • Simplifies maintenance when adding new XCM versions
  • Ensures consistent testing across all XCM versions
  • Makes it easier to identify version-specific issues

🤖 This refactoring was performed by an AI agent using Claude Code

@RomarQ RomarQ marked this pull request as draft June 21, 2025 23:14
@moonbeam-foundation moonbeam-foundation deleted a comment from coderabbitai bot Jun 21, 2025
Copy link
Contributor
github-actions bot commented Jun 21, 2025

WASM runtime size check:

Compared to target branch

Moonbase runtime: 2368 KB (no changes) ✅

Moonbeam runtime: 2356 KB (-4 KB) ✅

Moonriver runtime: 2352 KB (no changes) ✅

Compared to latest release (runtime-3701)

Moonbase runtime: 2368 KB (+312 KB compared to latest release) ⚠️

Moonbeam runtime: 2356 KB (+308 KB compared to latest release) ⚠️

Moonriver runtime: 2352 KB (+300 KB compared to latest release) ⚠️

@RomarQ RomarQ added B0-silent Changes should not be mentioned in any release notes I4-tests 🎯 Tests need fixing, improving or augmenting. D2-notlive PR doesn't change runtime code (so can't be audited) labels Jun 21, 2025
@moonbeam-foundation moonbeam-foundation deleted a comment from coderabbitai bot Jun 21, 2025
Copy link
Contributor

Coverage Report

@@                         Coverage Diff                         @@
##           master   refactor-xcm-tests-consolidation     +/-   ##
===================================================================
  Coverage   75.39%                             75.39%   0.00%     
  Files         407                                407             
- Lines      101610                             101574     -36     
===================================================================
- Hits        76604                              76573     -31     
- Misses      25006                              25001      -5     
Files Changed Coverage
/node/cli/src/cli.rs 29.79% (+0.32%) 🔼
/pallets/moonbeam-foreign-assets/src/lib.rs 80.21% (-0.11%) 🔽
/pallets/parachain-staking/src/inflation.rs 87.66% (-0.16%) 🔽
/pallets/parachain-staking/src/tests.rs 90.90% (-0.03%) 🔽
/primitives/xcm/src/ethereum_xcm.rs 97.20% (-1.17%) 🔽
/runtime/common/src/apis.rs 85.32% (+0.12%) 🔼
/runtime/common/src/impl_moonbeam_xcm_call_tracing.rs 38.98% (+0.80%) 🔼
/runtime/evm_tracer/src/lib.rs 65.96% (+1.67%) 🔼

Coverage generated Sun Jun 22 00:07:59 UTC 2025

@RomarQ RomarQ marked this pull request as ready for review June 23, 2025 13:04
Copy link
coderabbitai bot commented Jun 23, 2025

Important

Review skipped

Auto reviews are limited to specific labels.

🏷️ Labels to auto review (1)
  • agent-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRa 8000 bbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment on lines +65 to +72
// Convert to appropriate XCM version
if (xcmVersion === 3) {
xcmMessage = xcmMessage.as_v3();
} else if (xcmVersion === 4) {
xcmMessage = xcmMessage.as_v4();
} else if (xcmVersion === 5) {
xcmMessage = xcmMessage.as_v5();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be extracted into a helper method ?

Copy link
Contributor Author
@RomarQ RomarQ Jun 24, 2025

Choose a reason for hiding this comment

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

Yes, this was only a experiment, I will not merge it yet, since I still need to review every file (will mark it as DRAFT). This condition should be moved to an helper method in helpers/xcm.ts.

@RomarQ RomarQ marked this pull request as draft June 24, 2025 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B0-silent Changes should not be mentioned in any release notes D2-notlive PR doesn't change runtime code (so can't be audited) I4-tests 🎯 Tests need fixing, improving or augmenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0