test(events): bounty pillar coverage — apply/withdraw + credit charge (#33)#36
Open
zeroknowledge0x wants to merge 2 commits into
Conversation
…boundlessfi#33) Add tests/bounty_pillar.rs covering every code path reachable from apply_to_bounty and withdraw_application: - happy path: profile bootstrapped, credits debited, applicant appended - duplicate apply (same op_id) -> OpAlreadySeen - duplicate apply (new op_id) -> ApplicantAlreadyApplied - apply to nonexistent bounty -> EventNotFound - apply to non-bounty pillar -> InvalidPillar - apply to cancelled bounty -> EventActive - apply when contract paused -> Paused - apply with insufficient credits -> InsufficientCredits withdraw: - happy path with odd cost: refund = cost / 2 - happy path with zero cost: no refund - withdraw without prior apply -> ApplicantNotApplied - withdraw after submit -> SubmissionAlreadyExists - duplicate withdraw (same op_id) -> OpAlreadySeen - withdraw when contract paused -> Paused Auth: verify require_auth() is requested for the applicant via env.auths() snapshot (mock_all_auths_allowing_non_root_auth auto-approves at the host level, so should_panic auth tests are not reliable). Refs boundlessfi#33 Signed-off-by: zeroknowledge0x <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
…check) CI run 27906733663 on commit c7b0799 failed the rustfmt job. Apply cargo fmt across the affected contracts to clear the format check and unblock merge. No semantic changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #33
Summary
Add
contracts/events/src/tests/bounty_pillar.rscovering every code pathreachable from
apply_to_bountyandwithdraw_application— happy paths,each
Errorvariant, edge cases, idempotency, and auth-rejection.What changed
contracts/events/src/tests/bounty_pillar.rs(541 lines, 20 tests)contracts/events/src/tests/mod.rs— addedmod bounty_pillar;test_snapshots/tests/bounty_pillar/*.jsonregenerated bycargo testCoverage matrix
apply_to_bounty (10 tests)
OpAlreadySeenApplicantAlreadyAppliedEventNotFoundInvalidPillarEventActivePausedInsufficientCreditsrequire_auth()requested for applicant (verified viaenv.auths()snapshot)withdraw_application (9 tests)
ApplicantNotAppliedSubmissionAlreadyExistsOpAlreadySeenPausedAuth verification
mock_all_auths_allowing_non_root_auth()auto-approves everyrequire_auth()at the host level, so
#[should_panic(expected = "Auth")]cannot fire. Theapply_records_applicant_auth_in_snapshottest instead checksenv.auths()to confirm the contract requested auth for the applicant (rather than
silently skipping the check).
Acceptance criteria
tests/bounty_pillar.rscovering every function in scopeErrorvariant + edge cases + auth-rejection + idempotencycargo test --allpasses (96 events tests + 13 profile tests, 0 failures)Test evidence
Refs #25 (parent epic: contract test-coverage push)
Signed-off-by: zeroknowledge0x [email protected]