pub struct TestSVM {
pub svm: LiteSVM,
pub default_fee_payer: Keypair,
pub address_book: AddressBook,
}Expand description
Test SVM wrapper for LiteSVM with payer management and Anchor helpers
Fields§
§svm: LiteSVMUnderlying LiteSVM instance
default_fee_payer: KeypairDefault fee payer for transactions.
address_book: AddressBookAddress book for labeling addresses
Implementations§
Source§impl TestSVM
impl TestSVM
Sourcepub fn execute_transaction(&mut self, transaction: Transaction) -> TXResult
pub fn execute_transaction(&mut self, transaction: Transaction) -> TXResult
Execute a transaction with the test SVM’s payer
Sourcepub fn execute_ixs(&mut self, instructions: &[Instruction]) -> TXResult
pub fn execute_ixs(&mut self, instructions: &[Instruction]) -> TXResult
Execute instructions with the test SVM’s payer
Sourcepub fn execute_ixs_with_signers(
&mut self,
instructions: &[Instruction],
signers: &[&Keypair],
) -> TXResult
pub fn execute_ixs_with_signers( &mut self, instructions: &[Instruction], signers: &[&Keypair], ) -> TXResult
Execute instructions with additional signers
Sourcepub fn new_wallet(&mut self, name: &str) -> Result<Keypair>
pub fn new_wallet(&mut self, name: &str) -> Result<Keypair>
Create a new funded wallet and add to address book
Sourcepub fn default_fee_payer(&self) -> Pubkey
pub fn default_fee_payer(&self) -> Pubkey
Get the default fee payer’s public key
Sourcepub fn add_program_from_path(
&mut self,
label: &str,
pubkey: Pubkey,
path: impl AsRef<Path>,
) -> Result<()>
pub fn add_program_from_path( &mut self, label: &str, pubkey: Pubkey, path: impl AsRef<Path>, ) -> Result<()>
Add a program to the address book
Sourcepub fn add_program_fixture(
&mut self,
fixture_name: &str,
pubkey: Pubkey,
) -> Result<()>
pub fn add_program_fixture( &mut self, fixture_name: &str, pubkey: Pubkey, ) -> Result<()>
Add a program fixture from the fixtures directory.
This method loads a program binary from the fixtures directory. The fixture file
should be located at fixtures/programs/{fixture_name}.so relative to your project root.
Sourcepub fn get_pda<T: AccountDeserialize>(
&mut self,
label: &str,
seeds: &[&[u8]],
program_id: Pubkey,
) -> Result<AccountRef<T>>
pub fn get_pda<T: AccountDeserialize>( &mut self, label: &str, seeds: &[&[u8]], program_id: Pubkey, ) -> Result<AccountRef<T>>
Finds a program derived address and return an AccountRef with proper type information.
Sourcepub fn get_pda_with_bump<T: AccountDeserialize>(
&mut self,
label: &str,
seeds: &[&[u8]],
program_id: Pubkey,
) -> Result<(AccountRef<T>, u8)>
pub fn get_pda_with_bump<T: AccountDeserialize>( &mut self, label: &str, seeds: &[&[u8]], program_id: Pubkey, ) -> Result<(AccountRef<T>, u8)>
Finds a program derived address and return an AccountRef with proper type information and bump seed.
Sourcepub fn advance_time(&mut self, seconds: u64)
pub fn advance_time(&mut self, seconds: u64)
Advance the time by the specified number of seconds Assumes 450ms per slot, in practice this is not always the case.
Sourcepub fn advance_slots(&mut self, num_slots: u32)
pub fn advance_slots(&mut self, num_slots: u32)
Advance slots using LiteSVM’s warp_to_slot feature This is useful for simulating time passing in tests
Auto Trait Implementations§
impl Freeze for TestSVM
impl RefUnwindSafe for TestSVM
impl Send for TestSVM
impl Sync for TestSVM
impl Unpin for TestSVM
impl UnwindSafe for TestSVM
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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