pub struct MockInvocationFrame { /* private fields */ }Expand description
One open invocation frame in a mocked transaction. Drive it with
execute, then read the outcome with
result. Prefer the fluent
crate::frame_builder::FrameBuilder API unless a test needs this
level of control.
Implementations§
Source§impl MockInvocationFrame
impl MockInvocationFrame
Sourcepub fn open_child_frame(
&mut self,
contract_address: ContractAddress,
) -> MockInvocationFrameConfig<'_>
pub fn open_child_frame( &mut self, contract_address: ContractAddress, ) -> MockInvocationFrameConfig<'_>
Configure a child frame of this one, invoking contract_address.
The address must differ from every frame already open on the stack: the
test FFI admits mock frames under the same reentrance rule production
applies to Invoke, so an address that already has an active frame is
refused and build() panics unrecoverably. Frames that
have already finished, and frames in other transactions, do not count —
only the ones open at the same time.
Sourcepub fn execute(
&mut self,
lambda: impl FnOnce(&mut Self) -> FrameAction + UnwindSafe,
) -> &mut Self
pub fn execute( &mut self, lambda: impl FnOnce(&mut Self) -> FrameAction + UnwindSafe, ) -> &mut Self
Run lambda as this frame’s contract code, mapping panics out of it
to frame outcomes. Unrecoverable InvokeError payloads (harness
misuse, FFI refusals) propagate instead. The returned FrameAction
closes the frame or leaves it open for another execute.
Sourcepub fn result(&mut self) -> FrameResult
pub fn result(&mut self) -> FrameResult
The closed frame’s FrameResult. Panics if the frame is still
open.