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
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 insidecontracts/cntr/.Acceptance Criteria
contracts/cntr/tests/resource_credits_tests.rscredit_deduction.rsandcredit_topup.rspeer modulescargo test