Skip to content

test: add tests for issues #461, #464, #472, #476 - #596

Open
kokobutter-web wants to merge 1 commit into
BCPathway:mainfrom
kokobutter-web:fix/test-461-464-472-476
Open

test: add tests for issues #461, #464, #472, #476#596
kokobutter-web wants to merge 1 commit into
BCPathway:mainfrom
kokobutter-web:fix/test-461-464-472-476

Conversation

@kokobutter-web

Copy link
Copy Markdown

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: Added set_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: Modified pause and unpause methods to accept a caller: Address parameter. The contract now checks whether the caller is the admin or holds the Pauser role before allowing pause/unpause operations. Admin callers use admin_address.require_auth(), while pauser callers use caller.require_auth().
  • contracts/token/src/test.rs: Added five new tests:
    • test_pauser_can_pause — verifies a pauser can pause the contract
    • test_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 pause
    • test_non_pauser_cannot_unpause — verifies unauthorized callers cannot unpause
    • test_revoked_pauser_cannot_unpause — verifies a pauser whose role was revoked can no longer unpause
  • sdk/src/client.ts: Updated pause and unpause SDK 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: Added test_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: Added test_non_super_admin_cannot_grant_minter — explicitly verifies that a non-SuperAdmin caller (without the SuperAdmin or Admin role) cannot grant the Minter role, receiving AdminError::UnauthorizedRole (error code 3).

#476 — Fuzz: grant_role with random addresses

  • contracts/admin/src/proptest.rs (new file): Added property-based tests using proptest that verify grant_role and revoke_role behave correctly with randomly generated addresses:
    • test_grant_role_with_random_addresses — verifies that after granting a role to random addresses, has_role returns 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 makes has_role return false.
  • contracts/admin/Cargo.toml: Added proptest = "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.

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
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant