Skip to content

fix: repair realloc/native and cross-program-invocation/native excluded after CI overhaul - #651

Open
NikkiAung wants to merge 5 commits into
solana-foundation:mainfrom
NikkiAung:fix/repair-excluded-native-programs
Open

fix: repair realloc/native and cross-program-invocation/native excluded after CI overhaul#651
NikkiAung wants to merge 5 commits into
solana-foundation:mainfrom
NikkiAung:fix/repair-excluded-native-programs

Conversation

@NikkiAung

@NikkiAung NikkiAung commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

All three programs were removed from `.ghaignore` by PR #631 but the CI overhaul (PR #650) re-added them because it introduced a `tsc --noEmit` check and `pnpm install --frozen-lockfile` that exposed new issues.

  • `basics/cross-program-invocation/native` — `tsc --noEmit` failure: root `tsconfig.json` had `types: ["mocha", "chai"]` which excluded `@types/node`. The test imports from `node:buffer`, `node:fs`, `node:path` and uses `litesvm` — all require Node.js types.

    • Fix: add `"node"` to `types`, upgrade `target`/`lib` to `es2020`, add `skipLibCheck: true`, add `@types/node: ^22.19.1`, drop unused `chai`/`@types/chai`, bump TypeScript to `^5.5.0`
  • `basics/realloc/native` — runner mismatch: the test already used `node:test`'s `describe`/`test` runner but `package.json` still ran it with `ts-mocha`. Mocha saw zero registered tests. Also missing: a root `tsconfig.json` for the new typecheck step.

    • Fix: switch `test` script to `tsx --test`, drop `mocha`/`chai`/`ts-mocha`, add `@types/node: ^22.19.1` and `tsx: ^4.22.0`, bump TypeScript to `^5.5.0`, add root `tsconfig.json`
  • `basics/favorites/native` — bankrun 0.3.x SBF simulation engine rejects instructions emitted by the current stable `build-sbf` toolchain (new SBPF opcodes). litesvm tracks the upstream Solana BPF loader more closely.

    • Fix: replace `solana-bankrun` with `litesvm 0.8.0`, rewrite `tests/test.ts` to use litesvm's synchronous API (`sendTransaction`/`getAccount`), bump TypeScript to `^5.5.0`, update tsconfig to `es2020`

All three removed from `.ghaignore`.

Test plan

  • CI `solana-native.yml` passes for `basics/realloc/native`
  • CI `solana-native.yml` passes for `basics/cross-program-invocation/native`
  • CI `solana-native.yml` passes for `basics/favorites/native`
  • `.ghaignore` no longer contains the three paths

🤖 Generated with Claude Code

**cross-program-invocation/native**: the root tsconfig.json had
`types: ["mocha", "chai"]` which excluded @types/node. The test imports
from node:buffer, node:fs, node:path and uses litesvm — all need Node.js
types. The new tsc --noEmit check added by the CI overhaul caught this.
Fix: add "node" to types, update target/lib to es2020, add skipLibCheck,
add @types/node ^22.19.1, drop unused chai/@types/chai, bump TypeScript
to ^5.5.0.

**realloc/native**: the test was already using node:test's describe/test
runner but package.json still ran it with ts-mocha, causing a mismatch
where mocha saw 0 registered tests. Fix: switch to `tsx --test`, drop
mocha/chai/ts-mocha, add @types/node ^22.19.1 and tsx ^4.22.0, bump
TypeScript to ^5.5.0, add root tsconfig.json so tsc --noEmit can pass.

Both removed from .ghaignore.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NikkiAung
NikkiAung requested a review from dev-jodee as a code owner July 25, 2026 03:18
…on rejection

The bankrun 0.3.x SBF simulation engine rejects instructions emitted by
the current stable build-sbf toolchain (new SBPF opcodes). litesvm
tracks the upstream Solana SBF loader more closely and handles them.

Changes:
- tests/test.ts: replace async bankrun start()/processTransaction()/
  getAccount() with synchronous litesvm LiteSVM()/sendTransaction()/
  getAccount(). Each test gets a fresh LiteSVM in beforeEach for
  proper isolation. Wrong-seeds test now uses `!(result instanceof
  TransactionMetadata)` pattern instead of try/catch.
- package.json: add litesvm 0.8.0 dependency, remove solana-bankrun,
  bump @types/node ^22.8.1 → ^22.19.1, bump typescript ^4.3.5 → ^5.5.0
- tsconfig.json: upgrade target/lib es6/es2015 → es2020, add skipLibCheck

Removed from .ghaignore.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown

Greptile Summary

Repairs CI coverage for three native Solana examples:

  • Re-enables the realloc, cross-program-invocation, and favorites examples in native CI.
  • Updates TypeScript configurations, dependencies, build commands, and lockfiles.
  • Migrates favorites and realloc tests from Bankrun to LiteSVM and corrects the realloc test runner.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains within the scope of the follow-up review.

Important Files Changed

Filename Overview
.github/.ghaignore Removes the three repaired native examples from CI exclusions.
basics/cross-program-invocation/native/package.json Corrects the two-program build command and updates TypeScript and Node type dependencies.
basics/favorites/native/tests/test.ts Rewrites the native favorites integration tests to execute synchronously with LiteSVM.
basics/realloc/native/tests/realloc.test.ts Migrates realloc integration tests to LiteSVM and the Node test runner.
basics/realloc/native/program/tests/test.rs Updates the Rust test fixture path to the artifact generated by the example build.
basics/realloc/native/tsconfig.json Adds the TypeScript configuration required by the CI type-check step.

Reviews (5): Last reviewed commit: "fix(#651): fix Rust unit test include_by..." | Re-trigger Greptile

NikkiAung and others added 3 commits July 25, 2026 10:37
… build script

realloc/native: bankrun 0.3.x rejects new SBPF opcodes emitted by the
stable toolchain (same issue as favorites/native). Switch to litesvm:
replace async bankrun start()/processTransaction()/getAccount() with
synchronous LiteSVM API. Use before() hook to set up shared SVM state
across the three sequential tests. Remove solana-bankrun dep.

cross-program-invocation/native: build script used --sbf-out-dir=./program/target/so,
creating a program/ directory. The CI's Rust unit test check fires when
[ -d program ] and then fails trying cargo test --manifest-path=./program/Cargo.toml
which doesn't exist. Fix: output to ./programs/target/so and specify
manifest paths explicitly, matching the build-and-test script.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…alloc test schema mismatch

CPI/native: build script output dir `./programs/target/so` is inside the
`programs/*` workspace glob, causing `cargo metadata` to fail on the second
build when the `programs/target/` directory exists. Switch to `./target/so`
which is outside the glob.

Realloc/native: "Reallocate WITH zero init" shrinks the account to WorkInfo
layout. Calling printEnhancedAddressInfo after this realloc tried to read a
larger schema from the smaller buffer → "buffer is smaller than expected".
Remove the stale printEnhancedAddressInfo call; only printWorkInfo applies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… realloc/native

The Rust unit test referenced the .so via a path to the workspace-root
target/deploy/ directory, which is never populated when the build script
uses --sbf-out-dir=./tests/fixtures. Use the same relative path that
basics/favorites/native uses: ../../tests/fixtures/<program>.so, which
resolves to the directory where pnpm build-and-test places the artifact.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant