Skip to content

Bill Payments: Add overflow-safe get_total_unpaid / get_total_unpaid_by_currency aggregation tests #627

@Baskarayelu

Description

@Baskarayelu

Description

get_total_unpaid(owner) and get_total_unpaid_by_currency(owner, currency) sum the amount of unpaid bills into an i128. With many large-amount bills these sums can overflow; under overflow-checks = true that aborts the read. We need to make the aggregation overflow-aware (saturating or checked with a defined error) and add tests with near-i128::MAX totals and many bills, plus confirm currency filtering only sums matching currency codes.

Requirements and context

  • Secure: Aggregation must not panic-abort on overflow; define saturating or checked behavior consistently.
  • Tested: near-max totals, mixed-currency filtering, empty owner returns 0.
  • Documented: Document aggregation overflow policy in docs/.
  • Reference real symbols: get_total_unpaid, get_total_unpaid_by_currency, Bill { amount, currency, paid }, get_bills_by_currency.

Suggested execution

  • Branch feature/bp-total-unpaid-overflow.
  • Apply checked/saturating sums in bill_payments/src/lib.rs; add tests in bill_payments/tests/stress_test_large_amounts.rs.
  • Add docs docs/bill-payments-aggregation.md.
  • Add /// comments documenting overflow policy.
  • Validate security assumptions: bounded read behavior.

Test and commit

  • Run cargo test -p bill_payments.
  • Cover edge cases: near-max totals, currency mismatch, no bills.
  • Include test output and an aggregation-overflow note.

Example commit message

fix: make unpaid-total aggregations overflow-safe and add large-amount tests

Guidelines

  • Minimum 95% test coverage
  • Clear documentation in docs/ and inline /// comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programsecuritySecurity hardening and auditssmart-contractSoroban/Rust smart contract worksorobanStellar Soroban specifictestingTests and coverage

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions