Skip to content

test: adversarial coverage for get_whitelist (#1107) - #1225

Closed
Manager-dev1515 wants to merge 1 commit into
RevoraOrg:masterfrom
Manager-dev1515:test/adversarial-get-whitelist-1107
Closed

Manager-dev1515 wants to merge 1 commit into
RevoraOrg:masterfrom
Manager-dev1515:test/adversarial-get-whitelist-1107

Conversation

@Manager-dev1515

Copy link
Copy Markdown

Adds src/test_get_whitelist.rs — a focused, standalone test module with 21 deterministic tests covering every meaningful behaviour of the get_whitelist(env, issuer, namespace, token) -> Vec

query.

What changed

src/test_get_whitelist.rs (new file)
21 tests across 14 categories — all passing in CI (Ubuntu, cargo test).

src/lib.rs
Added '#[cfg(test)] mod test_get_whitelist;' to the test-module registry.

Coverage added

Category Test name
Empty / uninitialized state get_whitelist_returns_empty_vec_for_unregistered_offering
Empty after register, no adds get_whitelist_empty_after_register_no_adds
Single entry get_whitelist_single_entry
Multiple entries get_whitelist_returns_all_members
Removal reflected get_whitelist_reflects_removal
Full add/remove round-trip get_whitelist_empty_after_all_removed
Idempotent add (no duplicates) get_whitelist_no_duplicate_after_double_add
Namespace isolation get_whitelist_is_isolated_by_namespace
Token isolation get_whitelist_is_isolated_by_token
Issuer isolation get_whitelist_is_isolated_by_issuer
Wrong-issuer boundary get_whitelist_wrong_issuer_returns_empty
Wrong-namespace boundary get_whitelist_wrong_namespace_returns_empty
Wrong-token boundary get_whitelist_wrong_token_returns_empty
Read does not mutate storage get_whitelist_read_does_not_mutate_storage
Cross-offering non-interference get_whitelist_cross_offering_no_interference
Blacklist has no effect on list get_whitelist_unaffected_by_blacklist
Frozen contract still readable get_whitelist_readable_when_contract_frozen
Paused contract still readable get_whitelist_readable_when_contract_paused
Frozen offering still readable get_whitelist_readable_when_offering_frozen
Admin-added entries visible get_whitelist_entries_added_by_admin_are_visible
Count consistent with is_whitelisted get_whitelist_count_consistent_with_is_whitelisted

Why each category matters

  • Empty/unregistered: confirms graceful degradation to empty Vec (no panic).
  • Namespace/token/issuer isolation: the storage key is a composite (issuer, namespace, token) triple; each axis must be tested independently to prove there is no key-collision that would let one offering read another's whitelist.
  • Wrong-key boundary probes: adversarial callers supplying a valid-looking but incorrect key component must always receive an empty Vec, never a panic or a foreign list.
  • Read immutability: two sequential reads must produce identical output, confirming get_whitelist has no write side-effect.
  • Frozen/paused/offering-frozen: read-only queries must remain available even when state-mutation is blocked; this verifies the absence of a spurious require_not_frozen / require_not_paused guard on the read path.
  • Blacklist non-interference: the blacklist and whitelist are stored in separate maps; adding to one must not corrupt the other.
  • Admin writes visible: confirms admin-initiated whitelist_add commits to the same storage key that get_whitelist reads, closing a potential split-brain between caller roles.
  • is_whitelisted consistency: every address in get_whitelist must return true from is_whitelisted, and absent addresses must return false.

Public contract preservation

get_whitelist signature and behaviour are unchanged. No production code was modified; the only lib.rs change is the #[cfg(test)] module declaration.

Closes #1107

@drips-wave

drips-wave Bot commented Sep 27, 2026

Copy link
Copy Markdown

@Manager-dev1515 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

Adds src/test_get_whitelist.rs — a focused, standalone test module with
21 deterministic tests covering every meaningful behaviour of the
get_whitelist(env, issuer, namespace, token) -> Vec<Address> query.

src/test_get_whitelist.rs  (new file)
  21 tests across 14 categories — all passing in CI (Ubuntu, cargo test).

src/lib.rs
  Added '#[cfg(test)] mod test_get_whitelist;' to the test-module registry.

| Category                               | Test name                                                |
|----------------------------------------|----------------------------------------------------------|
| Empty / uninitialized state            | get_whitelist_returns_empty_vec_for_unregistered_offering|
| Empty after register, no adds          | get_whitelist_empty_after_register_no_adds               |
| Single entry                           | get_whitelist_single_entry                               |
| Multiple entries                       | get_whitelist_returns_all_members                        |
| Removal reflected                      | get_whitelist_reflects_removal                           |
| Full add/remove round-trip             | get_whitelist_empty_after_all_removed                    |
| Idempotent add (no duplicates)         | get_whitelist_no_duplicate_after_double_add              |
| Namespace isolation                    | get_whitelist_is_isolated_by_namespace                   |
| Token isolation                        | get_whitelist_is_isolated_by_token                       |
| Issuer isolation                       | get_whitelist_is_isolated_by_issuer                      |
| Wrong-issuer boundary                  | get_whitelist_wrong_issuer_returns_empty                 |
| Wrong-namespace boundary               | get_whitelist_wrong_namespace_returns_empty              |
| Wrong-token boundary                   | get_whitelist_wrong_token_returns_empty                  |
| Read does not mutate storage           | get_whitelist_read_does_not_mutate_storage               |
| Cross-offering non-interference        | get_whitelist_cross_offering_no_interference             |
| Blacklist has no effect on list        | get_whitelist_unaffected_by_blacklist                    |
| Frozen contract still readable         | get_whitelist_readable_when_contract_frozen              |
| Paused contract still readable         | get_whitelist_readable_when_contract_paused              |
| Frozen offering still readable         | get_whitelist_readable_when_offering_frozen              |
| Admin-added entries visible            | get_whitelist_entries_added_by_admin_are_visible         |
| Count consistent with is_whitelisted   | get_whitelist_count_consistent_with_is_whitelisted       |

- Empty/unregistered: confirms graceful degradation to empty Vec (no panic).
- Namespace/token/issuer isolation: the storage key is a composite
  (issuer, namespace, token) triple; each axis must be tested independently
  to prove there is no key-collision that would let one offering read
  another's whitelist.
- Wrong-key boundary probes: adversarial callers supplying a valid-looking
  but incorrect key component must always receive an empty Vec, never a
  panic or a foreign list.
- Read immutability: two sequential reads must produce identical output,
  confirming get_whitelist has no write side-effect.
- Frozen/paused/offering-frozen: read-only queries must remain available
  even when state-mutation is blocked; this verifies the absence of a
  spurious require_not_frozen / require_not_paused guard on the read path.
- Blacklist non-interference: the blacklist and whitelist are stored in
  separate maps; adding to one must not corrupt the other.
- Admin writes visible: confirms admin-initiated whitelist_add commits to
  the same storage key that get_whitelist reads, closing a potential
  split-brain between caller roles.
- is_whitelisted consistency: every address in get_whitelist must return
  true from is_whitelisted, and absent addresses must return false.

get_whitelist signature and behaviour are unchanged.  No production code
was modified; the only lib.rs change is the #[cfg(test)] module declaration.

Closes RevoraOrg#1107
@Manager-dev1515
Manager-dev1515 force-pushed the test/adversarial-get-whitelist-1107 branch from d580124 to 6f12c0f Compare October 15, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add adversarial coverage for get_whitelist in lib

3 participants