Skip to content

Anchor localnet test coverage — restore harness + green the suite (C-048) - #247

Merged
kh0ra merged 2 commits into
mainfrom
feat/c048-anchor-localnet-tests
Jun 11, 2026
Merged

kh0ra merged 2 commits into
mainfrom
feat/c048-anchor-localnet-tests

Conversation

@mehmethayirli

Copy link
Copy Markdown
Member

Özet

C-048 — full Anchor test coverage on localnet. Programın 22-test'lik
integration suite'i artık localnet'te yeşil koşuyor. Suite çürümüştü: root
test harness app/ ayrımında silinmiş, o yüzden hiç koşmuyordu ve program testlerin
altından kaymıştı.

Önkoşul olan compile fix (#245, errors.rs kapanış }) merge edildi —
bu PR onun üstüne kurulu ve yalnızca harness + test düzeltmelerini içerir.

anchor test --provider.cluster localnet: 22 passing, 1 pending, 0 failing (öncesi: 1 passing / 21 failing).

Closes #96

Nasıl / nerede

Harness (silinmiş — geri getirildi):

  • package.json + tsconfig.json (root): ts-mocha + chai + @coral-xyz/anchor
    (programın anchor-lang'iyle eşleşsin diye 0.30.1 pinli) + web3.js/spl-token.
  • Anchor.toml [toolchain] anchor_version = "0.30.1" — CLI 0.32.x uyumsuz IDL üretiyordu.

Suite'i programa göre düzelt (tests/covenant.ts):

  • escrow_token_account artık bir PDA (seeds=[b"escrow_token", job_escrow]),
    rastgele keypair değil → escrowTokenPda() helper'ı + her escrow-keypair kullanımı
    (createJob/finalize/dispute/credit) PDA'ya çevrildi, keypair signer kaldırıldı.
  • Spec-hash mismatch artık account-seeds katmanında (ConstraintSeeds) reddediliyor
    → assertion ikisini de kabul ediyor.
  • Negative-paths describe kendi arbitrator'larını üretip paylaşılan config singleton'ını
    kullanıyor → before()'da updateArbitrators ile kaydet (yoksa NotArbitrator).

Bundle coverage (yeşil suite ne kanıtlıyor)

Negative-paths (M-06) bloğu ilgili audit issue'larını localnet'te kanıtlıyor:

Bu PR'da olmayanlar (dürüst sınır)

mehmethayirli and others added 2 commits June 9, 2026 22:36
The root test harness (package.json + tsconfig.json) was dropped during the
app/ split, so `anchor test` could not run the ts-mocha suite at all
("Couldn't find a package.json file"). Restored:

- package.json: ts-mocha + chai + @coral-xyz/anchor (pinned 0.30.1 to match the
  program's anchor-lang) + @solana/web3.js/spl-token + bn.js.
- tsconfig.json: recovered (es2020, esModuleInterop).
- Anchor.toml [toolchain]: anchor_version = "0.30.1" so build/IDL generation
  matches the deployed program (CLI 0.32.x produces an incompatible IDL).

With the compile fix, `anchor test --provider.cluster localnet` now builds,
deploys, and runs the suite on a local validator. Baseline: 1 passing, 21
failing — the failures are a single rotted-suite cause (tests pass a random
escrow keypair as a signer, but create_job's escrow_token_account is now a PDA
[seeds = b"escrow_token", job_escrow]); greening those is the next commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…stration (C-048)

The suite had rotted since the root harness was dropped (it had not run, so the
program had drifted out from under it). Fixes to match the current program:

- escrow_token_account is a PDA (seeds = [b"escrow_token", job_escrow]), not a
  random keypair: added escrowTokenPda() and replaced every escrow-keypair usage
  (createJob, finalizePayment, dispute/credit flows) — dropped the keypair signer.
- A mismatched spec hash is now rejected at the account-seeds layer
  (ConstraintSeeds) before the in-handler SpecHashMismatch — accept either.
- The negative-paths describe generates its own arbitrators but reuses the shared
  config singleton; register them via updateArbitrators() in before(), else
  resolve_dispute is rejected with NotArbitrator.

`anchor test --provider.cluster localnet`: 22 passing, 1 pending, 0 failing
(was 1 passing / 21 failing before these fixes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
covenant Ready Ready Preview, Comment Jun 9, 2026 7:38pm

@kh0ra
kh0ra merged commit 79b3b7c into main Jun 11, 2026
10 of 12 checks passed

This branch was successfully deployed

1 active deployment
Preview — 37f1d76f Deployed Jun 9, 2026 by vercel[bot]
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.

C-048: Full Anchor test coverage on localnet

2 participants