Skip to main content

FrameResult

Struct FrameResult 

Source
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

Source

pub fn new( output: InvocationFrameOutput, trace: Option<InvocationFrameTrace>, events: Vec<TxEmittedEvent>, ) -> Self

Wrap a frame’s output, optional trace, and emitted events.

Source

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.

Source

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.

Source

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 in invoke_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.

Source

pub fn fault_message(&self) -> Option<&str>

Just the message from fault_panic, for callers that do not want the location.

Source

pub fn is_success(&self) -> bool

True if the frame returned successfully.

Source

pub fn is_abort(&self) -> bool

True if the frame aborted (threw a contract exception).

Source

pub fn is_fault(&self) -> bool

True if the frame faulted (panicked or trapped, with no abort data).

Source

pub fn assert_success(&self)

Assert the frame returned successfully. Frame-only check; use TransactResult::assert_success when the commit outcome matters.

Source

pub fn assert_abort(&self)

Assert the frame aborted (threw a contract exception). Frame-only check.

Source

pub fn assert_fault(&self)

Assert the frame faulted (panicked or trapped). Frame-only check.

Source

pub fn return_buffer(&self) -> &[u8] ⓘ

Returns the return buffer. Panics if the frame did not succeed.

Source

pub fn abort_buffer(&self) -> &[u8] ⓘ

Returns the abort buffer. Panics if the frame did not abort.

Source

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.

Source

pub fn assert_return_as<R>(&self) -> R
where R: ReadXDROwned,

Assert the frame succeeded and decode the return buffer, returning the decoded value. The returning twin of assert_return_with.

Source

pub fn assert_abort_as<E>(&self) -> E
where 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.

Source

pub fn output(&self) -> &InvocationFrameOutput

The frame’s raw InvocationFrameOutput.

Source

pub fn trace(&self) -> Option<&InvocationFrameTrace>

The frame’s execution trace, when tracing was enabled.

Source

pub fn events(&self) -> &[TxEmittedEvent]

The events this frame emitted (empty if the frame reverted).

Source

pub fn assert_event_count(&self, expected: usize)

Assert exactly expected events were emitted by this frame.

Source

pub fn assert_no_events(&self)

Assert this frame emitted no events.

Source

pub fn events_from(&self, address: &ContractAddress) -> Vec<&TxEmittedEvent>

All raw events emitted at the given address.

Source

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.

Source

pub fn assert_raw_event( &self, index: usize, check: impl FnOnce(&EmittedEvent<'_>), )

Inspect a raw emitted event by index.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FrameResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StaticIfNoAlloc for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.