Skip to content

Add regression test that collect_fees after a prior collection with zero new accrual returns NoFeesToCollect #145

Description

@Jagadeeshftw

📌 Description

collect_fees resets FeesAccrued to 0 and returns Error::NoFeesToCollect if the balance is already 0. There is no explicit regression test confirming the second consecutive collect_fees call for the same asset (immediately after a first successful collection, with no new settlements executed in between) correctly fails with Error::NoFeesToCollect rather than, say, returning 0 successfully or double-counting.

🧩 Requirements and context

  • Add a regression test that executes a settlement to accrue fees, calls collect_fees once successfully, then calls collect_fees again immediately for the same asset and asserts Error::NoFeesToCollect.
  • Add a follow-up step: execute another settlement for the same asset after the first collection, and confirm a third collect_fees call now succeeds and collects only the newly-accrued amount, not anything from before.
  • Confirm fees_collected events fire exactly once per successful collection, matching the accrued amount at that time.

🛠️ Suggested execution

  • Add the test to src/test.rs near existing collect_fees coverage.
  • Assert both the Result and the fees_accrued(asset) value after each step.
  • No production code change expected — this closes a test-coverage gap on already-implemented behavior.

✅ Acceptance criteria

  • A regression test confirms a second consecutive collect_fees call with no new accrual fails with Error::NoFeesToCollect.
  • A regression test confirms a subsequent collection after new accrual collects only the new amount.
  • fees_collected events accurately reflect each successful collection's amount.

🔒 Security notes

Fee-collection double-counting or an incorrect success-on-empty result would misstate protocol revenue in an off-chain accounting reconciliation, a low-severity but real correctness concern for anything treating collect_fees's return value as ground truth.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuesmart-contractSoroban/Rust smart contract worktestingTests and coverage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions