Skip to content

test: end-to-end vault -> settlement -> revenue_pool full cycle #471

Merged
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
V1ctor-o:test/e2e-full-cycle
Jun 26, 2026
Merged

test: end-to-end vault -> settlement -> revenue_pool full cycle #471
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
V1ctor-o:test/e2e-full-cycle

Conversation

@V1ctor-o

@V1ctor-o V1ctor-o commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

Summary

Adds tests/e2e_full_cycle.rs, a workspace-level smoke test that deploys
callora-vault, callora-settlement, and callora-revenue-pool together in
one Env and walks a full production-style fund cycle, asserting balances
at every stage. Shared setup boilerplate lives in scripts/e2e_setup.rs.

Topology note

The issue described one chain: vault -> settlement -> developer withdraw -> revenue_pool sweep -> admin batch_distribute. That chain doesn't actually
exist on-chain — there's no sweep function, and settlement/revenue_pool
have no call path between them. They're two independent destinations
for vault-deducted funds:

  • Settlement path: vault deducts credit settlement's global pool
    (to_pool=true); a developer can also be credited directly and call
    withdraw_developer_balance to pull USDC out.
  • Revenue pool path: funded separately via vault.distribute, then paid
    out via distribute / batch_distribute.

This test exercises both real paths so the conservation check is meaningful
across all three contracts. Full diagram and rationale are in the test
file's module doc comment.

What's covered

Deposit → single + batch deduct (with idempotency rejection) → settlement
pool/developer crediting → developer withdraw → vault surplus swept into
revenue_pool → batch_distribute → paused-vault edge cases (deposit/deduct
blocked, owner withdraw still allowed) → paused-revenue_pool edge cases →
oversized batch_distribute proven atomic (zero partial transfers) → final
cross-contract conservation assertion.

Invariant, checked at every stage:

vault.balance() + settlement.global_pool + sum(developer balances)
  + revenue_pool.balance() + sum(wallet balances) == total USDC minted

Files changed

  • tests/e2e_full_cycle.rs — the test
  • scripts/e2e_setup.rs — shared deploy/wiring helper
  • Cargo.toml — added [package] + [dev-dependencies] (was a virtual
    workspace; root needs a real package for a top-level tests/ binary to
    compile against the three contract crates)
  • src/lib.rs — empty; required for the new root package to be valid

⚠️ Blocked on a pre-existing, unrelated compile error

cargo build -p callora-vault fails on a clean main checkout (no PR
changes applied), in the existing remove_offering_index helper:

error[E0308]: mismatched types
   --> contracts\vault\src\lib.rs:421:22
421 |             if id != offering_id {
    |                --    ^^^^^^^^^^^ expected `String`, found `&String`

This blocks the project's own existing test suite too, not just this PR.
As a result I haven't been able to confirm this test compiles or passes
locally. The code has been carefully reviewed against the real contract
source (signatures, error enums, event payloads) but is unverified pending
a fix to that line. Suggest fixing separately before merging/reviewing this.

Checklist

  • All three contracts deployed in one Env
  • Conservation assertion at every stage
  • Edge cases: paused vault, paused revenue_pool, partial batch failure
  • Doc comments throughout
  • cargo test --workspace e2e_full_cycle passes — blocked, see above
  • cargo fmt / cargo clippy / ./scripts/check-wasm-size.sh

Closes #425

@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@V1ctor-o 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! 🚀

Learn more about application limits

@greatest0fallt1me greatest0fallt1me merged commit 828a1c9 into CalloraOrg:main Jun 26, 2026
0 of 3 checks passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

an end-to-end vault → settlement → revenue_pool cycle test is exactly the integration coverage this workspace needed. merged 🙏

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.

Pool drainage simulation in CI — vault → settlement → revenue_pool full-cycle E2E

2 participants