Repository navigation
test(contracts): Add shared test-utils crate with mocks, helpers and TestEnv - #1264
Open
Damilorlar wants to merge 3 commits into
Open
Damilorlar wants to merge 3 commits into
Damilorlar wants to merge 3 commits into
Conversation
|
@Damilorlar Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…dger helpers - Created test-utils crate exposing MockToken, MockOracle and MockReceiver contracts - Added helpers: advance_ledgers(env, n), set_timestamp(env, ts) and fund(env, account, amount) - Added TestEnv builder deploying the protocol with default config and returning typed clients - Added assertion helpers for events, such as assert_event(env, topic, data) Closes accesslayerorg#1260 Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
Member
✅ PR Ready for ReviewDue to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging. This PR has passed all automated checks:
Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#closed #1260
Previously, each contract test file built its own mock token, oracle and time helpers. This duplicated code and hid subtle differences between tests, so two tests that looked like they exercised the same setup could behave differently.
This PR adds a shared contracts/test-utils crate used by the contract tests, and migrates three existing test modules to it.
What changed
-Created the contracts/test-utils crate exposing MockToken, MockOracle and MockReceiver contracts.
-Added helpers: advance_ledgers(env, n), set_timestamp(env, ts) and fund(env, token, account, amount).
-Added a TestEnv builder that deploys the protocol with the default config in one call and returns typed clients.
-Added event assertion helpers such as assert_event(env, topic, data). On a mismatch they fail with a readable diff showing the expected event next to the events actually emitted.
-Migrated [module A, module B, module C] to the shared crate. Their behavior is unchanged and the tests pass as before.
-Documented every helper with examples in docs/testing.md.
-test-utils is added only under [dev-dependencies], so no production crate depends on it and it never ends up in a deployed contract.
Tests
-[A small test for the helpers themselves, e.g. fund updates balances, advance_ledgers moves the sequence, assert_event fails on a mismatch.]
Checklist
[ ] The crate compiles as a dev-dependency across the workspace (cargo build --workspace)
[ ] cargo test --workspace passes
[ ] TestEnv deploys the protocol with one call
[ ] Docs in docs/testing.md cover each helper
[ ] No production crate lists test-utils as a dependency
[ ] Changelog fragment added, if the repo uses one