Description
When report_revenue is called for an existing period_id with override_existing=false, it emits rev_rej and returns Ok(()) with no state mutation. There is no explicit assertion that AuditSummary.total_revenue, report_count, and the stored period amount are all unchanged after rejection. Add a test locking this no-op guarantee.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/lib.rs (report_revenue rejected branch, get_audit_summary, get_revenue_by_period), src/test_duplicates.rs
- Assert the
rev_rej event carries (attempted_amount, period_id, existing_amount)
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/report-revenue-duplicate-tests
- Implement changes
- Report a period, capture
AuditSummary
- Re-report same period with a different amount and
override_existing=false
- Assert
AuditSummary and stored amount unchanged and rev_rej emitted
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Duplicate with identical amount, larger amount, smaller amount
- Include test output and security notes
Example commit message
test: assert duplicate report_revenue is a no-op with rev_rej
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
When
report_revenueis called for an existingperiod_idwithoverride_existing=false, it emitsrev_rejand returnsOk(())with no state mutation. There is no explicit assertion thatAuditSummary.total_revenue,report_count, and the stored period amount are all unchanged after rejection. Add a test locking this no-op guarantee.Requirements and context
src/lib.rs(report_revenuerejected branch,get_audit_summary,get_revenue_by_period),src/test_duplicates.rsrev_rejevent carries(attempted_amount, period_id, existing_amount)Suggested execution
git checkout -b feat/report-revenue-duplicate-testsAuditSummaryoverride_existing=falseAuditSummaryand stored amount unchanged andrev_rejemittedTest and commit
cargo testExample commit message
test: assert duplicate report_revenue is a no-op with rev_rejGuidelines