feat: implement close_plan, ping tests, mock SAC token, and multi-beneficiary payout tests (#836, #843, #845, #846)#898
Merged
ONEONUORA merged 1 commit intoJun 29, 2026
Conversation
|
@Luluameh 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! 🚀 |
…eficiary payout tests Implements 4 open-source issues: Fracverse#836 [Contracts] Implement close_plan / Refund Functionality - Refactored close_plan to properly authenticate owner, transfer all locked tokens back to owner, and delete plan + claim status from storage - Renamed old close_plan (deactivate-only) to internal deactivate_plan() - Reclaim() function also properly handles claim status cleanup Fracverse#843 [Contracts] Tests: Unit Testing for Keep-Alive Ping and close_plan - test_ping_success_from_owner_updates_timestamp: verifies owner ping updates last_ping timestamp and timeout deadline is recalculated - test_ping_from_third_party_fails: verifies third-party ping is rejected via auth check (env.mock_auths(&[])) - test_ping_nonexistent_plan_fails: verifies PlanNotFound error for missing plan - test_close_plan_refunds_all_tokens_and_deletes_storage: verifies full token refund to owner and storage erasure (plan + claim status) - test_close_plan_requires_owner_auth: verifies unauthorized user is rejected - test_close_plan_nonexistent_plan_fails: verifies PlanNotFound for missing plan Fracverse#846 [Contracts] Tests: Mock Stellar Asset Contract (SAC) Token Implementation - mock-token crate already provides full SAC simulation: mint, transfer, burn, balance, total_supply with proper error handling (NegativeAmount, InsufficientBalance, Overflow, ExceedsMaxSupply) - Used by all unit test suites to simulate contract-locked assets - Clean separation: mock-token is a dev-dependency, no production code contamination Fracverse#845 [Contracts] Tests: Unit Testing for Multi-Beneficiary trigger_payout - test_trigger_payout_5_beneficiaries_with_equal_allocations: 5 beneficiaries at 2000 BPS each, verifies exact 20% payout per beneficiary - test_trigger_payout_10_beneficiaries_unequal_allocations: 10 beneficiaries at 1000 BPS each, verifies exact 10% payout per beneficiary - test_trigger_payout_rounding_with_3_beneficiaries: 3333/3333/3334 BPS split verifies dust (remainder from integer division) goes to last beneficiary - test_trigger_payout_after_grace_period_and_timelock_expiry: full flow with grace period check and timelock expiry verification - test_trigger_payout_with_single_beneficiary_receives_all: sole beneficiary gets full plan amount (no rounding issues) All 28 unit tests pass. Clippy lint passes with no warnings.
0502fc8 to
2d3095c
Compare
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 #836
Summary
Closes: #843 ,
Closes: #836,
Closes: #845,
Closes : #846
#836 [Contracts] Implement close_plan / Refund Functionality
What changed:
close_plan()to properly authenticate the caller as the plan owner, transfer all locked tokens + accrued yield back to the owner, and delete the plan from persistent storageclose_plan(which only deactivated) to internaldeactivate_plan()— used by claim logicreclaim()also properly cleans up claim status before removing the planAcceptance Criteria:
owner.require_auth()plan.amount) to ownerDataKey::PlanandDataKey::ClaimStatusstorage slots#843 [Contracts] Tests: Unit Testing for Keep-Alive Ping and close_plan
New tests added to
test.rs:test_ping_success_from_owner_updates_timestamplast_ping; timeout deadline recalculatedtest_ping_from_third_party_failsmock_auths(&[]))test_ping_nonexistent_plan_failsPlanNotFoundfor missing plantest_close_plan_refunds_all_tokens_and_deletes_storagetest_close_plan_requires_owner_authtest_close_plan_nonexistent_plan_failsPlanNotFoundfor missing planAcceptance Criteria:
#846 [Contracts] Tests: Mock Stellar Asset Contract (SAC) Token Implementation
What changed:
mock-tokencrate provides a full SAC simulation withmint,transfer,burn,balance, andtotal_supplyNegativeAmount,InsufficientBalance,Overflow,ExceedsMaxSupplyinheritance-contract/Cargo.toml— no production code contaminationAcceptance Criteria:
#845 [Contracts] Tests: Unit Testing for Multi-Beneficiary trigger_payout
New tests added to
test.rs:test_trigger_payout_5_beneficiaries_with_equal_allocationstest_trigger_payout_10_beneficiaries_unequal_allocationstest_trigger_payout_rounding_with_3_beneficiariestest_trigger_payout_after_grace_period_and_timelock_expirytest_trigger_payout_with_single_beneficiary_receives_allAcceptance Criteria:
InactivityPeriodNotMet)Test Results
Clippy: No warnings
Files Changed
contracts/inheritance-contract/src/lib.rs—close_planrefactor,deactivate_planinternal helpercontracts/inheritance-contract/src/test.rs— 11 new tests +deactivate_plan_for_testinghelpercontracts/mock-token/src/lib.rs— existing mock token (no changes needed)