pub struct TransactionResult { /* private fields */ }Expand description
Wrapper around LiteSVM’s TransactionMetadata with helper methods for testing
This struct provides convenient methods for analyzing transaction results, including log inspection, compute unit tracking, and success assertions.
§Example
ⓘ
let result = svm.send_instruction(ix, &[&signer])?;
result.assert_success();
assert!(result.has_log("Transfer complete"));
println!("Used {} compute units", result.compute_units());Implementations§
Source§impl TransactionResult
impl TransactionResult
Sourcepub fn new(
result: TransactionMetadata,
instruction_name: Option<String>,
) -> Self
pub fn new( result: TransactionMetadata, instruction_name: Option<String>, ) -> Self
Create a new TransactionResult wrapper for successful transaction
§Arguments
result- The transaction metadata from LiteSVMinstruction_name- Optional name of the instruction for debugging
Sourcepub fn new_failed(
error: String,
result: TransactionMetadata,
instruction_name: Option<String>,
) -> Self
pub fn new_failed( error: String, result: TransactionMetadata, instruction_name: Option<String>, ) -> Self
Create a new TransactionResult wrapper for failed transaction
§Arguments
error- The error messageresult- The transaction metadata from LiteSVMinstruction_name- Optional name of the instruction for debugging
Sourcepub fn assert_success(&self) -> &Self
pub fn assert_success(&self) -> &Self
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Sourcepub fn error(&self) -> Option<&String>
pub fn error(&self) -> Option<&String>
Get the error message if the transaction failed
§Returns
The error message if the transaction failed, None otherwise
Sourcepub fn compute_units(&self) -> u64
pub fn compute_units(&self) -> u64
Sourcepub fn print_logs(&self)
pub fn print_logs(&self)
Print the transaction logs
Sourcepub fn inner(&self) -> &TransactionMetadata
pub fn inner(&self) -> &TransactionMetadata
Get the inner TransactionMetadata for direct access
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TransactionResult
impl RefUnwindSafe for TransactionResult
impl Send for TransactionResult
impl Sync for TransactionResult
impl Unpin for TransactionResult
impl UnwindSafe for TransactionResult
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
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