pub struct LiteSVM { /* private fields */ }Implementations§
Source§impl LiteSVM
impl LiteSVM
Sourcepub fn with_compute_budget(self, compute_budget: ComputeBudget) -> Self
pub fn with_compute_budget(self, compute_budget: ComputeBudget) -> Self
Sets the compute budget.
Sourcepub fn with_sigverify(self, sigverify: bool) -> Self
pub fn with_sigverify(self, sigverify: bool) -> Self
Enables or disables sigverify.
Sourcepub fn with_blockhash_check(self, check: bool) -> Self
pub fn with_blockhash_check(self, check: bool) -> Self
Enables or disables the blockhash check.
Sourcepub fn with_sysvars(self) -> Self
pub fn with_sysvars(self) -> Self
Includes the default sysvars.
Sourcepub fn with_feature_set(self, feature_set: FeatureSet) -> Self
pub fn with_feature_set(self, feature_set: FeatureSet) -> Self
Set the FeatureSet used by the VM instance.
Sourcepub fn with_builtins(self) -> Self
pub fn with_builtins(self) -> Self
Changes the default builtins.
Sourcepub fn with_lamports(self, lamports: u64) -> Self
pub fn with_lamports(self, lamports: u64) -> Self
Changes the initial lamports in LiteSVM’s airdrop account.
Sourcepub fn with_default_programs(self) -> Self
pub fn with_default_programs(self) -> Self
Includes the standard SPL programs.
Sourcepub fn with_transaction_history(self, capacity: usize) -> Self
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.
pub fn with_log_bytes_limit(self, limit: Option<usize>) -> Self
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<&TransactionResult>
pub fn get_transaction( &self, signature: &Signature, ) -> Option<&TransactionResult>
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) -> TransactionResult
pub fn airdrop(&mut self, address: &Address, lamports: u64) -> TransactionResult
Airdrops the account with the lamports specified.
Sourcepub fn add_builtin(
&mut self,
program_id: Address,
entrypoint: BuiltinFunctionWithContext,
)
pub fn add_builtin( &mut self, program_id: Address, entrypoint: BuiltinFunctionWithContext, )
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 am SBF program to the test environment.
Sourcepub fn send_transaction(
&mut self,
tx: impl Into<VersionedTransaction>,
) -> TransactionResult
pub fn send_transaction( &mut self, tx: impl Into<VersionedTransaction>, ) -> TransactionResult
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
Trait Implementations§
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>
Auto Trait Implementations§
impl Freeze for LiteSVM
impl RefUnwindSafe for LiteSVM
impl Send for LiteSVM
impl Sync for LiteSVM
impl Unpin 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