Skip to content

test(vault): integration suite for C-address callers, trustlines and partial release - #37

Open
jdjioe5-cpu wants to merge 1 commit into
Kinlock-Org:mainfrom
jdjioe5-cpu:test/integration-suite-m1-15
Open

jdjioe5-cpu wants to merge 1 commit into
Kinlock-Org:mainfrom
jdjioe5-cpu:test/integration-suite-m1-15

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Closes #28

What and why

Implements the full end-to-end integration test suite in \contracts/kinlock/tests/integration.rs\ for roadmap row \M1-15, covering all five required pilot failure and interaction scenarios (C-address contract callers, trustline authorization failures with zero-state-movement invariants, partial release followed by refund and decline remainder accounting, and mid-flight token allowlist removals). All assertions check explicit state, money movement, and event \schema_version\ while keeping \contracts/kinlock/src/\ completely untouched.

Changes

  • \contracts/kinlock/tests/integration.rs:
    • Scenario (a) \ est_classic_g_address_sender_to_c_address_payee_contract: classic account sender creates a multi-tranche lock for a deployed C-address contract payee; verifies release moves funds into the contract payout, updates \ otal_locked, asserts \�uth_who == c_payee_payout\ via \�nv.auths(), and validates emitted \Released\ event with \schema_version = 1.
    • Scenario (b) \ est_c_address_sender_lifecycle: smart contract sender calls \create_lock\ requiring explicit invocation auth with the nested SAC \ ransfer\ sub-invocation; executes partial release, then refunds the remaining tranche back to the C-address sender after expiry with exact auth and \Refunded\ event verification.
    • Scenario (c) \ est_release_payout_lacks_trustline_reverts_then_succeeds_when_authorized: simulates missing/revoked USDC trustline on the payee payout; proves \ ry_release\ reverts with zero state moved (balances intact,
      eleased == 0, tranche unreleased, \ otal_locked\ preserved); proves subsequent release succeeds once trustline is established and authorized.
    • Scenario (d) \ est_partial_release_then_refund_of_remainder_and_decline_remainder: verifies that partial release followed by refund or decline returns exactly the post-release remainder (\500\ or \250), never the original total (\600\ or \400); verifies zero-release direct decline returns full amount.
    • Scenario (e) \ est_allowlist_removal_midflight_existing_locks_unaffected: verifies admin token removal prevents new lock creation (\TokenNotAllowed) while existing open locks release, refund, and decline without disruption.
  • \docs/TESTING.md: Added short reference guide documenting test layout, requirements, and execution commands.
  • \README.md: Updated tests section describing the integration suite and pointing to \docs/TESTING.md.
  • \ROADMAP.md: Marked \M1-15\ as \DONE, updated Section 3 Progress snapshot (Phase 2 DONE: 25, TODO: 13, Readiness: 61%; All DONE: 76, TODO: 89, Readiness: 41%), updated \Last updated\ date to 2026-10-17, and added Section 17 Changelog entry.

Hard rules / invariants touched

3, 4, 8, 10 (from \ARCHITECTURE.md\ §4.6)

Tests

1. Verification commands executed locally:

  • \cargo fmt --all -- --check: Exit code 0 (clean).
  • \cargo clippy --all-targets -- -D warnings: Exit code 0 (clean, 0 warnings).
  • \stellar contract build: Exit code 0 (\ arget\wasm32v1-none\release\kinlock.wasm, 23,780 bytes, hash: \5a8c6b230ab2c5a8c977e8a0b0a478d067a76f1ea58a9d80f1b739900c895558).
  • \cargo test --release --test integration: Exit code 0 (5/5 integration tests passed in 0.07s).
  • \cargo test --release --workspace: Exit code 0.
    • 107/107 unit tests passed (\ inished in 0.45s).
    • 5/5 integration tests passed (\ inished in 0.06s).
    • 1/1 property test (64 proptest cases) passed (\ inished in 3.64s).

2. Contract Scope Check:

  • \git diff --stat contracts/kinlock/src/\ is completely empty.

Docs / ADR

\docs/TESTING.md\ created; \README.md\ and \ROADMAP.md\ updated.

Roadmap

\M1-15\ marked \DONE. Changelog entry added: yes.

Assumptions and open questions

None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integration suite: C-address callers, trustline failures, partial release, allowlist removal with open locks

2 participants