Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

litesvm-with-snapshot

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

litesvm-with-snapshot

latest
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

LiteSVM (NodeJS)

[!NOTE] This is a fork.

This is the NodeJS wrapper for LiteSVM. It brings best-in-class Solana testing to NodeJS, giving you a powerful, fast and ergonomic way to test Solana programs in TS/JS.

For a standard testing workflow, LiteSVM offers an experience superior to solana-test-validator (slow, unwieldy) and bankrun (reasonably fast and powerful, but inherits a lot of warts from solana-program-test).

Minimal example

This example just transfers lamports from Alice to Bob without loading any programs of our own. It uses the jest test runner but you can use any test runner you like.

import { LiteSVM } from "litesvm";
import {
	PublicKey,
	Transaction,
	SystemProgram,
	Keypair,
	LAMPORTS_PER_SOL,
} from "@solana/web3.js";

test("one transfer", () => {
	const svm = new LiteSVM();
	const payer = new Keypair();
	svm.airdrop(payer.publicKey, BigInt(LAMPORTS_PER_SOL));
	const receiver = PublicKey.unique();
	const blockhash = svm.latestBlockhash();
	const transferLamports = 1_000_000n;
	const ixs = [
		SystemProgram.transfer({
			fromPubkey: payer.publicKey,
			toPubkey: receiver,
			lamports: transferLamports,
		}),
	];
	const tx = new Transaction();
	tx.recentBlockhash = blockhash;
	tx.add(...ixs);
	tx.sign(payer);
	svm.sendTransaction(tx);
	const balanceAfter = svm.getBalance(receiver);
	expect(balanceAfter).toBe(transferLamports);
});

Note: by default the LiteSVM instance includes some core programs such as the System Program and SPL Token.

Installation

yarn add litesvm

Contributing

Make sure you have Yarn and the Rust toolchain installed.

Then run yarn to install deps, run yarn build to build the binary and yarn test to run the tests.

FAQs

Package last updated on 15 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts