Skip to content

test(role_store): cover revoke-side member-count and enumeration bookkeeping (#564) - #697

Open
trakshan-mishra wants to merge 1 commit into
SO4-Markets:mainfrom
trakshan-mishra:test/role-store-revoke-bookkeeping
Open

test(role_store): cover revoke-side member-count and enumeration bookkeeping (#564)#697
trakshan-mishra wants to merge 1 commit into
SO4-Markets:mainfrom
trakshan-mishra:test/role-store-revoke-bookkeeping

Conversation

@trakshan-mishra

Copy link
Copy Markdown

Description

Closes #564 — adds revoke-side member-count/enumeration bookkeeping tests to role_store.

The test module thoroughly exercises the grant side (test_role_member_enumeration checks count/members after two grants; test_idempotent_grant checks double-grant is a no-op) but never the revoke side:

  • No test checks get_role_member_count after a revoke
  • No test checks get_role_members excludes the revoked account
  • No test exercises idempotent revoke
  • No test revokes from a multi-member role to verify vec_remove_addr removes only the target

What changed

Added three tests mirroring the grant-side coverage:

  1. test_revoke_decrements_count_and_removes_from_members — grant to two accounts, revoke one, assert count decremented by exactly one and get_role_members contains the remaining account but not the revoked one.

  2. test_revoke_from_multi_member_preserves_others — grant to three accounts, revoke the middle one, assert the other two are still present (catches vec_remove_addr removing the wrong entry from a multi-member list).

  3. test_idempotent_revoke — revoke twice, assert the count does not go negative or decrement twice (mirror of test_idempotent_grant).

Also adds a vec_contains_addr test helper (the existing vec_contains_b32 only works for BytesN<32>, not Address).

Verification

cargo test -p role-store   # 14 passed, 0 failed
cargo clippy -p role-store --all-targets -- -D warnings  # 0 warnings

Related issues

Closes #564

…keeping

The test module thoroughly exercises the grant side of role bookkeeping
(test_role_member_enumeration, test_idempotent_grant) but never the
revoke side: no test checks get_role_member_count after a revoke, no
test checks get_role_members excludes the revoked account, and no test
exercises idempotent revoke.

Add three tests mirroring the grant-side coverage:

- test_revoke_decrements_count_and_removes_from_members: grant a role
  to two accounts, revoke one, assert count decremented by exactly one
  and get_role_members contains the remaining account but not the
  revoked one.

- test_revoke_from_multi_member_preserves_others: grant to three
  accounts, revoke the middle one, assert the other two are still
  present (catches vec_remove_addr removing the wrong entry from a
  multi-member list).

- test_idempotent_revoke: revoke twice, assert the count does not go
  negative or decrement twice (mirror of test_idempotent_grant).

cargo test -p role-store: 14 passed, 0 failed.

Closes SO4-Markets#564
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.

role_store: revoke-side member-count/enumeration bookkeeping is completely untested

1 participant