test: admin role separation, batch operations, allowance cleanup, error handling - #369
Merged
DeFiVC merged 2 commits intoAug 30, 2026
Conversation
Adds integration tests for admin role separation (minter vs pauser) and batch-style claim/module/quiz flows, plus unit tests for expired allowance cleanup and typed AlreadyInitialized error handling across all three contracts. Re-exports AdminRole from learn-token so tests can construct role values, following the existing Proposal/VestingSchedule export pattern.
|
@privexlabs 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! 🚀 |
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.
Summary
Adds the four test suites requested for this wave: integration coverage for
admin role separation and batch-style operations on the ChainLearn
contracts, plus unit coverage for expired-allowance storage cleanup and
typed error handling.
Changes
tests/integration/admin_role_flow.rs(new): verifies that the Minterand Pauser roles on
learn-tokenare enforced independently (a mintercan mint but not pause; a pauser can pause/unpause but not mint), that
granting/revoking roles takes effect immediately, and that
role_granted/
role_revokedevents are emitted with the correct address.tests/integration/batch_operations.rs(new): verifiesbatch_claim_rewardprocesses multiple quizzes independently (analready-claimed quiz is skipped without blocking the others), and
exercises batch-style module completion and quiz submission flows
against
progress-tracker.tests/unit/token_tests.rs: adds a test thatcleanup_expired_allowancesremoves only expired allowances, preserves valid ones, shrinks the
spender registry accordingly, and is a no-op on a second pass.
tests/unit/token_tests.rs,tests/unit/progress_tests.rs,tests/unit/credential_tests.rs: each adds a test asserting thatcalling
initializea second time returns the typedContractError::AlreadyInitializederror (viatry_initialize) ratherthan an untyped panic.
contracts/learn-token/src/lib.rs: re-exportsAdminRolealongside theexisting
Proposal/VestingSchedulere-exports so external tests canreference it, since it's defined in the crate's private
storagemodule.
Cargo.toml: registers the two new integration test files as[[test]]targets, matching the existing pattern for every other testfile in the repo.
Issues
Resolves #282
Resolves #283
Resolves #284
Resolves #285
Verification
Changes were reviewed manually:
git status,git diff --stat, and thefull
git diffwere inspected line by line against the current contractsource (role/storage/event APIs) to confirm every call matches existing
function signatures and conventions.
cargo buildandcargo testwereNOT run, per instructions; no test execution or compilation was performed.