test: add simulation tests
Description
Add simulation tests to the node repository Use the following commands to run
make -f sims.mk test-sim-nondeterminism
make -f sims.mk test-sim-fullappsimulation
Closes : https://github.com/zeta-chain/node/issues/2960
The simulation tests would be added into the the CI as part of this issue : https://github.com/zeta-chain/node/issues/2960
How Has This Been Tested?
- [ ] Tested CCTX in localnet
- [ ] Tested in development environment
- [ ] Go unit tests
- [ ] Go integration tests
- [ ] Tested via GitHub Actions
Summary by CodeRabbit
Release Notes
-
New Features
- Introduced a new module management system for enhanced modularity within the application.
- Added support for simulation tests, including various test targets for different simulation scenarios.
-
Bug Fixes
- Resolved issues with voting mechanisms and transaction processing on EVM chains.
-
Documentation
- Updated changelog to reflect new features, refactors, and improvements across multiple versions.
-
Chores
- Added a new Makefile to facilitate simulation test execution.
-
Tests
- Implemented a comprehensive testing suite for application simulations, focusing on determinism and state export functionality.
[!IMPORTANT]
Review skipped
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
Walkthrough
The pull request introduces significant changes to the application structure, focusing on modularity and simulation capabilities. Key modifications include the addition of a ModuleBasics field in the App struct and the introduction of a new file, modules.go, which centralizes module management. The changelog reflects updates across multiple versions, including new features, refactors, and fixes. Additionally, several new files are created to enhance simulation testing, while some files are removed to streamline the codebase.
Changes
| File Path | Change Summary |
|---|---|
app/app.go |
Added fields: ModuleBasics and sm to App struct; updated RegisterGRPCGatewayRoutes. |
app/modules.go |
Introduced functions: newBasicManagerFromManager and simulationModules for module management. |
changelog.md |
Updated to reflect new features, refactors, and fixes; detailed changes across multiple versions. |
e2e/runner/admin_evm.go |
Streamlined logging by replacing fmt.Sprintf with direct string interpolation. |
e2e/runner/report.go |
Updated PrintTestReports method for formatted printing of test reports. |
sims.mk |
New Makefile created for simulation tests with various targets defined. |
tests/simulation/sim/sim_config.go |
Introduced flags for simulation parameters and functions for configuration management. |
tests/simulation/sim/sim_state.go |
Added functions for generating application states based on genesis or simulation parameters. |
tests/simulation/sim/sim_utils.go |
Added utility functions for initializing the simulation application and printing stats. |
tests/simulation/sim_test.go |
Established testing suite for application simulations, including determinism and state export tests. |
testutil/simapp/default_constants.go |
Removed variable defaultConsensusParams. |
testutil/simapp/simapp.go |
Removed utility functions for setting up simulation application environment. |
Suggested labels
ci, no-changelog, UPGRADE_TESTS, PERFORMANCE_TESTS
Suggested reviewers
- fbac
- skosito
- lumtis
- brewmaster012
- swift1337
- ws4charlie
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 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.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 generate unit testing code.@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.
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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
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.
Codecov Report
Attention: Patch coverage is 27.89969% with 230 lines in your changes missing coverage. Please review.
Project coverage is 64.06%. Comparing base (
3aa68fe) to head (1f744f8). Report is 1 commits behind head on develop.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| tests/simulation/sim/sim_state.go | 0.00% | 189 Missing :warning: |
| tests/simulation/sim/sim_utils.go | 0.00% | 41 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #2947 +/- ##
===========================================
- Coverage 64.47% 64.06% -0.41%
===========================================
Files 409 412 +3
Lines 28641 28960 +319
===========================================
+ Hits 18465 18554 +89
- Misses 9381 9611 +230
Partials 795 795
| Files with missing lines | Coverage Δ | |
|---|---|---|
| tests/simulation/sim/sim_config.go | 100.00% <100.00%> (ø) |
|
| tests/simulation/sim/sim_utils.go | 0.00% <0.00%> (ø) |
|
| tests/simulation/sim/sim_state.go | 0.00% <0.00%> (ø) |
Anyway we can add instruction how to run? Can be added in
docs/developmentwith a link in the readme
c1db4cf4cedc9086d3e3c67a820aea587149f513 I added a simple doc will add more information to it about how the tests work , and the different parameters to adjust
Can we tweak staking params?
The staking hook issue was not ported on
develop: #2968I was curious if setting a unbonding time of 10 seconds could lead to catching the error in the simulation tests
Tried it out , I wasn't able to produce the error . The unbond amount is randomly selected ,
unbondAmt, err := simtypes.RandPositiveInt(r, totalBond)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUndelegate, "invalid unbond amount"), nil, err
}
if unbondAmt.IsZero() {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUndelegate, "unbond amount is zero"), nil, nil
}
msg := types.NewMsgUndelegate(
delAddr, valAddr, sdk.NewCoin(k.BondDenom(ctx), unbondAmt),
)
Which might be the reason that it is not hitting the edge case which caused the panic in our tests