feat(basics): migrate remaining 29 programs from ts-mocha to tsx + node:test runner - #637
feat(basics): migrate remaining 29 programs from ts-mocha to tsx + node:test runner#637NikkiAung wants to merge 4 commits into
Conversation
Greptile SummaryThis PR moves the remaining non-Anchor
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "fix(#637): remove stale mocha/chai types..." | Re-trigger Greptile |
…de:test runner Follow-up to the 5-program pilot (PR solana-foundation#636). Applies the same pattern to all remaining non-anchor native/pinocchio/asm programs in basics/: - package.json: test script → `tsx --test <file>`; drop mocha/ts-mocha/ @types/mocha/chai/@types/chai; add tsx ^4.22.0 + @types/node ^22.19.1 - tsconfig.json (or tests/tsconfig.test.json): types → ["node"] - pnpm-lock.yaml: regenerated per package 6 test files also needed structural edits: - cross-program-invocation/native + pinocchio: add `node:test` imports; rename it() → test() - hello-solana/asm + pinocchio: add node:test imports; rename it() → test(); convert chai import to node:assert - favorites/native: change mocha import → node:test; chai → node:assert; convert expect().to.equal/deep.equal → assert.strictEqual/deepStrictEqual; add beforeEach to node:test import - favorites/pinocchio: change mocha import → node:test (stub file) Anchor programs are intentionally excluded: anchor test uses mocha internally via `anchor test --validator legacy`, bypassing package.json scripts entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bc92a78 to
f467b24
Compare
…igs, fix create-account/asm es6 target The CI overhaul added tsc --noEmit checks which caught: 1. Root tsconfig.json files with types:["mocha","chai","node"] - mocha/chai no longer installed (replaced by tsx migration), causing typecheck failure. 2. create-account/asm/tsconfig.json had target:"es6" but test uses BigInt literals which require ES2020. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ode compatibility Programs that use CPI to the system program fail in solana-bankrun 0.3.x because its bundled system-program binary emits SBPF v2 instructions that bankrun's own VM cannot execute. Switch the 5 affected programs to litesvm (synchronous API, before() setup hook) to fix CI. Programs fixed: - basics/account-data/native - basics/close-account/native - basics/pda-rent-payer/native - basics/program-derived-addresses/native - basics/rent/native Also adds skipLibCheck: true to tsconfigs missing it, and bumps TypeScript to ^5.5.0 to match the rest of the PR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Too many files changed for review. ( Bypass the limit by tagging |
… duplicate blockhash cross-program-invocation/pinocchio: bankrun 0.3.x rejects the LEVER program binary (unsupported BPF instruction). Switch to litesvm with before() setup; use expireBlockhash() between sequential tests that send identical instructions so they get distinct blockhashes. program-derived-addresses/native: "Visit the page! (2)" sent the same instruction with the same blockhash as "(1)", causing litesvm to reject it as a duplicate transaction. Add svm.expireBlockhash() before the second visit to advance the blockhash slot. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @dev-jodee, would love to get your eyes on this when you have a moment — all CI checks are passing. Let me know if you have any questions! |
|
Thanks @NikkiAung — closing as superseded by #656's harness unification ( |
Summary
Follow-up to #636 (pilot). Applies the same ts-mocha →
tsx --testmigration to all remaining non-anchor native/pinocchio/asm programs inbasics/(29 programs, 94 files).Anchor programs excluded —
anchor test --validator legacyinvokes mocha internally and bypassespackage.jsonscripts entirely; migrating them requires changes to the Anchor CLI itself.Changes per program (×29)
package.json—testscript:pnpm ts-mocha … <file>→tsx --test <file>; dropmocha/ts-mocha/@types/mocha/chai/@types/chai; addtsx ^4.22.0+@types/node ^22.19.1tsconfig.json—types: drop"mocha"and"chai", ensure"node"is presentpnpm-lock.yaml— regenerated per package (mocha/chai tree removed, tsx added)6 test files with structural edits
cross-program-invocation/nativenode:testimports (before,describe,test); renameit()→test()cross-program-invocation/pinocchioimport { assert } from "chai"→import assert from "node:assert"hello-solana/asmnode:testimports (before,describe,test); renameit()→test(); chai → node:asserthello-solana/pinocchiofavorites/nativeimport { describe, test } from "mocha"→node:test; addbeforeEach; chai → node:assert;expect().to.equal→assert.strictEqual,expect().to.deep.equal→assert.deepStrictEqualfavorites/pinocchioimport { describe } from "mocha"→node:test(stub file)Note:
favorites/nativeandcross-program-invocation/nativeremain in.ghaignore— migrations are for correctness/consistency, not yet CI-verified.Test plan
solana-native.ymlpasses for all native programs in this PRsolana-pinocchio.ymlpasses for all pinocchio programssolana-asm.ymlpasses forcreate-account/asmandtransfer-sol/asmts-mocha,from "mocha", orfrom "chai"in migrated programs