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: u8Implementations§
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 Freeze for ProgramTestBench
impl RefUnwindSafe for ProgramTestBench
impl Send for ProgramTestBench
impl Sync for ProgramTestBench
impl Unpin for ProgramTestBench
impl UnwindSafe for ProgramTestBench
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
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>
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 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>
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