Skip to content

test: add litesvm ts testcases#585

Open
aarjn wants to merge 1 commit into
solana-foundation:mainfrom
aarjn:cpi-test
Open

test: add litesvm ts testcases#585
aarjn wants to merge 1 commit into
solana-foundation:mainfrom
aarjn:cpi-test

Conversation

@aarjn

@aarjn aarjn commented Jun 1, 2026

Copy link
Copy Markdown

hy @Perelyn-sama raised PR here addressing the closed PR #392

Also I have noticed almost every ts test file for native program in basic are in bankrun.

@dev-jodee dev-jodee self-requested a review June 24, 2026 15:26

@dev-jodee dev-jodee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the CI gh action failure

@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown

Greptile Summary

This PR moves the native CPI TypeScript tests onto LiteSVM. The main changes are:

  • Adds litesvm to the native CPI package dependencies.
  • Builds the hand and lever SBF programs into test fixtures before running tests.
  • Rewrites the CPI test to load fixture programs and send transactions through LiteSVM.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
basics/cross-program-invocation/native/tests/test.ts Rewrites the CPI flow to use LiteSVM with Mocha tests and fixture-loaded programs.
basics/cross-program-invocation/native/package.json Adds LiteSVM and updates the build-and-test script to build both native programs before tests run.
basics/cross-program-invocation/native/pnpm-lock.yaml Locks LiteSVM and its platform-specific optional packages.

Reviews (2): Last reviewed commit: "test: add litesvm ts testcases" | Re-trigger Greptile

} from "@solana/web3.js";
import * as fs from "node:fs";
import * as path from "node:path";
import { before, describe, it } from "node:test";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Mocha Sees No Tests

The package script still runs this file through ts-mocha, but these imports register suites with Node's node:test runner instead of Mocha. When pnpm test loads the file, Mocha can see an empty suite and report success without running the CPI transactions.

Suggested change
import { before, describe, it } from "node:test";
import { before, describe, it } from "mocha";

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


const res = svm.sendTransaction(tx);
if (!(res instanceof TransactionMetadata)) {
throw new Error(`Transaction failed: ${res.meta().toString()}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failure Details Are Masked

If sendTransaction returns its failed-transaction variant, this branch assumes that object has meta() and can throw a TypeError while building the error message. A real program error or funding failure would then lose the LiteSVM failure details and report the wrong exception.

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.

2 participants