Skip to content

[SC-80] asset-maintenance's aggregate calculation functions need edge-case tests for empty/zero input #1351

Description

@yusuftomilola

Overview

calculate_total_maintenance_cost, calculate_asset_downtime, and get_asset_health_score (contracts/asset-maintenance/src/lib.rs) are exactly the kind of aggregate/derived-value functions where the empty-input case (an asset with zero maintenance records) is easy to get wrong (divide-by-zero in a health-score average, an unhandled empty-vec fold) — worth dedicated tests for a brand-new asset with no history at all, distinct from the general edge cases in [SC-66]/[SC-67]/[SC-68].

Tasks

  • Add a test calling all three functions against an asset id with zero maintenance records and assert each returns a sane default (0 cost, 0 downtime, a defined health score) rather than trapping.
  • Add a test with exactly one record, to catch off-by-one issues distinct from the zero and many-record cases.

Acceptance Criteria

  • All three aggregate functions have explicit zero-record and single-record test cases.

Notes for Contributors

Requires Rust + Soroban. Workspace: contracts/ (soroban-sdk 23, members: assetsup, contrib, multisig-wallet, multisig-transfer, asset-maintenance). Run cargo test --all, cargo fmt --all -- --check, and cargo clippy --all-targets --all-features -- -D warnings before opening a PR — CI enforces all three. Comment below to be assigned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contracttestingTests, QA, and quality assurance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions