Skip to content

test(learn-token): add dedicated unit tests for query functions - #511

Open
lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:test/learn-token-query-unit-tests-505
Open

lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:test/learn-token-query-unit-tests-505

Conversation

@lmduy2612

Copy link
Copy Markdown

Description

Resolves #505.

This PR adds dedicated unit tests for all 9 learn-token query functions as requested:

  1. get_claim_history (test_get_claim_history_query): verifies claim records match actual reward claims, order is preserved, and returns empty for accounts with no claim history.
  2. get_storage_size (test_get_storage_size_query): verifies that persistent storage counters increase as new entries (mints, allowance spenders, vesting, claim records) are created.
  3. total_minted_to (test_total_minted_to_query): verifies per-address accumulated mint totals across multiple mints and claims, and confirms token transfers do not alter minted totals.
  4. get_vesting_schedule (test_get_vesting_schedule_query): verifies exact schedule parameters for registered beneficiaries and returns None for non-beneficiaries.
  5. permit_nonce (test_permit_nonce_query): verifies nonce initialization to 0 and proper per-address increments upon permit consumption.
  6. get_admins (test_get_admins_query): verifies initial admin listing, additions of admins/pausers, and removals.
  7. has_role (test_has_role_query): verifies role queries and hierarchy (including main admin all-role access and role grants/revocations).
  8. prune_expired_allowance (test_prune_expired_allowance_query): verifies selective removal of expired allowances while preserving active ones, and confirms idempotency.
  9. cleanup_expired_allowances (test_cleanup_expired_allowances_query): verifies bulk allowance sweeps, empty account handling, and spender count tracking.

Additionally resolves test setup syntax splicing and sequence alignment in token_tests.rs.

Testing

  • cargo test --test token_tests: All 87 unit tests passed green.
  • cargo clippy --test token_tests: 0 warnings.

…nLearnOfficial#505)

- Add dedicated unit tests covering:
  - get_claim_history (verifying claim records and empty state)
  - get_storage_size (verifying persistent storage growth across operations)
  - total_minted_to (verifying per-address mint totals vs transfers)
  - get_vesting_schedule (verifying query accuracy for registered/unregistered beneficiaries)
  - permit_nonce (verifying initial state and increments per address)
  - get_admins (verifying admin listings and role assignments)
  - has_role (verifying role hierarchy and queries)
  - prune_expired_allowance (verifying selective pruning and idempotency)
  - cleanup_expired_allowances (verifying bulk expiration sweeps)
- Fix upstream syntax split and ledger sequence alignment in token_tests.rs
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.

get_claim_history and get_storage_size are missing from learn-token unit tests

2 participants