fix: reject duplicate bounty claims for same issue (#19) - #166
Merged
Kings9595 merged 2 commits intoJun 28, 2026
Merged
Conversation
- Add InvalidRepoHash (12) and InvalidDeveloper (13) error variants to the Error enum so the contract compiles against all validation checks already present in lib.rs - Remove WaveGuard check from clawback_expired_funds; ownership is now guarded by pool.maintainer address equality only, matching the design intent documented in MilestonePool trust assumptions (a revoked WaveGuard must not lock the pool creator out of their own escrow) - Fix unit test setup() to register contracts before Address::generate so maintainer/developer addresses are never the all-zero sentinel address - Update test assertions across clawback.rs, error_enum_coverage.rs, unauthorized_access.rs, and test.rs to match the corrected behaviour - All 97 tests pass: 28 unit + 69 integration
|
@Rayyanah0 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Fixes #19 — ensure duplicate bounty claims for the same
(repo_hash, issue_id)pair are rejected withBountyAlreadyClaimed.Root Cause & Fixes
The contract logic for duplicate-claim rejection was already correct (
is_claimedcheck + Persistent storage), but the codebase had several compile and logic errors preventing the tests from running:1. Missing error variants (compile errors)
Error::InvalidRepoHashandError::InvalidDeveloperwere referenced inlib.rsand tests but absent from theErrorenum intypes.rs. Added:2. Broken clawback authorization (logic bug)
clawback_expired_fundswas callingensure_is_maintainer(WaveGuard check) even though the design intent — documented inMilestonePooltrust assumptions — is that clawback intentionally bypasses WaveGuard. A revoked WaveGuard must not lock the pool creator out of their own escrow. Removed the WaveGuard call; ownership is now guarded solely bypool.maintaineraddress equality.3. Test setup zero-address collision (unit test bug)
In
test.rs,Address::generatewas called beforeenv.register, causing the first generated address to be the all-zero sentinelCAAAA...D2KM. This causedtest_maintainer_self_payout_is_not_blockedto fail because the maintainer address matched theInvalidDeveloperguard. Fixed by registering contracts first.4. Stale test assertions
Updated assertions in
clawback.rs,error_enum_coverage.rs,unauthorized_access.rs, andtest.rsto match the corrected clawback authorization model and correct enum discriminants.Test Results
All 97 tests pass (28 unit + 69 integration):
duplicate_claim.rs: 7/7 — core issue coverageclaim_manipulation.rs: 6/6Files Changed
src/types.rs— addedInvalidRepoHashandInvalidDevelopervariantssrc/lib.rs— removed WaveGuard check fromclawback_expired_fundssrc/test.rs— fixed setup order; corrected test assertionstests/clawback.rs— updated clawback auth error expectationtests/error_enum_coverage.rs— fixed variant name and discriminanttests/unauthorized_access.rs— corrected clawback auth assertions