pub struct FrameResult { /* private fields */ }Expand description
Result of executing a single invocation frame. Wraps InvocationFrameOutput + optional trace + per-frame events.
Implementations§
Source§impl FrameResult
impl FrameResult
Sourcepub fn new(
output: InvocationFrameOutput,
trace: Option<InvocationFrameTrace>,
events: Vec<TxEmittedEvent>,
) -> FrameResult
pub fn new( output: InvocationFrameOutput, trace: Option<InvocationFrameTrace>, events: Vec<TxEmittedEvent>, ) -> FrameResult
Wrap a frame’s output, optional trace, and emitted events.
Sourcepub fn rv32_stack_usage(&self) -> Option<Rv32StackUsage>
pub fn rv32_stack_usage(&self) -> Option<Rv32StackUsage>
The stack record of the most recent rv32 call made under this frame:
the last of rv32_stack_usage_records.
For a mock frame whose body calls an rv32 contract through its
client, that is the last such call.
None if no rv32 invocation ran under this frame, or if the test
FFI library was built without the diagnostic (the prebuilt one has
it). See Rv32StackUsage for the fields.
Sourcepub fn rv32_stack_usage_records(&self) -> &[Rv32StackUsage]
pub fn rv32_stack_usage_records(&self) -> &[Rv32StackUsage]
The stack records of the rv32 invocations that ran under this frame, in the order they finished: a callee’s before its caller’s.
“Under this frame” is what its body ran while the frame was open:
the rv32 contracts it called directly, and those called by a mock
contract it invoked. It is never a call that finished before this
frame opened, whichever frame of the transaction made it, and never
a call made under a child frame opened with child_call: those are
the child’s own result’s. Pick a call by its contract_address when
the body made several.
Sourcepub fn fault_panic(&self) -> Option<&PanicRecord>
pub fn fault_panic(&self) -> Option<&PanicRecord>
The panic that faulted this frame’s own body.
None whenever there is nothing to report rather than nothing to
find, and the two are worth telling apart:
- the frame did not fault, or faulted with neither a string payload nor a hook record;
- the frame faulted because a
raw_Invokeed callee did. That callee ran in a frame the runtime owns, caught its own panic ininvoke_wrapper, and reported an error code — nothing reaches this side. It is still printed to stderr by the panic hook.
So a record here is always this frame’s body panicking, never a nested frame’s.
Sourcepub fn fault_message(&self) -> Option<&str>
pub fn fault_message(&self) -> Option<&str>
Just the message from fault_panic, for callers
that do not want the location.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
True if the frame returned successfully.
Sourcepub fn is_fault(&self) -> bool
pub fn is_fault(&self) -> bool
True if the frame faulted (panicked or trapped, with no abort data).
Sourcepub fn assert_success(&self)
pub fn assert_success(&self)
Assert the frame returned successfully. Frame-only check; use
TransactResult::assert_success when the commit outcome matters.
Sourcepub fn assert_abort(&self)
pub fn assert_abort(&self)
Assert the frame aborted (threw a contract exception). Frame-only check.
Sourcepub fn assert_fault(&self)
pub fn assert_fault(&self)
Assert the frame faulted (panicked or trapped). Frame-only check.
Sourcepub fn return_buffer(&self) -> &[u8] ⓘ
pub fn return_buffer(&self) -> &[u8] ⓘ
Returns the return buffer. Panics if the frame did not succeed.
Sourcepub fn abort_buffer(&self) -> &[u8] ⓘ
pub fn abort_buffer(&self) -> &[u8] ⓘ
Returns the abort buffer. Panics if the frame did not abort.
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 frame succeeded and decode the return buffer as a typed value.
Sourcepub fn assert_return_as<R>(&self) -> Rwhere
R: ReadXDROwned,
pub fn assert_return_as<R>(&self) -> Rwhere
R: ReadXDROwned,
Assert the frame succeeded and decode the return buffer, returning
the decoded value. The returning twin of 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 frame aborted with a thrown E and return it. Panics
unless the frame aborted with a [CXS(E::SELECTOR)][payload] buffer
whose payload decodes as E.
Sourcepub fn output(&self) -> &InvocationFrameOutput
pub fn output(&self) -> &InvocationFrameOutput
The frame’s raw InvocationFrameOutput.
Sourcepub fn trace(&self) -> Option<&InvocationFrameTrace>
pub fn trace(&self) -> Option<&InvocationFrameTrace>
The frame’s execution trace, when tracing was enabled.
Sourcepub fn events(&self) -> &[TxEmittedEvent]
pub fn events(&self) -> &[TxEmittedEvent]
The events this frame emitted (empty if the frame reverted).
Sourcepub fn assert_event_count(&self, expected: usize)
pub fn assert_event_count(&self, expected: usize)
Assert exactly expected events were emitted by this frame.
Sourcepub fn assert_no_events(&self)
pub fn assert_no_events(&self)
Assert this 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.
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,
Collect events from address that decode as E via
TypedEvent::try_new: well-formed, topic 0 matching E’s declared
discriminant (when Event::signature returns one), topic count
matching Event::num_topics, and payload decoding as E::Payload.
Foreign and malformed events are skipped, never panicked on.
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.
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 the check closure. Provides access to both topics and the decoded payload.
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,
Assert that exactly one event from address decodes as E (per
TypedEvent::try_new — see filter_events
for the matching rules) and satisfies predicate. Panics if zero or
more than one event matches.
Trait Implementations§
Source§impl Clone for FrameResult
impl Clone for FrameResult
Source§fn clone(&self) -> FrameResult
fn clone(&self) -> FrameResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more