test: add tests for issues #461, #464, #472, #476 - #596
Open
kokobutter-web wants to merge 1 commit into
Open
Conversation
BCPathway#476 - Add pauser pause/unpause support in token contract and lifecycle module - Add test_super_admin_can_grant_minter (BCPathway#461) - Add test_non_super_admin_cannot_grant_minter (BCPathway#464) - Add proptest for grant_role with random addresses (BCPathway#476) - Add pauser can pause/unpause tests (BCPathway#472) - Update SDK pause/unpause to pass caller address
|
@kokobutter-web 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
This PR adds test coverage for four testing gaps in the bc-forge admin and token contracts, as described in the following issues:
Changes
#472 — Pauser can unpause successfully
contracts/lifecycle/src/lib.rs: Addedset_paused(env, paused)helper that allows setting the paused state without requiring admin auth. This enables the token contract to support pauser-initiated pause/unpause operations.contracts/token/src/lib.rs: Modifiedpauseandunpausemethods to accept acaller: Addressparameter. The contract now checks whether the caller is the admin or holds thePauserrole before allowing pause/unpause operations. Admin callers useadmin_address.require_auth(), while pauser callers usecaller.require_auth().contracts/token/src/test.rs: Added five new tests:test_pauser_can_pause— verifies a pauser can pause the contracttest_pauser_can_unpause— verifies a pauser can unpause the contract (core fix for [Testing] Test: Pauser can unpause successfully #472)test_non_pauser_cannot_pause— verifies unauthorized callers cannot pausetest_non_pauser_cannot_unpause— verifies unauthorized callers cannot unpausetest_revoked_pauser_cannot_unpause— verifies a pauser whose role was revoked can no longer unpausesdk/src/client.ts: UpdatedpauseandunpauseSDK methods to pass the caller's public key as the first argument, matching the new contract signatures.#461 — SuperAdmin can grant Minter
contracts/admin/src/lib.rs: Addedtest_super_admin_can_grant_minter— explicitly verifies that a SuperAdmin can grant the Minter role to an address.#464 — Non-SuperAdmin cannot grant Minter
contracts/admin/src/lib.rs: Addedtest_non_super_admin_cannot_grant_minter— explicitly verifies that a non-SuperAdmin caller (without the SuperAdmin or Admin role) cannot grant the Minter role, receivingAdminError::UnauthorizedRole(error code 3).#476 — Fuzz: grant_role with random addresses
contracts/admin/src/proptest.rs(new file): Added property-based tests usingproptestthat verifygrant_roleandrevoke_rolebehave correctly with randomly generated addresses:test_grant_role_with_random_addresses— verifies that after granting a role to random addresses,has_rolereturns true for those addresses.test_random_address_lacks_ungranted_role— verifies that a random address does not hold roles it was never granted.test_revoke_role_with_random_address— verifies that revoking a role from a random address makeshas_rolereturn false.contracts/admin/Cargo.toml: Addedproptest = "1.4.0"as a dev-dependency.Testing
All new tests follow the existing patterns in the codebase and use
mock_all_auths()for Soroban test environment simulation. The proptest runs 50 cases per property to ensure broad coverage of random address inputs.