pub struct ProgramTestBench {
pub context: ProgramTestContext,
pub rent: Rent,
pub payer: Keypair,
pub next_id: u8,
}
Expand description
Program’s test bench which captures test context, rent and payer and common utility functions
Fields§
§context: ProgramTestContext
§rent: Rent
§payer: Keypair
§next_id: u8
Implementations§
source§impl ProgramTestBench
impl ProgramTestBench
sourcepub async fn start_new(program_test: ProgramTest) -> Self
pub async fn start_new(program_test: ProgramTest) -> Self
Create new bench given a ProgramTest instance populated with all of the desired programs.
pub fn get_unique_name(&mut self, prefix: &str) -> String
pub async fn process_transaction( &mut self, instructions: &[Instruction], signers: Option<&[&Keypair]> ) -> Result<(), ProgramError>
pub async fn with_wallet(&mut self) -> WalletCookie
pub async fn create_mint( &mut self, mint_keypair: &Keypair, mint_authority: &Pubkey, freeze_authority: Option<&Pubkey> )
Sets spl-token program account (Mint or TokenAccount) authority
pub async fn create_empty_token_account( &mut self, token_account_keypair: &Keypair, token_mint: &Pubkey, owner: &Pubkey )
pub async fn with_token_account( &mut self, token_mint: &Pubkey, owner: &Pubkey, token_mint_authority: &Keypair, amount: u64 ) -> TokenAccountCookie
pub async fn transfer_sol(&mut self, to_account: &Pubkey, lamports: u64)
pub async fn mint_tokens( &mut self, token_mint: &Pubkey, token_mint_authority: &Keypair, token_account: &Pubkey, amount: u64 )
pub async fn get_clock(&mut self) -> Clock
pub async fn get_bincode_account<T: DeserializeOwned>( &mut self, address: &Pubkey ) -> T
sourcepub async fn get_borsh_account<T: BorshDeserialize>(
&mut self,
address: &Pubkey
) -> T
pub async fn get_borsh_account<T: BorshDeserialize>( &mut self, address: &Pubkey ) -> T
TODO: Add to SDK
sourcepub fn set_borsh_account<T: BorshSerialize>(
&mut self,
program_id: &Pubkey,
address: &Pubkey,
account: &T
)
pub fn set_borsh_account<T: BorshSerialize>( &mut self, program_id: &Pubkey, address: &Pubkey, account: &T )
Overrides or creates Borsh serialized account with arbitrary account data subverting normal runtime checks
pub async fn get_account(&mut self, address: &Pubkey) -> Option<Account>
Auto Trait Implementations§
impl !RefUnwindSafe for ProgramTestBench
impl Send for ProgramTestBench
impl Sync for ProgramTestBench
impl Unpin for ProgramTestBench
impl !UnwindSafe for ProgramTestBench
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more