Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

litesvm

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

litesvm

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
24K
16.22%
Maintainers
2
Weekly downloads
 
Created
Source

LiteSVM (NodeJS)

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 Node.js test runner.

import { test } from "node:test";
import assert from "node:assert/strict";
import { LiteSVM } from "litesvm";
import { getTransferSolInstruction } from "@solana-program/system";
import {
	appendTransactionMessageInstruction,
	createTransactionMessage,
	generateKeyPairSigner,
	lamports,
	pipe,
	setTransactionMessageFeePayerSigner,
	setTransactionMessageLifetimeUsingBlockhash,
	signTransactionMessageWithSigners,
} from "@solana/kit";

test("it transfers SOL from one wallet to another", async () => {
	// Given a payer with 2 SOL and a recipient with 0 SOL.
	const svm = new LiteSVM();
	const payer = await generateKeyPairSigner();
	const recipient = await generateKeyPairSigner();
	svm.airdrop(payer.address, lamports(2_000_000_000n));

	// When we send 1 SOL from the payer to the recipient.
	const instruction = getTransferSolInstruction({
		source: payer,
		destination: recipient.address,
		amount: lamports(1_000_000_000n),
	});
	const transaction = await pipe(
		createTransactionMessage({ version: 0 }),
		(tx) => setTransactionMessageFeePayerSigner(payer, tx),
		(tx) => svm.setTransactionMessageLifetimeUsingLatestBlockhash(tx),
		(tx) => appendTransactionMessageInstruction(instruction, tx),
		(tx) => signTransactionMessageWithSigners(tx),
	);
	svm.sendTransaction(transaction);

	// Then we expect the accounts to have the correct balances.
	assert.strictEqual(
		svm.getBalance(recipient.address),
		lamports(1_000_000_000n),
	);
	assert(svm.getBalance(payer.address) < lamports(1_000_000_000n));
});

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 30 Mar 2026

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