harb/docs/testing.md
openhands 58c3e62f3d fix: refactor AGENTS.md into progressive-disclosure structure (#184)
- Root AGENTS.md: 350+ lines → 68 lines (map, not encyclopedia)
- New docs/dev-environment.md (67 lines): Docker, dev.sh, ports, pitfalls
- New docs/ci-pipeline.md (73 lines): Woodpecker setup, monitoring, debugging
- New docs/testing.md (41 lines): Foundry, E2E, version validation
- New docs/codeberg-api.md (32 lines): .netrc auth, API usage
- Updated stale model refs in .claude-code-supervisor.yml files
- Sub-component AGENTS.md files unchanged
- Context docs (PRODUCT-TRUTH, ARCHITECTURE, UX-DECISIONS) unchanged
2026-02-23 09:46:35 +00:00

1.8 KiB

Testing

Contract Tests (Foundry)

Run inside onchain/:

forge build      # compile contracts
forge test       # run unit + fork tests
forge snapshot   # gas snapshot

Fuzzing

Scripts under onchain/analysis/ generate replayable scenarios:

./analysis/run-fuzzing.sh [optimizer] debugCSV

Integration Testing

After the stack boots via dev.sh:

  • Anvil logs: check for revert errors
  • Ponder GraphQL: http://localhost:8081/api/graphql
  • txnBot health: http://localhost:8081/api/txn/status

E2E Tests (Playwright)

Full-stack tests in tests/e2e/ verify complete user journeys (mint ETH → swap KRK → stake).

npm run test:e2e   # from repo root
  • Tests use a mocked wallet provider with Anvil accounts.
  • In CI, the Woodpecker e2e.yml pipeline runs these against pre-built service images.
  • See docs/ci-pipeline.md for CI-specific E2E details.

Version Validation System

The stack enforces version compatibility across contracts, indexer, and frontend:

  • Contract VERSION: Kraiken.sol exposes a VERSION constant (currently v2) that must be incremented for breaking changes to TAX_RATES, events, or core data structures.
  • Ponder Validation: On startup, Ponder reads the contract VERSION and validates against COMPATIBLE_CONTRACT_VERSIONS in kraiken-lib/src/version.ts. Fails hard (exit 1) on mismatch to prevent indexing wrong data.
  • Frontend Check: Web-app validates KRAIKEN_LIB_VERSION at runtime (currently placeholder; future: query Ponder GraphQL for full 3-way validation).
  • CI Enforcement: Woodpecker release.yml pipeline validates that contract VERSION matches COMPATIBLE_CONTRACT_VERSIONS before release.
  • See VERSION_VALIDATION.md (repo root) for complete architecture, workflows, and troubleshooting.