pub struct TXErrorAssertions { /* private fields */ }Expand description
Provides assertion methods for failed transactions.
This struct wraps a transaction error and provides helper methods for asserting specific error conditions in tests.
Implementations§
Source§impl TXErrorAssertions
impl TXErrorAssertions
Sourcepub fn with_anchor_error(&self, error_name: &str) -> Result<()>
pub fn with_anchor_error(&self, error_name: &str) -> Result<()>
Asserts that the transaction failed with a specific Anchor error.
This uses string matching to find the error in the transaction logs, looking for the last program log containing the string “AnchorError” and matching the error name.
Sourcepub fn with_error(&self, error_name: &str) -> Result<()>
pub fn with_error(&self, error_name: &str) -> Result<()>
Asserts that the transaction failed with a specific error message.
This method checks the transaction logs for an error message containing the specified error name and error code.
Sourcepub fn with_custom_error(&self, error_code: u32) -> Result<()>
pub fn with_custom_error(&self, error_code: u32) -> Result<()>
Asserts that the transaction failed with a specific custom error code.
This is useful for checking SPL Token errors and other program-specific error codes.
Sourcepub fn with_program_error<T: Into<ProgramError>>(&self, err: T) -> Result<()>
pub fn with_program_error<T: Into<ProgramError>>(&self, err: T) -> Result<()>
Asserts that the transaction failed with a specific program error.
Auto Trait Implementations§
impl Freeze for TXErrorAssertions
impl RefUnwindSafe for TXErrorAssertions
impl Send for TXErrorAssertions
impl Sync for TXErrorAssertions
impl Unpin for TXErrorAssertions
impl UnwindSafe for TXErrorAssertions
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