test(profile): add credits.rs coverage for spend/earn/refund/admin_grant#48
test(profile): add credits.rs coverage for spend/earn/refund/admin_grant#48Sendi0011 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds ChangesCredits Contract Test Suite
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds
tests/credits.rsforcontracts/profile/src/credits.rs, coveringbootstrap,spend,earn,refund, andadmin_grant.Closes #26 (part of #25).
Coverage
Errorvariant actually reachable fromcredits.rs:EventsContractNotConfigured,OpAlreadySeen,Paused,ProfileNotFound,InsufficientCredits,ReasonRequiredu32::MAXsaturation on
earn/refund/admin_grant,admin_grantbootstrappinga fresh profile for an unknown user
op_idrejected on every function, including thezero-amount
spendno-op pathbootstrap/spend/earn/refundreject a caller thatisn't the configured events contract;
admin_grantrejects a callerthat isn't admin. These use
mock_auths+#[should_panic]sincerequire_auth()panics rather than returning anError— there was noexisting auth-rejection test anywhere in the suite to follow, so this
establishes the pattern.
Note:
Error::InvalidAmountis declared inerrors.rsbut is neverreturned by any path in
credits.rs, so it isn't tested here — happy toadd if it's meant to be wired in as part of this issue.
Testing
```
cargo test -p boundless-profile
cargo test
```
Screenshot
Summary by CodeRabbit