Skip to content

[CT-21] Write Resource Credits Test Suite (10+ tests) in Rust #1038

@devwums

Description

@devwums

Problem

The resource_credits contract has no dedicated test suite. Deduction and top-up edge cases — especially zero-balance deduction and maximum-balance top-up — are untested and commonly cause off-by-one errors.

Proposed Solution

Create contracts/cntr/tests/resource_credits_tests.rs. Write at least 10 unit tests covering: deduct from full balance (success), deduct exact balance leaving zero (success), deduct more than balance (fail), deduct zero (fail), deduct negative (fail), top-up from zero, top-up to exact max balance, top-up one above max (fail), zero top-up (fail), large balance accumulation. All implementation must live inside contracts/cntr/.

Acceptance Criteria

  • File at contracts/cntr/tests/resource_credits_tests.rs
  • At least 10 test functions
  • Tests import credit_deduction.rs and credit_topup.rs peer modules
  • Deduction-to-zero edge case is explicitly and separately tested
  • All tests pass with cargo test

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

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