Socket
Book a DemoInstallSign in
Socket

anchor-litesvm

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anchor-litesvm

`anchor-litesvm` is a small extension to [LiteSVM](https://github.com/LiteSVM/litesvm) that enables using both Anchor and LiteSVM with minimal code changes. It does this by exporting a `LitesvmProvider` class that can be used as a replacement for `AnchorP

latest
npmnpm
Version
0.2.1
Version published
Weekly downloads
157
-38.67%
Maintainers
1
Weekly downloads
 
Created
Source

anchor-litesvm

anchor-litesvm is a small extension to LiteSVM that enables using both Anchor and LiteSVM with minimal code changes. It does this by exporting a LitesvmProvider class that can be used as a replacement for AnchorProvider during testing.

Async note

litesvm is synchronous because it is entirely compute-bound. However, anchor-litesvm uses async because it implements interfaces that require async. If you would like to avoid async tests, you can simply use regular litesvm without anchor-litesvm.

Usage

Here's an example using LitesvmProvider to test an Anchor program:

import { fromWorkspace, LiteSVMProvider } from "anchor-litesvm";
import { Keypair, PublicKey } from "@solana/web3.js";
import { BN, Program, Wallet } from "@coral-xyz/anchor";
import { Puppet } from "./anchor-example/puppet";
const IDL = require("./anchor-example/puppet.json");

test("anchor", async () => {
	const client = fromWorkspace("tests/anchor-example");
	const provider = new LiteSVMProvider(client);
	const puppetProgram = new Program<Puppet>(IDL, provider);
	const puppetKeypair = Keypair.generate();
	await puppetProgram.methods
		.initialize()
		.accounts({
			puppet: puppetKeypair.publicKey,
		})
		.signers([puppetKeypair])
		.rpc();

	const data = new BN(123456);
	await puppetProgram.methods
		.setData(data)
		.accounts({
			puppet: puppetKeypair.publicKey,
		})
		.rpc();

	const dataAccount = await puppetProgram.account.data.fetch(
		puppetKeypair.publicKey,
	);
	expect(dataAccount.data.eq(new BN(123456)));
});

Installation

yarn add anchor-litesvm

FAQs

Package last updated on 05 Sep 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