est(reporting): add idempotency coverage for archive cleanup and document safety guarantees#407
Open
IbrahimIjai wants to merge 6 commits intoRemitwise-Org:mainfrom
Open
Conversation
added 5 commits
March 26, 2026 02:17
…modules, alongside extensive new tests and examples for various contracts.
… a common utility library, comprehensive tests, and updated gas benchmarks.
…prehensive test suite with snapshots.
Add a new test `test_cleanup_old_reports_repeated_partial_cleanup_preserves_remaining_archives_and_counters` to verify that calling `cleanup_old_reports` multiple times with the same cutoff correctly preserves remaining active and archived reports without duplicate deletions. This ensures the cleanup logic is idempotent and maintains accurate storage statistics across sequential operations.
Author
|
@Hahfyeex @johnsmccain kindly check my pr. |
Contributor
|
@IbrahimIjai Please resolve the conflicts |
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.
closes: #314
test(reporting): add idempotency coverage for archive cleanup and document safety guarantees
PR Description
Summary
This PR adds explicit idempotency coverage for reporting archive cleanup to ensure repeated cleanup calls are safe, non-duplicative, and do not corrupt storage counters.
What Changed
Added NatSpec-style docs to cleanup_old_reports in reporting/src/lib.rs:
Admin-only behavior
Idempotency guarantee for repeated calls with the same cutoff
Added comprehensive idempotency tests in reporting/src/tests.rs:
Repeated cleanup with same cutoff returns 0 after first deletion
No duplicate deletions across staggered cutoffs
Storage stats remain consistent across cleanup retries
Updated documentation:
reporting/README.md with archive cleanup idempotency and security notes
Root README.md with reporting cleanup safety guarantees
Security Notes
Cleanup and archiving remain admin-gated.
Unauthorized calls fail before mutation.
Deletions are map-key based, preventing double-deletion accounting.
Cleanup scope is limited to archived records older than the supplied cutoff.
Test Status
Attempted:
cargo test -p reporting
Blocked by pre-existing workspace compile errors in remitwise-common (duplicate constants):
INSTANCE_BUMP_AMOUNT defined twice
INSTANCE_LIFETIME_THRESHOLD defined twice
This blocker is outside the files changed in this PR.