Test/1059 1060 1061 1062#1177
Open
Dev-Vik-Tor wants to merge 4 commits into
Open
Conversation
- Add deterministic unit tests for batch_reveal atomicity - Test invalid element mid-batch causes entire batch to revert - Verify valid batch applies all elements atomically - Cover empty batch, single-element batch, and insufficient fee scenarios - Assert state before/after failed batch is identical - Test batch with metadata and max batch size limits Closes Emmyt24#1059
- Add stress tests for vault deposit/withdraw/claim edge cases - Assert claiming from non-existent vault returns VaultNotFound - Assert claiming with nothing available returns NothingToClaim - Cover full and partial withdrawal bookkeeping accuracy - Verify unauthorized withdrawal attempts fail - Test unlock time enforcement and vault status transitions - Validate multiple deposits then claim flow - Test vault funding and claim interactions Closes Emmyt24#1060
- Add comprehensive unit tests for WebhookRetryService - Mock HTTP client to fail N times then succeed - Assert delivery eventually succeeds after retries - Verify backoff intervals follow exponential schedule using fake timers - Assert exhausting all retries marks delivery failed exactly once - Verify successful first attempt performs no retries - Test non-retryable status codes stop immediately - Cover network errors, configuration, and edge cases - Validate timing accuracy and terminal failure handling Closes Emmyt24#1061
- Add comprehensive tests for leaderboard cache behavior - Assert score updates invalidate relevant cached leaderboard slice - Assert reads after TTL expiry recompute from source - Cover tie-breaking ordering stability across cache hits - Verify concurrent updates do not corrupt cached ordering - Test different cache keys for different periods and pages - Validate cache clearing functionality - Test all leaderboard types (most-burned, most-active, newest, largest-supply, most-burners) - Verify pagination consistency and metadata accuracy Closes Emmyt24#1062
|
@Dev-Vik-Tor 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comprehensive Test Coverage for Batch Operations, Vault Management, Webhook Delivery, and Leaderboard Caching
Overview
This PR implements deterministic unit tests across four critical systems to improve reliability and maintainability. All tests follow existing project patterns and maintain >80% code coverage targets.
Changes Implemented
1. Batch Operation Atomicity Tests (#1059)
File:
contracts/token-factory/src/batch_atomicity_test.rsVerifies batch operations maintain all-or-nothing semantics:
InvalidParametersKey Test Cases:
test_batch_atomicity_invalid_element_mid_batch- Validates rollback on validation failuretest_batch_atomicity_valid_batch_applies_all- Confirms all tokens created sequentiallytest_batch_atomicity_state_consistency_after_failure- Ensures idempotencytest_batch_atomicity_with_metadata- Metadata fee calculationtest_batch_atomicity_max_batch_size- Boundary testing2. Vault Deposit/Withdraw Edge Cases (#1060)
File:
contracts/token-factory/src/vault_deposit_withdraw_test.rsStress-tests vault deposit/withdraw/claim flows across boundary and error states:
VaultNotFound(error code 60)NothingToClaim(error code 65)UnauthorizedCliffNotReached)Key Test Cases:
test_vault_claim_nonexistent_vault- Error code 60 validationtest_vault_claim_nothing_to_claim- Error code 65 validationtest_vault_claim_unauthorized- Authorization enforcementtest_vault_fund_then_claim- Multi-step workflowtest_vault_claim_bookkeeping_accuracy- State tracking3. Webhook Retry/Backoff Deterministic Tests (#1061)
File:
backend/src/__tests__/webhookRetry.deterministic.test.tsImplements deterministic unit tests with mocked timers and HTTP client:
Key Test Cases:
test_exponential_backoff_schedule- Validates delay computationtest_retry_after_failures- Confirms retry logic with correct intervalstest_terminal_failure- Exhausts retries correctlytest_non_retryable_status- Stops on 4xx errorstest_network_errors- Retries on null status4. Leaderboard Cache Invalidation Tests (#1062)
File:
backend/src/__tests__/leaderboardCache.invalidation.test.tsValidates leaderboard cache correctness under rapid score updates:
Key Test Cases:
test_cache_invalidation_on_score_updates- Cache hit verificationtest_different_cache_keys_for_periods- Period isolationtest_tie_breaking_ordering_stability- Consistent orderingtest_concurrent_updates_no_corruption- Parallel safetytest_cache_clearing- Cache reset functionalityTesting Strategy
Contract Tests (Rust):
Backend Tests (TypeScript/Vitest):
Files Modified
contracts/token-factory/src/batch_atomicity_test.rs(NEW)contracts/token-factory/src/vault_deposit_withdraw_test.rs(NEW)contracts/token-factory/src/lib.rs(module registration)backend/src/__tests__/webhookRetry.deterministic.test.ts(NEW)backend/src/__tests__/leaderboardCache.invalidation.test.ts(NEW)Verification
Closes