pub struct MolluskContext<AS: AccountStore> {
pub mollusk: Mollusk,
pub account_store: Rc<RefCell<AS>>,
}Expand description
A stateful wrapper around Mollusk that provides additional context and
convenience features for testing programs.
MolluskContext maintains persistent state between instruction executions,
starting with an account store that automatically manages account
lifecycles. This makes it ideal for complex testing scenarios involving
multiple instructions, instruction chains, and stateful program
interactions.
Note: Account state is only persisted if the instruction execution was successful. If an instruction fails, the account state will not be updated.
The API is functionally identical to Mollusk but with enhanced state
management and a streamlined interface. Namely, the input accounts slice
is no longer required, and the returned result does not contain a
resulting_accounts field.
Fields§
§mollusk: Mollusk§account_store: Rc<RefCell<AS>>Implementations§
Source§impl<AS: AccountStore> MolluskContext<AS>
impl<AS: AccountStore> MolluskContext<AS>
Sourcepub fn process_instruction(
&self,
instruction: &Instruction,
) -> InstructionResult
pub fn process_instruction( &self, instruction: &Instruction, ) -> InstructionResult
Process an instruction using the minified Solana Virtual Machine (SVM) environment. Simply returns the result.
Sourcepub fn process_instruction_chain(
&self,
instructions: &[Instruction],
) -> InstructionResult
pub fn process_instruction_chain( &self, instructions: &[Instruction], ) -> InstructionResult
Process a chain of instructions using the minified Solana Virtual Machine (SVM) environment.
Sourcepub fn process_and_validate_instruction(
&self,
instruction: &Instruction,
checks: &[Check<'_>],
) -> InstructionResult
pub fn process_and_validate_instruction( &self, instruction: &Instruction, checks: &[Check<'_>], ) -> InstructionResult
Process an instruction using the minified Solana Virtual Machine (SVM) environment, then perform checks on the result.
Sourcepub fn process_and_validate_instruction_chain(
&self,
instructions: &[(&Instruction, &[Check<'_>])],
) -> InstructionResult
pub fn process_and_validate_instruction_chain( &self, instructions: &[(&Instruction, &[Check<'_>])], ) -> InstructionResult
Process a chain of instructions using the minified Solana Virtual Machine (SVM) environment, then perform checks on the result.
Auto Trait Implementations§
impl<AS> Freeze for MolluskContext<AS>
impl<AS> !RefUnwindSafe for MolluskContext<AS>
impl<AS> !Send for MolluskContext<AS>
impl<AS> !Sync for MolluskContext<AS>
impl<AS> Unpin for MolluskContext<AS>
impl<AS> !UnwindSafe for MolluskContext<AS>
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