test: implement commitment-first-deposit-only state-machine tests for…#289
Merged
mikewheeleer merged 3 commits intoMay 28, 2026
Merged
Conversation
|
@Mrwicks00 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! 🚀 |
Contributor
Author
|
@mikewheeleer not my error, please merge |
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.
PR Description: Test fund_with_commitment rejects a second deposit from the same investor (#260)
Description
This PR implements comprehensive test cases for the LiquiFact escrow contract to enforce state-machine invariants regarding investor funding behavior, fully resolving issue #260.
Specifically, the contract requires that the selection of tier-based yield and claim-lock gates is permanently set during the investor's first deposit. Any subsequent contributions by the same investor must use the simple
fund()entrypoint, which preserves their originally assigned yield and claim-lock gate.This PR adds a dedicated suite of unit tests in
escrow/src/tests/funding.rsand updates the optional tiered yield ADR (docs/adr/ADR-005-tiered-yield.md) to document the complete test coverage.Closes #260
Closes #244
Technical Details & Invariants Tested
We implemented 6 new unit tests to comprehensively verify the state machine's boundary conditions and invariants:
test_commitment_claim_lock_preserved_after_follow_on_fund:Verifies that after a tiered deposit via
fund_with_commitment(lock_secs > 0), a subsequent plainfund()call by the same investor succeeds and leaves bothInvestorEffectiveYieldandInvestorClaimNotBefore(absolute timestamp lock) unchanged.test_commitment_invariant_across_multiple_follow_on_funds:Ensures that tier and claim-lock selection remain immutable across multiple consecutive follow-on
fund()calls from the same investor.test_commitment_zero_lock_follow_on_fund_no_claim_gate:Confirms that zero-lock commitments correctly assign base yield and no claim gate, and that subsequent
fund()calls preserve these zero-valued guards.test_second_fund_with_commitment_panics_without_tier_table:Asserts that a second
fund_with_commitmentcall from an existing investor correctly triggers a panic with the expected error message:"Additional principal after a tiered first deposit must use fund(), not fund_with_commitment()"even when no tier table is configured.test_fund_first_then_commitment_second_panics:Verifies the inverse rule: a plain
fund()first deposit permanently closes the tier selection window, so any follow-onfund_with_commitmentby the same investor panics with the expected error.test_fund_first_deposit_sets_base_yield_and_no_claim_gate:Sanity checks that a simple
fund()first deposit correctly defaults the investor's effective yield to base yield and sets no claim gate.Verification Plan
Automated Verification
Run the contract test suite:
cargo testTests added under:
escrow/src/tests/funding.rsDocumentation updated under:
docs/adr/ADR-005-tiered-yield.mdManual Verification
liquifact_escrowlibrary.