Skip to content

Add integration test suites for dex, lending, crowdfunding, and property management - #1045

Open
prismn wants to merge 1 commit into
MettaChain:mainfrom
prismn:feature/integration-tests-dex-lending-crowdfunding-property
Open

Add integration test suites for dex, lending, crowdfunding, and property management#1045
prismn wants to merge 1 commit into
MettaChain:mainfrom
prismn:feature/integration-tests-dex-lending-crowdfunding-property

Conversation

@prismn

@prismn prismn commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds four integration test suites covering the DEX AMM, lending platform, crowdfunding lifecycle, and property management (14 new tests, all running in CI).

DEX (#918)

  • Pool creation validation: identical tokens, zero reserves, fee >= 100%, and duplicate ordered pairs all rejected with InvalidPair.
  • Initial LP supply minted as sqrt(base * quote); initial price seeded in bips.
  • Balanced liquidity additions mint exactly proportional shares; reserves and share supply tracked correctly; zero adds and over-withdrawals rejected.
  • Fee-adjusted constant-product swaps verified against hand-computed outputs in both directions; selling base depresses the pool price as expected.
  • Slippage guard rejects unfavorable outputs; zero input and unknown pools fail cleanly.

Lending (#919)

  • Pool creation admin-only; borrow rate tracks utilization (base + utilisation/50) with over-borrow rejected by deposit accounting.
  • Underwriting gated on-chain credit profiles: borrowers without repayment history stay Pending; qualified loans activate with their computed score stored.
  • Liquidation: healthy collateral refuses (LiquidationThresholdNotMet), threshold breach liquidates, and settled state cannot be re-liquidated or re-flagged.

Crowdfunding (#920)

  • Creator-only activation; investment requires onboarding + KYC + admin-verified accreditation, each step enforced separately with distinct errors.
  • Per-investor aggregation counts top-ups once; crossing the target flips status to Funded.
  • Milestone flow: creator/admin-only creation, admin approval required before release, authorized-oracle verification required, double-release blocked, released capital tracked.
  • Cancelled campaigns refund each investor exactly once (AlreadyRefunded after), non-investors get NoInvestmentFound.

Property management (#921)

  • Manager administration admin-gated; managers can set jurisdiction compliance configs that round-trip through getters.
  • Lease creation validates rent/period/fee terms, enforces the landlord-role check, applies jurisdiction security-deposit caps (over-cap deposit → ComplianceViolation, within-cap stores Active), and single-use ending.
  • Maintenance lifecycle Submitted → InProgress → Resolved with manager authorization and resolution hash; unknown ids fail cleanly.
  • Tenant screening: applicants submit, only managers review, single-review semantics prevent status flips.
  • Expense recording manager-gated with amount validation.

Infrastructure notes

  • The four contract modules are now declared pub (identity/oracle already were), and their [lib] crate-type gains "rlib" alongside cdylib — cdylib alone cannot be linked into test binaries.
  • tests/Cargo.toml gains the four dependencies plus explicit [[test]] targets: the package root is the tests directory itself, so cargo's auto-discovery never picks up files placed there.
  • Crate-level #![allow(clippy::clone_on_copy)] added workspace-wide: current nightly fires it inside ink!-generated storage accessors on a pristine checkout of main, failing -D warnings for every PR. Also one pre-existing clippy::new_without_default suppression on the property-management constructor now needed since the crate links as rlib into tests.

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-features --workspace (626 passed, 0 failed)

…rty management

Closes MettaChain#918
Closes MettaChain#919
Closes MettaChain#920
Closes MettaChain#921

- dex: pool creation validation (identical tokens, zero reserves, fee
  cap, duplicate ordered pairs), sqrt LP share minting, price seeding,
  proportional liquidity shares, fee-adjusted constant-product swaps
  that move the pool price, slippage guard enforcement, and clean errors
  for unknown pools.
- lending: utilization-driven borrow rates with over-borrow rejection,
  credit-profile gating of underwriting (thin files stay pending), LTV
  enforcement at activation, threshold-gated liquidation, and settled
  loan state that cannot be re-liquidated.
- crowdfunding: creator-only activation, KYC + accreditation gating of
  investment (with admin-only verification), per-investor aggregation
  without inflating investor counts, target-crossing to Funded status,
  milestone add/approve/oracle-verify/release flow with double-release
  protection, and exactly-once refunds after admin cancellation.
- property management: admin-gated manager administration, lease term
  validation (zero rent/periods, fee bps bound), jurisdiction deposit
  caps rejecting over-collateralized deposits, landlord-role gating,
  maintenance triage through resolution with manager authorization,
  manager-reviewed tenant screening with single-review semantics, and
  expense recording with amount validation.
- contracts/dex|lending|crowdfunding|property-management: expose the
  contract modules as pub and add rlib to crate-type so external test
  binaries can link them (cdylib alone is not linkable).
- tests/Cargo.toml: add the four dependencies plus explicit [[test]]
  targets - the package root is the tests directory itself, so cargo
  cannot auto-discover new test files.
@drips-wave

drips-wave Bot commented Aug 24, 2026

Copy link
Copy Markdown

Hey @prismn! 👋 It looks like this PR isn't linked to any issue.

If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g., Closes #123), or by clicking a button below:

Issue Title
#921 Property-management has no workspace integration coverage: tests/ never exercises it Link to this issue
#918 DEX has no workspace integration coverage: tests/ never exercises propchain-dex Link to this issue
#920 Crowdfunding has no workspace integration coverage: tests/ never exercises propchain-crowdfunding Link to this issue
#919 Lending has no workspace integration coverage: tests/ never exercises propchain-lending Link to this issue

ℹ️ Learn more about linking PRs to issues

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.

1 participant