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.rs and updates the optional tiered yield ADR (docs/adr/ADR-005-tiered-yield.md) to document the complete test coverage.
Closes #260 Closes #244
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 viafund_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-onfund()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 subsequentfund()calls preserve these zero-valued guards. -
test_second_fund_with_commitment_panics_without_tier_table: Asserts that a secondfund_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 plainfund()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 simplefund()first deposit correctly defaults the investor's effective yield to base yield and sets no claim gate.
Run the contract test suite:
cargo testTests added under: escrow/src/tests/funding.rs
Documentation updated under: docs/adr/ADR-005-tiered-yield.md
- Verified compilation cleanliness of the
liquifact_escrowlibrary. - Verified test suite integration and invariant assertions match ADR-005 spec.