hpsvm is a fast and lightweight library for testing Solana programs. It works by creating an in-process Solana VM optimized for program developers. This makes it much faster to run and compile than alternatives like solana-program-test and solana-test-validator. In a further break from tradition, it has an ergonomic API with sane defaults and extensive configurability for those who want it.
This is a pure Rust library, making it ideal for Rust-native Solana development workflows.
- 🚀 High Performance: In-process VM runs tests significantly faster than external validators
- 🛠️ Easy to Use: Simple API with sensible defaults and comprehensive configuration options
- 🔧 Pure Rust: No external dependencies or runtime requirements beyond Rust
- 📊 Comprehensive Testing: Supports transactions, account management, and program execution
- 🔄 Configurable: Extensive options for customizing the test environment
- 📚 Well Documented: Full API documentation and examples
- Rust
- Solana CLI (for building test programs)
Add hpsvm as a development dependency to your Solana program project:
cargo add --dev hpsvmHere's a minimal example that demonstrates creating a test environment, airdropping SOL, and executing a transfer transaction:
use hpsvm::HPSVM;
use solana_address::Address;
use solana_keypair::Keypair;
use solana_message::Message;
use solana_signer::Signer;
use solana_system_interface::instruction::transfer;
use solana_transaction::Transaction;
// Create keypairs for testing
let from_keypair = Keypair::new();
let from = from_keypair.pubkey();
let to = Address::new_unique();
// Initialize the SVM with default configuration
let mut svm = HPSVM::new();
// Airdrop SOL to the sender account
svm.airdrop(&from, 10_000).unwrap();
// Create a transfer instruction
let instruction = transfer(&from, &to, 64);
// Build and sign the transaction
let tx = Transaction::new(
&[&from_keypair],
Message::new(&[instruction], Some(&from)),
svm.latest_blockhash(),
);
// Execute the transaction
let tx_result = svm.send_transaction(tx).unwrap();
// Verify the results
let from_account = svm.get_account(&from).unwrap();
let to_account = svm.get_account(&to).unwrap();
assert_eq!(from_account.lamports, 4936); // 10000 - 64 - fee
assert_eq!(to_account.lamports, 64);For more advanced usage, including custom configurations, program deployment, and complex transaction scenarios, see the full documentation.
The test suite uses Solana programs that need to be built first:
cd crates/hpsvm/test_programs
cargo build-sbfRun the full test suite:
cargo testcargo benchFormat code:
cargo fmtLint code:
cargo clippy- Initially forked from litesvm
- Built for the Solana ecosystem
- Inspired by the need for faster, more ergonomic testing tools
- Thanks to the Solana community for their contributions and feedback