-
Notifications
You must be signed in to change notification settings - Fork 49
test(drive-abci): add comprehensive tests for token query v0 modules#3265
test(drive-abci): add comprehensive tests for token query v0 modules#3265QuantumExplorer merged 1 commit intov3.1-devfrom
Conversation
Issue being fixed or feature implemented
Add unit test coverage for all 10 token query v0 modules in packages/rs-drive-abci/src/query/token_queries/, which previously had 0% coverage.
What was done?
Added 71 comprehensive unit tests across all 10 token query v0/mod.rs files:
| Module | Tests | Coverage Areas |
|---|---|---|
identities_token_balances |
6 | invalid token_id, invalid identity_id, empty state, proof, data, data+proof |
identities_token_infos |
7 | invalid token_id, invalid identity_id, empty state, proof, not_frozen, frozen, data+proof |
identity_token_balances |
6 | invalid identity_id, invalid token_id, empty state, proof, data, data+proof |
identity_token_infos |
6 | invalid identity_id, invalid token_id, empty state, proof, data, data+proof |
token_contract_info |
6 | invalid token_id, not_found, proof, data pos0, data pos1, data+proof |
token_direct_purchase_prices |
9 | empty ids, invalid token_id, empty state, proof, fixed price, variable price, no price, multiple tokens, data+proof |
token_perpetual_distribution_last_claim |
8 | invalid token_id, invalid identity_id, proof, raw without contract, with contract info, invalid contract_id, contract not found, position too large, data+proof |
token_pre_programmed_distributions |
9 | invalid token_id, empty state, proof, data, limit, start_at, invalid start_recipient, no distributions, data+proof |
token_status |
7 | invalid token_id, empty state, proof, not paused, paused, multiple tokens, data+proof |
token_total_supply |
7 | invalid token_id, not found, proof, data token0, data token1, data+proof |
Also added a reusable setup_platform_with_token_state() helper function to query::tests that creates:
- 3 test identities with keys and credits
- A data contract with 3 tokens (including groups, perpetual distributions, and pre-programmed distributions)
- Minted token balances across identities
- Frozen identity state (identity 2 on token 0)
- Paused token state (token 1)
- Direct purchase pricing (fixed for token 1, variable schedule for token 2)
How Has This Been Tested?
All 71 tests pass:
cargo test -p drive-abci -- query::token_queries
test result: ok. 71 passed; 0 failed; 0 ignored; 0 measured; 1313 filtered out
Each test exercises both the validation error paths and the successful query paths (with and without proofs), targeting >93% line coverage for each v0/mod.rs file.
Breaking Changes
None.
Checklist:
- I have performed a self-review of my own code
- I have commented my code, particularly in hard-to-understand areas
- I have added or updated relevant unit/integration/functional/e2e tests
- I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
- I have made corresponding changes to the documentation if needed
Add 71 unit tests covering all code paths in the token_queries
v0/mod.rs files, bringing coverage from 0% to >93% for each module.
Modules covered:
- identities_token_balances (6 tests)
- identities_token_infos (7 tests)
- identity_token_balances (6 tests)
- identity_token_infos (6 tests)
- token_contract_info (6 tests)
- token_direct_purchase_prices (9 tests)
- token_perpetual_distribution_last_claim (8 tests)
- token_pre_programmed_distributions (9 tests)
- token_status (7 tests)
- token_total_supply (7 tests)
Each module tests: invalid identifier validation, empty state queries,
proof-based queries, and data queries with actual token state (contracts,
balances, freeze status, paused status, pricing, distributions).
Also adds setup_platform_with_token_state() helper to query::tests module
for reusable token state setup across all test modules.
Co-Authored-By: Claude Opus 4.6 (1M context)
|
Warning Rate limit exceeded
How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. i Review infoRun configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: Files selected for processing (11)
Finishing TouchesGenerate unit tests (beta)
Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3265 +/- ## ============================================ + Coverage 66.08% 66.63% +0.55% ============================================ Files 3292 3292 Lines 253958 255467 +1509 ============================================ + Hits 167837 170240 +2403 + Misses 86121 85227 -894
New features to boost your workflow:
|
|
Self reviewed |