Skip to content

fix(backend): dispute body, provider latency, dedup cap and k6 routes (#800, #801, #732, #819) - #842

Merged
meshackyaro merged 5 commits into
trustflow-protocol:mainfrom
dev-susa:fix/800-801-819-732-trustflow-backend
Oct 24, 2026
Merged

meshackyaro merged 5 commits into
trustflow-protocol:mainfrom
dev-susa:fix/800-801-819-732-trustflow-backend

Conversation

@dev-susa

@dev-susa dev-susa commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Four open issues in the backend, fixed in one PR as agreed. Each is its own commit.

Closes #800
Closes #801
Closes #732
Closes #819

Type of Change

  • 🐛 Bug fix

Component

  • Backend (Node.js API)

Testing

Rebased onto current main. Run locally with Node 20 (.nvmrc), with ts-jest diagnostics turned off for the specs below. The diagnostics are off because main already has type errors that block some specs (see below).

Spec Result
ipfs-pinning/ipfs-provider-latency.spec.ts (new, #801) passing
milestone-notifications/event-dedup.service.spec.ts (new, #732) passing
dispute/escrow-dispute.controller.spec.ts (#800) passing
escrow/escrow.controller.spec.ts passing

Total: 35 passed, 35 total across these four suites.

  • k6 run was not run against a live server. The script passes a syntax check, and its routes and bodies were checked against the controllers and DTOs.

Known issues (not introduced by this PR)

These fail on upstream/main as well. They are not in this PR.

  • Typecheck (tsc --noEmit) fails on main: syntax errors in src/common/rate-limit/rate-limit.guard.ts and src/ipfs-pinning/ipfs-pinning.controller.ts, and type errors in src/dispute/arweave-archive.service.ts. The arweave errors also stop the dispute spec from compiling under the default ts-jest config.
  • Lint fails on main: eslint "src/**/*.ts" reports 320 errors, including unused variables in ipfs-pinning.service.ts.
  • Prettier: src/escrow/escrow.controller.spec.ts already fails prettier --check on main.
  • provider-health.service.spec.ts fails because its test module doesn't provide REDIS_CLIENT.
  • ipfs-failover.spec.ts fails in Jest's transform step.

Reviewer Notes

  • The RaiseDisputeSchema change narrows the body type used by the dispute controller.
  • event-dedup.service.ts: the eviction loop moved into evictOldest(limit). pruneLocal still uses the cap at the start of each claim, and the new call before the insert keeps the size at or below the cap.

@dev-susa
dev-susa requested a review from meshackyaro as a code owner October 23, 2026 18:24
…/dispute (Closes trustflow-protocol#800)

RaiseDisputeSchema required escrowId and signerAddress, which the route never
receives. The escrow comes from the :id path parameter and the initiator from
the JWT, so every documented request failed validation with a 400.

The schema now validates only reason and evidenceUrl. The dispute controller
spec used one-letter reasons that the schema rejects, referenced a notification
method the saga does not call, and did not provide ArweaveArchiveService. Those
are fixed in the spec.
…ustflow-protocol#801)

Every health call passed a hard-coded 5000ms, so averageLatencyMs was always
5000 for every provider. Each provider attempt is now timed and the measured
duration is recorded on success and on failure, in pin() and in the background
cross-pin.

New spec checks that the recorded value tracks the provider's real delay.
…rustflow-protocol#732)

The eviction ran before the new entry was inserted, so the cache could reach
LOCAL_MAX_ENTRIES + 1. Eviction now makes room for the entry being added.

New spec covers the cap and checks that the oldest entries are evicted first.
…Closes trustflow-protocol#819)

The k6 script posted to /api/v1/escrow and /api/v1/webhooks/register, which do
not exist, and sent a body the global ValidationPipe rejects. It now uses
/v1/escrows with depositor, beneficiary and amountXLM, /v1/webhooks with id,
url and events, and the matching status path.
…rustflow-protocol#800)

A caller may omit reason; the dispute controller then records
'No reason provided'. Any reason that is given must still be 10 to 500
characters.
@dev-susa
dev-susa force-pushed the fix/800-801-819-732-trustflow-backend branch from 152a138 to 96d7ee6 Compare October 24, 2026 09:32
@meshackyaro
meshackyaro merged commit 2865fbb into trustflow-protocol:main Oct 24, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment