Skip to content

[CT-20] Write comprehensive tests for asset-maintenance contract in opsce crate #817

@yusuftomilola

Description

@yusuftomilola

Problem

contracts/asset-maintenance/src/test.rs exists but has near-zero coverage. Maintenance record creation, alert generation, and warranty checking are completely untested.

Proposed Solution

Create contracts/opsce/src/maintenance_tests.rs with a full test suite using the Soroban test environment. Mock ledger timestamps to test time-dependent logic.

Acceptance Criteria

  • create_maintenance_record() — success path, invalid asset ID fails
  • get_maintenance_records() — returns correct records after multiple creates
  • check_maintenance_alerts() — no alerts when none due, correct severity at each time threshold (7, 3, 1 day, overdue)
  • register_warranty() — success path, status is Active before expiry
  • check_warranty_status() — returns Expired after mocking ledger timestamp past expiry
  • rate_provider() — correct average after multiple ratings, duplicate rating rejected
  • Tests run cleanly with cargo test -p asset-maintenance

Metadata

Metadata

Assignees

Labels

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