Skip to content

Add report_revenue duplicate-rejection tests asserting rev_rej event and zero state change #372

@thlpkee20-wq

Description

@thlpkee20-wq

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
    • cargo test
  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions