Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Add xcm-simulator #102

Merged
merged 16 commits into from
Jan 11, 2023
Merged

Add xcm-simulator #102

merged 16 commits into from
Jan 11, 2023

Conversation

evilrobot-01
Copy link
Contributor

@evilrobot-01 evilrobot-01 commented Jan 7, 2023

Adds a xcm-simulator, based on the example within the Polkadot repository, with Trappist-specific use cases as tests. Each closure scope in each test can be thought of as a block on the corresponding chain, with messages being dispatched to target chains via the mock message queue as it goes out of scope.

It effectively translates the integration tests in #76 into Rust with the following main benefits:

  • enables interactive debugging with breakpoints, allowing stepping through code to see exactly what is going on as messages are processed across chains
  • uses existing runtime config as much as possible, simulating actual runtime interactions as best as possible
  • shows xcm tracing output in test console for further additional insight

The tests can simply be run from the command line as follows, assuming one is in the root folder of the project, but the real value is running the tests with a debugger and breakpoints to explore how the instructions are handled by the xcm-executor. Note also that the crate is excluded from the workspace, effectively making it 'opt-in'.

cd xcm-simulator; cargo test; cd ..

Potential next steps:

  • implement a helper function for determining fees, better demonstrating the relationships between xcm weights/fees
  • add GH action to run when creating PRs, ensuring no regressions in cross-chain functionality

Any other suggestions for improvement welcome!

Copy link
Contributor

@stiiifff stiiifff left a comment

Choose a reason for hiding this comment

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

Great work @evilrobot-01, this is a super valuable addition to the repo.
Can you add instructions in the README on how to run the tests ?
Also, as you mentioned it, it would be nice to run these as part of a CI task.

@evilrobot-01
Copy link
Contributor Author

Updated the PR description with a crude way to run the tests. Will update the readme and add a separate GH action for now, which can always be incorporated into the main CI flow as/when required.

@stiiifff stiiifff linked an issue Jan 10, 2023 that may be closed by this pull request
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@evilrobot-01
Copy link
Contributor Author

Updated the readme, thanks to additional information from @bernardoaraujor 🙌, and then also added a separate CI workflow which outputs the test results as an artifact. I had hoped to also include the xcm-executor tracing output as further demonstration of what is available from the simulations, but nextest doesnt currently support this for passing tests so I have opened a feature request issue there.

PS - nextest used in CI as it allows converting results into junit format for nicer reporting using test-reporter. Happy to hear of any better alternatives, haven't explored the GH test reporting landscape for a few months.

@evilrobot-01 evilrobot-01 enabled auto-merge (squash) January 11, 2023 08:59
@stiiifff
Copy link
Contributor

@evilrobot-01 Super cool, I love the test report. Should we add a badge to the README with the latest "XCM tests" status ?

@evilrobot-01
Copy link
Contributor Author

evilrobot-01 commented Jan 11, 2023

Sure, any preference on location? Could add one for the build at the same time.

@evilrobot-01 evilrobot-01 merged commit c81fab8 into master Jan 11, 2023
@evilrobot-01 evilrobot-01 deleted the frank/xcm-simulator branch January 11, 2023 13:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement cross-chain message unit tests using xcm-simulator
3 participants