pub struct TransactResult { /* private fields */ }Expand description
Result of a full transaction: root frame result + commit outcome. Events are accessed via the root frame’s per-frame events.
Implementations§
Source§impl TransactResult
impl TransactResult
Sourcepub fn new(frame: FrameResult, exec_result: ExecResult) -> Self
pub fn new(frame: FrameResult, exec_result: ExecResult) -> Self
Combine a root-frame result with the transaction’s commit outcome.
Sourcepub fn fault_panic(&self) -> Option<&PanicRecord>
pub fn fault_panic(&self) -> Option<&PanicRecord>
The panic that faulted the root frame’s body, if it faulted with one.
See FrameResult::fault_panic for what None covers — notably, a
fault caused by a called contract rather than by this frame’s own body.
Sourcepub fn fault_message(&self) -> Option<&str>
pub fn fault_message(&self) -> Option<&str>
Just the message from fault_panic.
Sourcepub fn rv32_stack_usage(&self) -> Option<Rv32StackUsage>
pub fn rv32_stack_usage(&self) -> Option<Rv32StackUsage>
The root frame’s FrameResult::rv32_stack_usage: the stack record
of the most recent rv32 call made under the root frame.
Sourcepub fn rv32_stack_usage_records(&self) -> &[Rv32StackUsage]
pub fn rv32_stack_usage_records(&self) -> &[Rv32StackUsage]
The root frame’s FrameResult::rv32_stack_usage_records: the
rv32 calls made under it, in the order they finished.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
True if the root frame returned successfully AND the commit was OK.
Sourcepub fn assert_success(&self)
pub fn assert_success(&self)
Asserts the root frame returned successfully AND the transaction committed OK.
Sourcepub fn assert_abort(&self)
pub fn assert_abort(&self)
Assert the root frame aborted. Frame-only check; the commit outcome is not consulted.
Sourcepub fn assert_fault(&self)
pub fn assert_fault(&self)
Assert the root frame faulted. Frame-only check.
Sourcepub fn assert_return_with<R>(&self, check: impl FnOnce(&R))where
R: ReadXDROwned,
pub fn assert_return_with<R>(&self, check: impl FnOnce(&R))where
R: ReadXDROwned,
Assert the root frame returned successfully and decode its return buffer.
This checks only the frame outcome (contract execution), not the
database commit. Use assert_success() when you need to verify both
frame return and commit. This separation lets you inspect the return
value even when the commit is expected to fail or hasn’t happened yet.
Sourcepub fn assert_return_as<R>(&self) -> Rwhere
R: ReadXDROwned,
pub fn assert_return_as<R>(&self) -> Rwhere
R: ReadXDROwned,
Assert the root frame returned successfully and decode its return
buffer, returning the decoded value. Frame-only check, like
assert_return_with.
Sourcepub fn assert_abort_as<E>(&self) -> Ewhere
E: Exn + ReadXDROwned,
pub fn assert_abort_as<E>(&self) -> Ewhere
E: Exn + ReadXDROwned,
Assert the root frame aborted with a thrown E and return it; see
FrameResult::assert_abort_as. Frame-only check (commit status not
checked).
Sourcepub fn assert_commit_failed(&self)
pub fn assert_commit_failed(&self)
Asserts the root frame succeeded but the DB commit step failed.
Sourcepub fn assert_commit_failed_nondeterministically(&self)
pub fn assert_commit_failed_nondeterministically(&self)
Assert the root frame succeeded but the commit failed with
ExecResultTxNonDeterministicError (a storage conflict).
Sourcepub fn exec_result(&self) -> &ExecResult
pub fn exec_result(&self) -> &ExecResult
The transaction’s commit outcome.
Sourcepub fn frame(&self) -> &FrameResult
pub fn frame(&self) -> &FrameResult
The root frame’s result.
Sourcepub fn events(&self) -> &[TxEmittedEvent]
pub fn events(&self) -> &[TxEmittedEvent]
The events the root frame emitted; see FrameResult::events.
Sourcepub fn assert_event_count(&self, expected: usize)
pub fn assert_event_count(&self, expected: usize)
Assert exactly expected events were emitted by the root frame.
Sourcepub fn assert_no_events(&self)
pub fn assert_no_events(&self)
Assert the root frame emitted no events.
Sourcepub fn events_from(&self, address: &ContractAddress) -> Vec<&TxEmittedEvent>
pub fn events_from(&self, address: &ContractAddress) -> Vec<&TxEmittedEvent>
All raw events emitted at the given address by the root frame.
Sourcepub fn filter_events<E>(
&self,
address: &ContractAddress,
) -> Vec<TypedEvent<'_, E>>where
E: Event,
pub fn filter_events<E>(
&self,
address: &ContractAddress,
) -> Vec<TypedEvent<'_, E>>where
E: Event,
See FrameResult::filter_events for the matching rules.
Sourcepub fn assert_raw_event(
&self,
index: usize,
check: impl FnOnce(&EmittedEvent<'_>),
)
pub fn assert_raw_event( &self, index: usize, check: impl FnOnce(&EmittedEvent<'_>), )
Inspect a raw emitted event by index; see
FrameResult::assert_raw_event.
Sourcepub fn assert_event<E>(
&self,
index: usize,
check: impl FnOnce(&TypedEvent<'_, E>),
)where
E: Event,
pub fn assert_event<E>(
&self,
index: usize,
check: impl FnOnce(&TypedEvent<'_, E>),
)where
E: Event,
Decode an event as a typed event and pass it to check; see
FrameResult::assert_event.
Sourcepub fn assert_emitted<E>(
&self,
address: &ContractAddress,
predicate: impl Fn(&TypedEvent<'_, E>) -> bool,
)where
E: Event,
pub fn assert_emitted<E>(
&self,
address: &ContractAddress,
predicate: impl Fn(&TypedEvent<'_, E>) -> bool,
)where
E: Event,
See FrameResult::assert_emitted for the matching rules.