Skip to content

Integration test harness - #223

Open
codefather2026 wants to merge 2 commits into
Miracle656:mainfrom
codefather2026:integrationTestHarness
Open

codefather2026 wants to merge 2 commits into
Miracle656:mainfrom
codefather2026:integrationTestHarness

Conversation

@codefather2026

Copy link
Copy Markdown
Contributor

Closes #63

Summary

Adds a Docker Compose integration-test harness that runs Wraith against a real PostgreSQL database and exercises the running HTTP API with deterministic fixtures.

Changes

  • Add a Postgres and Wraith test stack with fixed host ports and health checks
  • Add API-only startup support through SKIP_INDEXER
  • Seed deterministic transfer, account-summary, and indexer-state fixtures
  • Add Vitest coverage for:
    • filtered incoming transfers
    • combined account history and pagination
    • /accounts/:address/summary
    • transaction-hash queries
    • unrelated-account filtering
  • Add npm run test:integration
  • Add a pull-request CI job with failure logs and guaranteed volume teardown
  • Generate Prisma Client in the runtime image and install the required OpenSSL dependency
  • Add .dockerignore to reduce Docker build context
  • Keep integration and chaos tests out of the default Jest unit suite

Testing

  • npm run build
  • docker compose -f docker-compose.test.yml config --quiet
  • docker compose -f docker-compose.test.yml up -d --build
  • npm run test:integration — 5 tests passed
  • docker compose -f docker-compose.test.yml down -v

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good news first: this doesn't rebuild the harness. The headline number (+1262) is misleading — 1178 of those additions are package-lock.json, so the human diff is about 84 lines across 9 files, and several of them are real fixes I want. The problem is the base: the branch is cut from 86c971e ("Merge #125"), which is a long way behind, and #178 has since landed a dual-network harness in the same directory. That makes one change in here actively destructive.

The blocker: vitest.integration.config.ts stops running six of the seven integration suites

-    include: ["tests/integration/**/*.test.ts"],
+    // Older files in this directory belong to standalone Jest/DB suites. This
+    // command is the compose-backed black-box API suite for issue #63.
+    include: ["tests/integration/api.test.ts"],

The comment isn't accurate. tests/integration/dual-network.test.ts (420 lines — it is #178, the dual-network isolation harness), reorg.test.ts (226 lines) and reorg-rollover.test.ts (93 lines) all import { describe, expect, it } from "vitest" and are run today by that glob. Narrowing include to a single file means npm run test:integration and the CI "Integration tests" job report green off 5 tests while 739 lines of reorg and dual-network coverage silently stop executing. That's the one change I can't take.

If the goal was to keep e2e.test.ts, migrations.test.ts and ws.test.ts out (those three do use bare globals against globals: false), exclude those three by name rather than allow-listing one file — and note main's jest config already has testPathIgnorePatterns for tests/integration/ and tests/chaos/, so those three currently run under neither runner. Worth a follow-up issue rather than solving it here.

Already on main, please drop on rebase

  • package.json — the testPathIgnorePatterns block you add is byte-for-byte what main already has.
  • The PR description lists "Add a Postgres and Wraith test stack", "Add npm run test:integration" and "Add a pull-request CI job". All three are on main already (docker-compose.test.yml, the test:integration script, the integration job in ci.yml), and docker-compose.test.yml already sets SKIP_INDEXER: "true".
  • tests/integration/fixtures.ts — this file no longer exists; fixtures were consolidated into src/fixtures.ts. Your +22 to it and the setup.ts import of seedAccountSummaries from "./fixtures" are the merge conflict.
  • tests/integration/api.test.ts — main already reworked this assertion, but in the other direction: it now calls /summary/:address with a comment noting that /accounts/:address/summary is shadowed by the accounts router and returns the { address, assets } shape. Your assets/net/lastActivityAt expectation is correct for /accounts/:address/summary, so if you want to keep testing that endpoint, add it as a second test instead of converting the existing one — covering both shapes is strictly better than either.

One thing to pull out of the lockfile

package.json moves vitest from ^3.2.4 to ^4.1.9. That's a major bump of the integration runner and it's where essentially all 1178 lockfile lines come from. At your base there was no vitest devDependency at all, so adding one was right then; against current main it's an unrelated major upgrade riding along in a test-harness PR. Please drop it back to ^3.2.4 — if vitest 4 is worth doing, it deserves its own PR where a red run is attributable.

Keep these — they're the good part of the PR

  • src/index.ts: the SKIP_INDEXER guard. docker-compose.test.yml has been setting that variable while the code ignored it, so the test container has been booting the indexer against a live RPC endpoint this whole time. Genuine fix.
  • Dockerfile: apk add --no-cache openssl in both stages and npm run db:generate in the runner. Correct — Prisma's engine needs OpenSSL on alpine, and the runner's npm ci does land a fresh node_modules with no generated client.
  • .dockerignore, the CI timeout-minutes: 20, and docker compose logs on failure.
  • setup.ts: AbortSignal.timeout(5_000) on the healthz poll — without it a hung connect eats the whole boot budget in one attempt.

What I could and couldn't run: the Docker daemon isn't running on this machine, so I could not execute npm run test:integration against the compose stack — I'm reviewing these by reading, not by observing a pass. Worth knowing that CI didn't cover for me either: the only check on this PR is GitGuardian. The typecheck, integration and chaos jobs haven't run on your branch (compare #210, which has all four). They should run on your next push now that fork workflow approval is cleared — please make sure they're green before re-requesting.

Rebase onto main, restore the include glob, drop the three already-landed pieces and the vitest 4 bump, and the remainder is a clean merge.

This branch has not been deployed

No deployments
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.

Add docker-compose integration test harness

3 participants