Configuration

Each setter mirrors the corresponding builder method on the Rust LiteSVM type. Calls take effect immediately and return an error.

Typical Test Setup

svm, err := litesvm.New()
if err != nil {
t.Fatal(err)
}
defer svm.Close()
// Each setter returns an error. The calls below are infallible in practice,
// so the docs use _ = ... for brevity; check the error in production code.
_ = svm.SetSigverify(false) // skip signature verification (faster)
_ = svm.SetBlockhashCheck(false) // skip blockhash validation (simpler)
_ = svm.SetSysvars() // reset Clock, Rent, etc. to defaults
_ = svm.SetBuiltins() // reload built-in programs
_ = svm.SetTransactionHistory(100) // keep the last 100 transactions

Signature and Blockhash

SetSigverify

func (s *LiteSVM) SetSigverify(enabled bool) error

Toggle transaction signature verification.

if err := svm.SetSigverify(false); err != nil { // accept unsigned / badly-signed txs
t.Fatal(err)
}
if err := svm.SetSigverify(true); err != nil { // restore production-like behavior
t.Fatal(err)
}

Disabling signature verification makes tests faster but less realistic.

Sigverify

func (s *LiteSVM) Sigverify() (bool, error)

Read the current setting.

SetBlockhashCheck

func (s *LiteSVM) SetBlockhashCheck(enabled bool) error

Toggle the recent-blockhash check on submitted transactions.

if err := svm.SetBlockhashCheck(false); err != nil { // accept any blockhash
t.Fatal(err)
}

Programs and Sysvars

SetSysvars

func (s *LiteSVM) SetSysvars() error

Re-initialize the built-in sysvars (Clock, Rent, EpochSchedule, ...) to their defaults.

SetBuiltins

func (s *LiteSVM) SetBuiltins() error

Load the default set of built-in programs.

SetDefaultPrograms

func (s *LiteSVM) SetDefaultPrograms() error

Load the standard SPL programs (System Program, SPL Token, Memo, ...).

SetPrecompiles

func (s *LiteSVM) SetPrecompiles() error

Enable the ed25519 / secp256k1 precompiled programs.

WithNativeMints

func (s *LiteSVM) WithNativeMints() error

Seed the SPL Token / Token-2022 native-mint accounts (wrapped SOL). No-op if the matching program is not loaded; call SetDefaultPrograms first if you want both.

Resource Limits

SetLamports

func (s *LiteSVM) SetLamports(lamports uint64) error

Set the default lamports balance of the internal airdrop-pool account.

if err := svm.SetLamports(1 << 40); err != nil { // ~1.1 trillion lamports (~1,100 SOL)
t.Fatal(err)
}

SetLogBytesLimit

func (s *LiteSVM) SetLogBytesLimit(limit int) error

Bound the total log bytes captured per transaction. Pass a negative value to remove the limit.

if err := svm.SetLogBytesLimit(10_000); err != nil { // 10 KB cap
t.Fatal(err)
}
if err := svm.SetLogBytesLimit(-1); err != nil { // unlimited
t.Fatal(err)
}

SetTransactionHistory

func (s *LiteSVM) SetTransactionHistory(capacity int) error

Set the capacity of the in-memory transaction history. Pass 0 to disable dedup and allow replaying identical transactions.

if err := svm.SetTransactionHistory(100); err != nil { // cap at 100 entries
t.Fatal(err)
}
if err := svm.SetTransactionHistory(0); err != nil { // disable dedup entirely
t.Fatal(err)
}

Compute Budget

type ComputeBudget struct {
// See litesvm-go/litesvm.go for the full field list.
// usize fields are normalized to uint64; HeapSize stays uint32.
ComputeUnitLimit uint64
HeapSize uint32
// ...
}

ComputeBudget

func (s *LiteSVM) ComputeBudget() (ComputeBudget, bool, error)

Read the current compute budget. The second return value reports whether a budget was explicitly set; if false, the struct contains the default values that will be used.

budget, set, err := svm.ComputeBudget()
if err != nil {
t.Fatal(err)
}
if !set {
budget.ComputeUnitLimit = 1_400_000
}
if err := svm.SetComputeBudget(budget); err != nil {
t.Fatal(err)
}

SetComputeBudget

func (s *LiteSVM) SetComputeBudget(b ComputeBudget) error

Install a compute budget for subsequent transactions.

Feature Sets

FeatureSet is an opaque handle - construct it, mutate it with Activate / Deactivate, then install it with SetFeatureSet. Close handles you create.

// Start with all features off, then activate what you care about.
fs, err := litesvm.NewFeatureSet()
if err != nil {
t.Fatal(err)
}
defer fs.Close()
if err := fs.Activate(featureID, 0); err != nil {
t.Fatal(err)
}
// Or start from "everything enabled" and flip specific features off.
fs2, err := litesvm.NewFeatureSetAllEnabled()
if err != nil {
t.Fatal(err)
}
defer fs2.Close()
if err := fs2.Deactivate(featureID); err != nil {
t.Fatal(err)
}
if err := svm.SetFeatureSet(fs); err != nil {
t.Fatal(err)
}
MethodDescription
litesvm.NewFeatureSet() (*FeatureSet, error)Empty set (all features inactive)
litesvm.NewFeatureSetAllEnabled() (*FeatureSet, error)All features active
fs.Activate(featureID, slot) errorMark feature active at slot
fs.Deactivate(featureID) errorMark feature inactive
fs.IsActive(featureID) boolActive check
fs.ActivatedSlot(featureID) (uint64, bool)Slot a feature was activated at
fs.ActiveCount() intActive feature count
fs.InactiveCount() intInactive feature count
fs.ActiveFeatures() []solana.PublicKeyList active feature IDs
fs.InactiveFeatures() []solana.PublicKeyList inactive feature IDs
fs.Close()Release the handle
svm.SetFeatureSet(*FeatureSet) errorInstall on the SVM

Use feature gating to test how programs behave under a specific Solana version

  • activate the features that shipped with the release you target, then deactivate any that arrived later.

Is this page helpful?

© 2026 Solana Foundation. 無断転載を禁じます。