LiteSVM

Struct LiteSVM 

Source
pub struct LiteSVM { /* private fields */ }

Implementations§

Source§

impl LiteSVM

Source

pub fn new() -> Self

Creates the basic test environment.

Source

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

Sets the compute budget.

Source

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

Enables or disables sigverify.

Source

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

Enables or disables the blockhash check.

Source

pub fn with_sysvars(self) -> Self

Includes the default sysvars.

Source

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

Set the FeatureSet used by the VM instance.

Source

pub fn with_builtins(self) -> Self

Changes the default builtins.

Source

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

Changes the initial lamports in LiteSVM’s airdrop account.

Source

pub fn with_default_programs(self) -> Self

Includes the standard SPL programs.

Source

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

Changes the capacity of the transaction history. Set this to 0 to disable transaction history and allow duplicate transactions.

Source

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

Source

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.

Source

pub fn get_account(&self, address: &Address) -> Option<Account>

Returns all information associated with the account of the provided pubkey.

Source

pub fn set_account( &mut self, address: Address, data: Account, ) -> Result<(), LiteSVMError>

Sets all information associated with the account of the provided pubkey.

Source

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 needed
Source

pub fn get_balance(&self, address: &Address) -> Option<u64>

Gets the balance of the provided account pubkey.

Source

pub fn latest_blockhash(&self) -> Hash

Gets the latest blockhash.

Source

pub fn set_sysvar<T>(&mut self, sysvar: &T)

Sets the sysvar to the test environment.

Source

pub fn get_sysvar<T>(&self) -> T

Gets a sysvar from the test environment.

Source

pub fn get_transaction( &self, signature: &Signature, ) -> Option<&TransactionResult>

Gets a transaction from the transaction history.

Source

pub fn airdrop_pubkey(&self) -> Address

Returns the pubkey of the internal airdrop account.

Source

pub fn airdrop(&mut self, address: &Address, lamports: u64) -> TransactionResult

Airdrops the account with the lamports specified.

Source

pub fn add_builtin( &mut self, program_id: Address, entrypoint: BuiltinFunctionWithContext, )

Adds a builtin program to the test environment.

Source

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.

Source

pub fn add_program( &mut self, program_id: impl Into<Address>, program_bytes: &[u8], ) -> Result<(), LiteSVMError>

Adds am SBF program to the test environment.

Source

pub fn send_transaction( &mut self, tx: impl Into<VersionedTransaction>, ) -> TransactionResult

Submits a signed transaction.

Source

pub fn simulate_transaction( &self, tx: impl Into<VersionedTransaction>, ) -> Result<SimulatedTransactionInfo, FailedTransactionMetadata>

Simulates a transaction.

Source

pub fn expire_blockhash(&mut self)

Expires the current blockhash.

Source

pub fn warp_to_slot(&mut self, slot: u64)

Warps the clock to the specified slot.

Source

pub fn get_compute_budget(&self) -> Option<ComputeBudget>

Gets the current compute budget.

Source

pub fn get_sigverify(&self) -> bool

Trait Implementations§

Source§

impl Clone for LiteSVM

Source§

fn clone(&self) -> LiteSVM

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for LiteSVM

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl InvokeContextCallback for LiteSVM

Available on non-crate feature precompiles only.
Source§

fn get_epoch_stake(&self) -> u64

Returns the total current epoch stake for the network.
Source§

fn get_epoch_stake_for_vote_account(&self, _vote_address: &Address) -> u64

Returns the current epoch stake for the given vote account.
Source§

fn is_precompile(&self, _program_id: &Address) -> bool

Returns true if the program_id corresponds to a precompiled program
Source§

fn process_precompile( &self, _program_id: &Address, _data: &[u8], _instruction_datas: Vec<&[u8]>, ) -> Result<(), PrecompileError>

Calls the precompiled program corresponding to the given program ID.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V