litesvm-utils
Framework-agnostic testing utilities for LiteSVM - One-line token operations, assertions, and account management for any Solana program.
Overview
litesvm-utils provides ergonomic testing utilities that work with any Solana program - Native, Anchor, SPL, or custom frameworks. It eliminates boilerplate by providing one-line helpers for common testing operations.
Use this crate if you're testing:
- Native Solana programs
- SPL programs
- Non-Anchor custom frameworks
- Or if you need just testing utilities without Anchor-specific features
Note: If you're testing Anchor programs, consider using
anchor-litesvminstead, which builds on this crate and adds Anchor-specific features.
Installation
[]
= "0.3"
Quick Start
use ;
use Signer;
Features
Test Account Helpers
// Create funded accounts
let user = svm.create_funded_account?;
let accounts = svm.create_funded_accounts?;
Token Operations
// Create mint and token accounts
let mint = svm.create_token_mint?;
let token_account = svm.create_token_account?;
let ata = svm.create_associated_token_account?;
// Mint tokens
svm.mint_to?;
Transaction Helpers
// Send single instruction
let result = svm.send_instruction?;
// Send multiple instructions
let result = svm.send_instructions?;
// Analyze results
result.assert_success;
result.assert_failure;
result.assert_error;
// Debug
result.print_logs;
let cu = result.compute_units;
let logs = result.logs;
Assertions
// Account existence
svm.assert_account_exists;
svm.assert_account_closed;
// Ownership and data
svm.assert_account_owner;
svm.assert_account_data_len;
// Balances
svm.assert_token_balance;
svm.assert_sol_balance;
svm.assert_mint_supply;
PDA Utilities
// Get PDA
let pda = svm.get_pda;
// Get PDA with bump
let = svm.get_pda_with_bump;
// Derive (alias)
let pda = svm.derive_pda;
Clock Manipulation
// Get current slot
let slot = svm.get_current_slot;
// Advance time
svm.advance_slot;
API Reference
Traits
| Trait | Description |
|---|---|
TestHelpers |
Account creation, token operations, PDA utilities |
AssertionHelpers |
State verification and balance assertions |
TransactionHelpers |
Transaction execution and result handling |
ProgramTestExt |
Program deployment helpers |
Builder
// New empty SVM
let svm = new.build;
// With single program
let svm = build_with_program;
// With multiple programs
let svm = build_with_programs;
// Chained building
let svm = new
.deploy_program
.build;
Testing
This crate has comprehensive test coverage:
Related Crates
anchor-litesvm- Anchor-specific testing (builds on this crate)litesvm- The underlying fast Solana VM
License
MIT License - see LICENSE for details.