Skip to content

Add integration test suites for fees, analytics, identity, and database - #1044

Open
kike-alt wants to merge 1 commit into
MettaChain:mainfrom
kike-alt:feature/integration-tests-database-identity-analytics-fees
Open

Add integration test suites for fees, analytics, identity, and database#1044
kike-alt wants to merge 1 commit into
MettaChain:mainfrom
kike-alt:feature/integration-tests-database-identity-analytics-fees

Conversation

@kike-alt

Copy link
Copy Markdown
Contributor

Summary

Adds four integration test suites covering the fees, analytics, identity, and database contracts (17 new tests, all running in CI).

Fees (#922)

  • Per-operation fee configs override default pricing; the fixed strategy returns the configured base verbatim.
  • Config bound validation (min > max, base < min rejected) and admin gating on set_operation_config.
  • Treasury accumulation across recorded collections, 50/50 validator distribution split with configurable shares, idempotent validator registration, reward claiming without double-pay, and empty-distribution no-op.
  • Congestion-driven update_fee_params eases the base fee down 5% at low load while respecting the floor; admin-only enforcement.

Analytics (#923)

  • Market metric updates and read-back, batch updates applying last-write-wins, and batch size limits rejecting wholesale without state corruption.
  • Historical trend ordering preserved and the latest trend embedded verbatim in generated market reports.
  • Sentiment volumes accumulate across updates; ratios flow into reports (600/400 → 6000 bips).
  • Portfolio positions round-trip per owner; benchmark indices track per property type.
  • Two-step admin key rotation: requester must be admin, cooldown blocks premature confirmation, only the nominee can confirm, pending request blocks re-request.

Identity (#924)

  • DID format validation (did:method:id) and duplicate identity rejection.
  • Verifier-gated verification raising trust score by level with expiry stamping.
  • Reputation updates restricted to authorized callers, moving scores up on success / down on failure against threshold checks.
  • Recovery initiation requires a well-sized signature, flips active state (re-initiation blocked), and guardian approvals reject unauthorized callers. Note: recovery cannot be completed today because there is no public message to add guardians — documented in the suite header.

Database (#925)

  • Full sync lifecycle: emit → indexer confirm → checksum verify (accept/reject), per-data-type last-synced-block cursor.
  • Publisher authorization gates sync emission (authorize → allowed → revoke → blocked).
  • Admin-gated analytics snapshots retrievable by id with field-level verification.
  • Export requests validate ranges (from > to rejected), complete with integrity checksums, unknown ids fail cleanly.
  • Indexer management: admin-only registration, duplicate rejection, deactivation flipping status.

Infrastructure notes

  • The three contract modules (propchain_fees, propchain_analytics, propchain_database) are now declared pub so external test binaries can link them — identity and oracle already were.
  • tests/Cargo.toml gains the four dependencies and explicit [[test]] targets: the package root is the tests directory itself, so cargo's auto-discovery never picks up files placed there (pre-existing suites have the same blind spot; left untouched to keep this PR scoped).
  • 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.

Test plan

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

Closes MettaChain#922
Closes MettaChain#923
Closes MettaChain#924
Closes MettaChain#925

- fees: per-operation config overrides with fixed-strategy pricing,
  config bound validation, treasury accumulation, validator distribution
  split by configurable shares, reward claiming, and admin gating of
  every configuration entry point.
- analytics: metric updates and batch limits, historical trend ordering
  feeding market reports, sentiment accumulation semantics, portfolio
  position round-trips, benchmark indices, and the two-step admin key
  rotation with cooldown and nominee confirmation.
- identity: DID validation and duplicate rejection, verifier-gated
  verification raising trust scores with expiry, reputation movement in
  both directions, recovery initiation signature checks, active-recovery
  re-entry blocking, and guardian approval gating (full completion is not
  reachable today because no message exists to add guardians; noted in
  the suite header).
- database: full sync lifecycle from emission through indexer
  confirmation to checksum verification, publisher authorization,
  admin-gated analytics snapshots, export request range validation and
  completion, and indexer management uniqueness/deactivation.
- contracts/fees|analytics|database: expose the contract modules as pub
  so integration binaries can link against them (identity/oracle already
  did).
- tests/Cargo.toml: add the four contract 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 @kike-alt! 👋 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
#925 Database contract has no workspace integration coverage: tests/ never exercises propchain-database Link to this issue
#922 Fees has no workspace integration coverage: tests/ never exercises propchain-fees Link to this issue
#924 Identity has no workspace integration coverage: tests/ never exercises propchain-identity Link to this issue
#923 Analytics has no workspace integration coverage: tests/ never exercises propchain-analytics 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