pub struct LiteSVM { /* private fields */ }Implementations§
Source§impl LiteSVM
impl LiteSVM
Sourcepub fn with_compute_budget(self, compute_budget: ComputeBudget) -> LiteSVM
pub fn with_compute_budget(self, compute_budget: ComputeBudget) -> LiteSVM
Sets the compute budget.
Sourcepub fn with_sigverify(self, sigverify: bool) -> LiteSVM
pub fn with_sigverify(self, sigverify: bool) -> LiteSVM
Enables or disables sigverify.
Sourcepub fn with_blockhash_check(self, check: bool) -> LiteSVM
pub fn with_blockhash_check(self, check: bool) -> LiteSVM
Enables or disables the blockhash check.
Sourcepub fn with_sysvars(self) -> LiteSVM
pub fn with_sysvars(self) -> LiteSVM
Includes the default sysvars.
Sourcepub fn with_feature_set(self, feature_set: FeatureSet) -> LiteSVM
pub fn with_feature_set(self, feature_set: FeatureSet) -> LiteSVM
Set the FeatureSet used by the VM instance.
pub fn with_feature_accounts(self) -> LiteSVM
Sourcepub fn with_builtins(self) -> LiteSVM
pub fn with_builtins(self) -> LiteSVM
Changes the default builtins.
Sourcepub fn with_lamports(self, lamports: u64) -> LiteSVM
pub fn with_lamports(self, lamports: u64) -> LiteSVM
Changes the initial lamports in LiteSVM’s airdrop account.
Sourcepub fn with_default_programs(self) -> LiteSVM
pub fn with_default_programs(self) -> LiteSVM
Includes the standard SPL programs.
Sourcepub fn with_transaction_history(self, capacity: usize) -> LiteSVM
pub fn with_transaction_history(self, capacity: usize) -> LiteSVM
Changes the capacity of the transaction history. Set this to 0 to disable transaction history and allow duplicate transactions.
pub fn with_log_bytes_limit(self, limit: Option<usize>) -> LiteSVM
Sourcepub fn minimum_balance_for_rent_exemption(&self, data_len: usize) -> u64
pub fn minimum_balance_for_rent_exemption(&self, data_len: usize) -> u64
Returns minimum balance required to make an account with specified data length rent exempt.
Sourcepub fn get_account(&self, address: &Address) -> Option<Account>
pub fn get_account(&self, address: &Address) -> Option<Account>
Returns all information associated with the account of the provided pubkey.
Sourcepub fn set_account(
&mut self,
address: Address,
data: Account,
) -> Result<(), LiteSVMError>
pub fn set_account( &mut self, address: Address, data: Account, ) -> Result<(), LiteSVMError>
Sets all information associated with the account of the provided pubkey.
Sourcepub fn accounts_db(&self) -> &AccountsDb
pub fn accounts_db(&self) -> &AccountsDb
⚠️ ADVANCED USE ONLY ⚠️
Returns a reference to the internal accounts database.
This provides read-only access to the accounts database for advanced inspection.
Use get_account for normal account retrieval.
§Examples
use litesvm::LiteSVM;
let svm = LiteSVM::new();
// Read-only access to accounts database
let accounts_db = svm.accounts_db();
// ... inspect internal state if neededSourcepub fn get_balance(&self, address: &Address) -> Option<u64>
pub fn get_balance(&self, address: &Address) -> Option<u64>
Gets the balance of the provided account pubkey.
Sourcepub fn latest_blockhash(&self) -> Hash
pub fn latest_blockhash(&self) -> Hash
Gets the latest blockhash.
Sourcepub fn set_sysvar<T>(&mut self, sysvar: &T)
pub fn set_sysvar<T>(&mut self, sysvar: &T)
Sets the sysvar to the test environment.
Sourcepub fn get_sysvar<T>(&self) -> T
pub fn get_sysvar<T>(&self) -> T
Gets a sysvar from the test environment.
Sourcepub fn get_transaction(
&self,
signature: &Signature,
) -> Option<&Result<TransactionMetadata, FailedTransactionMetadata>>
pub fn get_transaction( &self, signature: &Signature, ) -> Option<&Result<TransactionMetadata, FailedTransactionMetadata>>
Gets a transaction from the transaction history.
Sourcepub fn airdrop_pubkey(&self) -> Address
pub fn airdrop_pubkey(&self) -> Address
Returns the pubkey of the internal airdrop account.
Sourcepub fn airdrop(
&mut self,
address: &Address,
lamports: u64,
) -> Result<TransactionMetadata, FailedTransactionMetadata>
pub fn airdrop( &mut self, address: &Address, lamports: u64, ) -> Result<TransactionMetadata, FailedTransactionMetadata>
Airdrops the account with the lamports specified.
Sourcepub fn add_builtin(
&mut self,
program_id: Address,
entrypoint: fn(*mut EbpfVm<'_, InvokeContext<'static, 'static>>, u64, u64, u64, u64, u64),
)
pub fn add_builtin( &mut self, program_id: Address, entrypoint: fn(*mut EbpfVm<'_, InvokeContext<'static, 'static>>, u64, u64, u64, u64, u64), )
Adds a builtin program to the test environment.
Sourcepub fn add_program_from_file(
&mut self,
program_id: impl Into<Address>,
path: impl AsRef<Path>,
) -> Result<(), LiteSVMError>
pub fn add_program_from_file( &mut self, program_id: impl Into<Address>, path: impl AsRef<Path>, ) -> Result<(), LiteSVMError>
Adds an SBF program to the test environment from the file specified.
Sourcepub fn add_program(
&mut self,
program_id: impl Into<Address>,
program_bytes: &[u8],
) -> Result<(), LiteSVMError>
pub fn add_program( &mut self, program_id: impl Into<Address>, program_bytes: &[u8], ) -> Result<(), LiteSVMError>
Adds an SBF program to the test environment.
Uses BPFLoaderUpgradeable by default for the loader.
Sourcepub fn add_program_with_loader(
&mut self,
program_id: impl Into<Address>,
program_bytes: &[u8],
loader_id: Address,
) -> Result<(), LiteSVMError>
pub fn add_program_with_loader( &mut self, program_id: impl Into<Address>, program_bytes: &[u8], loader_id: Address, ) -> Result<(), LiteSVMError>
Adds an SBF program with a specific loader to match mainnet CU behavior.
Use bpf_loader::id() for BPFLoader2, bpf_loader_deprecated::id() for BPFLoader1,
or bpf_loader_upgradeable::id() for the upgradeable loader.
Sourcepub fn send_transaction(
&mut self,
tx: impl Into<VersionedTransaction>,
) -> Result<TransactionMetadata, FailedTransactionMetadata>
pub fn send_transaction( &mut self, tx: impl Into<VersionedTransaction>, ) -> Result<TransactionMetadata, FailedTransactionMetadata>
Submits a signed transaction.
Sourcepub fn simulate_transaction(
&self,
tx: impl Into<VersionedTransaction>,
) -> Result<SimulatedTransactionInfo, FailedTransactionMetadata>
pub fn simulate_transaction( &self, tx: impl Into<VersionedTransaction>, ) -> Result<SimulatedTransactionInfo, FailedTransactionMetadata>
Simulates a transaction.
Sourcepub fn expire_blockhash(&mut self)
pub fn expire_blockhash(&mut self)
Expires the current blockhash.
Sourcepub fn warp_to_slot(&mut self, slot: u64)
pub fn warp_to_slot(&mut self, slot: u64)
Warps the clock to the specified slot.
Sourcepub fn get_compute_budget(&self) -> Option<ComputeBudget>
pub fn get_compute_budget(&self) -> Option<ComputeBudget>
Gets the current compute budget.
pub fn get_sigverify(&self) -> bool
Sourcepub fn with_custom_syscall(
self,
name: &str,
syscall: fn(*mut EbpfVm<'_, InvokeContext<'static, 'static>>, u64, u64, u64, u64, u64),
) -> LiteSVM
pub fn with_custom_syscall( self, name: &str, syscall: fn(*mut EbpfVm<'_, InvokeContext<'static, 'static>>, u64, u64, u64, u64, u64), ) -> LiteSVM
Registers a custom syscall in both program runtime environments (v1 and v2).
Must be called after with_builtins() (which recreates the environments
from scratch) and before with_default_programs() (which clones the
environment Arcs into program cache entries, preventing further mutation).
Panics if the runtime environments cannot be mutated or if registration fails. This is intentional — a misconfigured syscall should fail loudly rather than silently.
Trait Implementations§
Source§impl AssertionHelpers for LiteSVM
impl AssertionHelpers for LiteSVM
Source§fn assert_account_closed(&self, pubkey: &Pubkey)
fn assert_account_closed(&self, pubkey: &Pubkey)
Source§fn assert_account_exists(&self, pubkey: &Pubkey)
fn assert_account_exists(&self, pubkey: &Pubkey)
Source§fn assert_token_balance(&self, token_account: &Pubkey, expected: u64)
fn assert_token_balance(&self, token_account: &Pubkey, expected: u64)
Source§impl InvokeContextCallback for LiteSVM
Available on non-crate feature precompiles only.
impl InvokeContextCallback for LiteSVM
precompiles only.Source§fn get_epoch_stake(&self) -> u64
fn get_epoch_stake(&self) -> u64
Source§fn get_epoch_stake_for_vote_account(&self, _vote_address: &Address) -> u64
fn get_epoch_stake_for_vote_account(&self, _vote_address: &Address) -> u64
Source§fn is_precompile(&self, _program_id: &Address) -> bool
fn is_precompile(&self, _program_id: &Address) -> bool
Source§fn process_precompile(
&self,
_program_id: &Address,
_data: &[u8],
_instruction_datas: Vec<&[u8]>,
) -> Result<(), PrecompileError>
fn process_precompile( &self, _program_id: &Address, _data: &[u8], _instruction_datas: Vec<&[u8]>, ) -> Result<(), PrecompileError>
Source§impl ProgramTestExt for LiteSVM
impl ProgramTestExt for LiteSVM
Source§impl TestHelpers for LiteSVM
impl TestHelpers for LiteSVM
Source§fn create_funded_account(
&mut self,
lamports: u64,
) -> Result<Keypair, Box<dyn Error>>
fn create_funded_account( &mut self, lamports: u64, ) -> Result<Keypair, Box<dyn Error>>
Source§fn create_funded_accounts(
&mut self,
count: usize,
lamports: u64,
) -> Result<Vec<Keypair>, Box<dyn Error>>
fn create_funded_accounts( &mut self, count: usize, lamports: u64, ) -> Result<Vec<Keypair>, Box<dyn Error>>
Source§fn create_token_mint(
&mut self,
authority: &Keypair,
decimals: u8,
) -> Result<Keypair, Box<dyn Error>>
fn create_token_mint( &mut self, authority: &Keypair, decimals: u8, ) -> Result<Keypair, Box<dyn Error>>
Source§fn create_token_account(
&mut self,
mint: &Pubkey,
owner: &Keypair,
) -> Result<Keypair, Box<dyn Error>>
fn create_token_account( &mut self, mint: &Pubkey, owner: &Keypair, ) -> Result<Keypair, Box<dyn Error>>
Source§fn create_associated_token_account(
&mut self,
mint: &Pubkey,
owner: &Keypair,
) -> Result<Pubkey, Box<dyn Error>>
fn create_associated_token_account( &mut self, mint: &Pubkey, owner: &Keypair, ) -> Result<Pubkey, Box<dyn Error>>
Source§fn mint_to(
&mut self,
mint: &Pubkey,
account: &Pubkey,
authority: &Keypair,
amount: u64,
) -> Result<(), Box<dyn Error>>
fn mint_to( &mut self, mint: &Pubkey, account: &Pubkey, authority: &Keypair, amount: u64, ) -> Result<(), Box<dyn Error>>
Source§fn derive_pda(&self, seeds: &[&[u8]], program_id: &Pubkey) -> (Pubkey, u8)
fn derive_pda(&self, seeds: &[&[u8]], program_id: &Pubkey) -> (Pubkey, u8)
Source§fn get_current_slot(&self) -> u64
fn get_current_slot(&self) -> u64
Source§fn advance_slot(&mut self, slots: u64)
fn advance_slot(&mut self, slots: u64)
Source§impl TransactionHelpers for LiteSVM
impl TransactionHelpers for LiteSVM
Source§fn send_instruction(
&mut self,
instruction: Instruction,
signers: &[&Keypair],
) -> Result<TransactionResult, TransactionError>
fn send_instruction( &mut self, instruction: Instruction, signers: &[&Keypair], ) -> Result<TransactionResult, TransactionError>
Source§fn send_instructions(
&mut self,
instructions: &[Instruction],
signers: &[&Keypair],
) -> Result<TransactionResult, TransactionError>
fn send_instructions( &mut self, instructions: &[Instruction], signers: &[&Keypair], ) -> Result<TransactionResult, TransactionError>
Source§fn send_transaction_result(
&mut self,
transaction: Transaction,
) -> Result<TransactionResult, TransactionError>
fn send_transaction_result( &mut self, transaction: Transaction, ) -> Result<TransactionResult, TransactionError>
Auto Trait Implementations§
impl Freeze for LiteSVM
impl RefUnwindSafe for LiteSVM
impl Send for LiteSVM
impl Sync for LiteSVM
impl Unpin for LiteSVM
impl UnsafeUnpin for LiteSVM
impl UnwindSafe for LiteSVM
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more