Commit graph

3 commits

Author SHA1 Message Date
openhands
a4a3a85fdc fix: Ponder: fix mintNextHourProjected divisor, dead param, dead code (#308) 2026-02-27 05:47:51 +00:00
openhands
16dc1827c9 fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287)
- vitest.config.ts: add statements/functions/branches thresholds alongside
  lines so the coverage gate catches regressions in all four dimensions
- tests/stats.test.ts: replace weak "> 0n" / "toBeDefined()" assertions with
  exact expected values derived from the ring buffer algebra:
  - hour-advanced path: mintedLastWeek=480n, mintedLastDay=220n,
    burnedLastWeek=240n, burnedLastDay=110n, mintNextHourProjected=68n,
    burnNextHourProjected=34n, netSupplyChangeDay=110n,
    netSupplyChangeWeek=240n
  - same-hour projection path: mintNextHourProjected=140n (elapsed-seconds
    scaling verified), burnNextHourProjected=0n (medium=0 fallback path)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 23:28:25 +00:00
openhands
76560fd26b fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287)
- Add vitest ^2 + @vitest/coverage-v8 ^2 as devDependencies
- Add `test` and `test:coverage` scripts to package.json
- Create vitest.config.ts with resolve.alias to mock ponder virtual modules
  (ponder:schema, ponder:registry) and point kraiken-lib/version to source
- Add coverage/ to .gitignore
- Add tests/**/* and vitest.config.ts to tsconfig.json include
- Create tests/__mocks__/ponder-schema.ts and ponder-registry.ts stubs
- Create tests/stats.test.ts — 48 tests covering ring buffer logic,
  segment updates, hourly advancement, projections, ETH reserve snapshots,
  all exported async helpers with mock Ponder contexts
- Create tests/version.test.ts — 14 tests covering isCompatibleVersion,
  getVersionMismatchError, and validateContractVersion (compatible / mismatch /
  error paths, existing-meta upsert path)
- Create tests/abi.test.ts — 6 tests covering validateAbi and validateContractAbi

Tests placed at tests/ (not src/tests/) so Ponder's Vite build does not
attempt to execute test files as event handlers on startup.

Result: 68 tests pass, 100% line/statement/function coverage on all helpers
(stats.ts, version.ts, abi.ts, logger.ts) — exceeds 95% target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 22:53:01 +00:00
Renamed from services/ponder/src/tests/stats.test.ts (Browse further)