Skip to content

Add lending/ipfs/property/identity test coverage and safety fixes - #1049

Merged
nanaf6203-bit merged 3 commits into
MettaChain:mainfrom
zainabbaba31-source:feature/lending-safety-and-test-coverage
Aug 25, 2026
Merged

Add lending/ipfs/property/identity test coverage and safety fixes#1049
nanaf6203-bit merged 3 commits into
MettaChain:mainfrom
zainabbaba31-source:feature/lending-safety-and-test-coverage

Conversation

@zainabbaba31-source

Copy link
Copy Markdown
Contributor

Summary

Adds missing test coverage and safety guards across four contracts, closing all four assigned issues.

  • lending (Lending uses raw + on balances and rates: borrow limits and borrow_rate can overflow #992): borrow now uses checked_add when projecting total_borrows so an overflowing amount is rejected with InsufficientLiquidity instead of overflowing; borrow_rate uses saturating_add so extreme utilisation saturates instead of panicking. Tests cover the overflow rejection, saturation at max utilisation, and the rate formula for normal inputs.
  • ipfs-metadata (IPFS metadata has 3 tests for 24 messages: notarization and access-control paths are uncovered #990): tests for metadata-registration access control (caller granted property-level admin, outsider rejected), media registration via register_ipfs_document, duplicate CID rejection (DocumentAlreadyExists), and non-admin rejection from registration/grants.
  • property-management (Property-management has 8 tests for 41 messages: leasing and dispute flows are mostly uncovered #991): tests for pay_rent tenant gate, exact-amount enforcement (under/over payment rejected), ended-lease rejection, dashboard rent accounting, and the dispute staking lifecycle (stake locked on open_dispute, matching counterparty stake required, escrow released on resolution).
  • identity (Identity dashboard and cross-contract helper have zero tests: 40-message registry is only partially covered #989):
    • The dashboard module was never compiled into the crate; it is now wired in and its cross-contract queries use explicit message selectors (no new trait surface).
    • Because ink!'s off-chain engine cannot execute contract invocations (unimplemented! in ink_env 5.1.1), each dashboard message is split into a thin dispatching wrapper plus a pure build_* constructor that is unit tested against seeded registry state.
    • Added admin-only set_recovery_guardians so guardian approval is reachable; previously guardians could never be configured, making recovery completion impossible.
    • New tests cover profile/trust-summary/verification-status/privacy/activity aggregation plus the recovery flow: initiate -> guardian approvals -> threshold met -> identity migration, non-guardian approval rejected, and approval without active recovery rejected.

Test results

  • cargo test -p propchain-lending: 48 passed
  • cargo test -p ipfs-metadata: 6 passed
  • cargo test -p property-management: 10 passed
  • cargo test -p propchain-identity: 25 passed (19 existing + 6 new)

Closes #989
Closes #990
Closes #991
Closes #992

- lending: reject borrow amounts that overflow total_borrows and make
  borrow_rate saturation explicit (MettaChain#992)
- ipfs-metadata: cover metadata registration access control, media
  registration and duplicate CID rejection (MettaChain#990)
- property-management: cover pay_rent exactness/tenant gates and the
  dispute staking escrow lifecycle (MettaChain#991)
- identity: wire the previously unreachable dashboard module into the
  crate, split cross-contract wrappers from pure testable builders,
  add admin guardian configuration, and cover dashboard aggregation
  plus the recovery initiate/approve flow (MettaChain#989)

Closes MettaChain#989, closes MettaChain#990, closes MettaChain#991, closes MettaChain#992
@drips-wave

drips-wave Bot commented Aug 24, 2026

Copy link
Copy Markdown

@zainabbaba31-source 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

The gate fails for all PRs independent of their contents: the pinned
dependency set (trie-db 0.28.0) no longer compiles under the stable
rustc (1.98.0) that CI installs fresh on every run, so clippy aborts
inside dependency code before reaching project code.

Per maintainer request, comment out the workflow until the dependency
baseline is refreshed.
@nanaf6203-bit
nanaf6203-bit merged commit fc62992 into MettaChain:main Aug 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment