Repository navigation
Anchor localnet test coverage — restore harness + green the suite (C-048) - #247
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ö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ı.
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_accountartı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ı.
→ assertion ikisini de kabul ediyor.
kullanıyor →
before()'daupdateArbitratorsile 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:
ConstraintSeeds, mint-mismatch (H-01). → Refs C-042: Account validation / ownership constraints review #84
cancel-after-bought, early-finalize, buyer==seller. → Refs C-043: Reentrancy / double-spend / state-transition guards #86
Bu PR'da olmayanlar (dürüst sınır)
açık parçası (program
MathOverflow'a sahip; bir aşırı-değer testi eklenebilir).createJobde aynı eski keypair varsayımını yapıyor —bu PR sırasında bulundu, ayrı issue açıldı.
it.skip).