Overview
LiteSVM is a fast and lightweight library for testing Solana programs. It works by creating an in-process Solana VM optimized for program developers, making it much faster to run and compile than alternatives likesolana-program-test and solana-test-validator.
LiteSVM is available in:
- Rust - Full-featured testing in Rust
- TypeScript/JavaScript - Client-side testing with full SVM access
- Python - Testing via the
solderslibrary
Key Features
- Blazingly Fast - No validator startup time, tests run in milliseconds
- Lightweight - Minimal resource usage, compiles quickly
- Multi-Language - Use Rust, TypeScript, or Python
- Time Travel - Manipulate clock and slots for testing time-dependent logic
- Arbitrary Accounts - Write any account data, even impossible states
- Real SVM - Tests run against actual Solana VM, not a mock
When to Use LiteSVM
LiteSVM is ideal for:- Unit Testing - Test individual instructions in isolation
- Fast Iteration - Rapid test feedback during development
- CI/CD Pipelines - Quick test execution in automated builds
- Account Manipulation - Testing edge cases with custom account states
- Time-Dependent Logic - Programs that use the Clock sysvar
solana-test-validator when you need full RPC support or want to test against real validator behavior.
Installation
Quick Start
Here’s a simple transfer example to get you started:Testing Anchor Programs
To test an Anchor program with LiteSVM, you need to load the compiled program binary:Time Travel
LiteSVM allows you to manipulate the Clock sysvar to test time-dependent logic:Arbitrary Account States
LiteSVM lets you write any account data, even states that would be impossible to achieve normally. This is useful for testing edge cases:Advanced Features
Compute Budget Control
Disable Signature Verification
Transaction History
Performance Comparison
Best Practices
- Use LiteSVM for unit tests - Test individual instructions quickly
- Use test-validator for integration - Test full workflows and RPC interactions
- Mock account states - Use arbitrary accounts to test edge cases
- Time travel for scheduling - Test time-locked features without waiting
- Parallel tests - LiteSVM tests can run in parallel safely
Limitations
- No RPC methods - LiteSVM doesn’t expose RPC endpoints
- Simplified validator - Doesn’t simulate all validator behaviors
- No cross-program invocation limits - May behave differently than production
solana-test-validator.
Next Steps
- Learn about [Mollusktesting/mollusk) for even lighter Rust testing
- Explore [Testing Overviewtesting/overview) for testing strategies
- Check out the LiteSVM GitHub for more examples