LiteSVM Docs

Environment Configuration

Builder pattern methods for configuring LiteSVM test environments

All configuration methods use the builder pattern with LiteSVM::default().

with_compute_budget

pub fn with_compute_budget(self, compute_budget: ComputeBudget) -> Self

Set compute unit limits and heap size.

use solana_sdk::compute_budget::ComputeBudget;

let mut svm = LiteSVM::default()
    .with_compute_budget(ComputeBudget {
        compute_unit_limit: 1_400_000,
        heap_size: 256 * 1024,
        ..ComputeBudget::default()
    });

with_sigverify

pub fn with_sigverify(self, sigverify: bool) -> Self

Enable or disable signature verification. Default: true.

// Disable for faster tests
let mut svm = LiteSVM::default()
    .with_sigverify(false);

with_blockhash_check

pub fn with_blockhash_check(self, check: bool) -> Self

Enable or disable blockhash validation. Default: true.

// Disable to use any blockhash
let mut svm = LiteSVM::default()
    .with_blockhash_check(false);

with_transaction_history

pub fn with_transaction_history(self, capacity: usize) -> Self

Set number of transactions to keep in history. Default: 0.

// Keep last 100 transactions
let mut svm = LiteSVM::default()
    .with_transaction_history(100);

with_log_bytes_limit

pub fn with_log_bytes_limit(self, limit: Option<usize>) -> Self

Set maximum bytes for transaction logs. Default: Some(10_000).

// Unlimited logs
let mut svm = LiteSVM::default()
    .with_log_bytes_limit(None);

// Custom limit (50KB)
let mut svm = LiteSVM::default()
    .with_log_bytes_limit(Some(50_000));

with_lamports

pub fn with_lamports(self, lamports: u64) -> Self

Set initial lamports for fee collection. Default: 1_000_000_000.

let mut svm = LiteSVM::default()
    .with_lamports(10_000_000_000);

with_default_programs

pub fn with_default_programs(self) -> Self

Include default SPL programs (Token, Associated Token, etc.).

let mut svm = LiteSVM::default()
    .with_default_programs();

with_sysvars

pub fn with_sysvars(self) -> Self

Includes default sysvars (Clock, Rent, EpochSchedule, SlotHashes, StakeHistory, etc.).

let mut svm = LiteSVM::default()
    .with_sysvars();

with_feature_set

pub fn with_feature_set(self, feature_set: Arc<FeatureSet>) -> Self

Configure Solana feature set for testing specific runtime features.

use solana_sdk::feature_set::FeatureSet;
use std::sync::Arc;

let mut svm = LiteSVM::default()
    .with_feature_set(Arc::new(FeatureSet::all_enabled()));

with_precompiles

#[cfg(feature = "precompiles")]
pub fn with_precompiles(self) -> Self

Includes standard precompile programs (ed25519, secp256k1, secp256r1).

let mut svm = LiteSVM::default()
    .with_precompiles();

Requires the precompiles feature flag:

[dev-dependencies]
litesvm = { version = "0.8", features = ["precompiles"] }