pub struct MockExecutor<A>where
    A: Deref + Send + Sync,
    Address: for<'a> From<&'a <A as Deref>::Target>,{ /* private fields */ }
Expand description

A structure to execute smart contract queries, transactions, and deployments in a mocked blockchain environment.

This executor utilizes the scenario engine from the MultiversX Rust Testing Framework for executing smart contract interactions.

Implementations§

source§

impl<A> MockExecutor<A>where A: Deref + Send + Sync, Address: for<'a> From<&'a <A as Deref>::Target>,

source

pub fn new( world: Arc<Mutex<ScenarioWorld>>, opt_caller: Option<A> ) -> MockExecutor<A>

Constructs a new MockExecutor with the specified mocked world and an optional caller address.

Parameters
  • world: The mocked world where the smart contract interactions are executed.
  • opt_caller: Optional caller address.
Returns

A new instance of MockExecutor.

Trait Implementations§

source§

impl<A> Clone for MockExecutor<A>where A: Clone + Deref + Send + Sync, Address: for<'a> From<&'a <A as Deref>::Target>,

source§

fn clone(&self) -> MockExecutor<A>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<A> DeployExecutor for MockExecutor<A>where A: Deref + Send + Sync, Address: for<'a> From<&'a <A as Deref>::Target>,

Mock implementation of the DeployExecutor trait for testing and development purposes. This implementation uses a mock executor to simulate the deployment of smart contracts on the blockchain without actually interacting with a real blockchain network.

The MockExecutor struct encapsulates the state and behavior necessary for simulating blockchain interactions.

Type Parameters

  • A: A type implementing Deref, Send, and Sync. This type is used to derive an Address type instance representing a blockchain address.
source§

fn sc_deploy<'life0, 'life1, 'async_trait, OriginalResult>( &'life0 mut self, sc_deploy_step: &'life1 mut TypedScDeploy<OriginalResult> ) -> Pin<Box<dyn Future<Output = Result<(), ExecutorError>> + Send + 'async_trait>>where 'life0: 'async_trait, 'life1: 'async_trait, OriginalResult: TopEncodeMulti + Send + Sync + 'async_trait, MockExecutor<A>: 'async_trait,

Asynchronously deploys a smart contract to the mock blockchain environment.

Type Parameters
  • OriginalResult: Represents the result type expected from the smart contract deployment. This type must implement TopEncodeMulti, Send, and Sync.
  • S: Represents the type encapsulating the smart contract deployment step. This type must implement AsMut<TypedScDeploy<OriginalResult>> and Send.
Parameters
  • sc_deploy_step: A mutable reference to the smart contract deployment step to be executed.
Returns

A Result with an empty Ok(()) value indicating success, or an Err(ExecutorError) indicating failure, specifically a MockDeployError::WalletAddressNotPresent error if the wallet address is not present.

source§

fn should_skip_deserialization<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where 'life0: 'async_trait, MockExecutor<A>: 'async_trait,

Specifies whether deserialization should be skipped during the deployment execution. In this implementation, deserialization is not skipped.

Returns

A bool value of false, indicating that deserialization should not be skipped.

source§

impl<A> QueryExecutor for MockExecutor<A>where A: Clone + Deref + Send + Sync, Address: for<'a> From<&'a <A as Deref>::Target>,

The MockExecutor implementation for the QueryExecutor trait, used to simulate smart contract queries in a mock environment. This struct is typically utilized in testing and development scenarios where interaction with a real blockchain is undesirable or unnecessary.

Type Parameters

  • A: A type that implements Clone, Deref, Send, and Sync traits. This type is used to derive an Address instance representing a blockchain address.
source§

fn execute<'life0, 'life1, 'async_trait, OutputManaged>( &'life0 self, request: &'life1 ScCallStep ) -> Pin<Box<dyn Future<Output = Result<<OutputManaged as NativeConvertible>::Native, ExecutorError>> + Send + 'async_trait>>where 'life0: 'async_trait, 'life1: 'async_trait, OutputManaged: TopDecodeMulti + NativeConvertible + Send + Sync + 'async_trait, MockExecutor<A>: 'async_trait,

Executes a simulated smart contract query in the mock environment.

Type Parameters
  • OutputManaged: The type representing the expected output of the smart contract query. It should implement TopDecodeMulti, NativeConvertible, Send, and Sync.
Parameters
  • request: A reference to the ScCallStep detailing the smart contract query to be executed.
Returns
  • Result<OutputManaged::Native, ExecutorError>: On successful execution, returns a Result containing the native converted query output. On failure, returns a Result containing an ExecutorError.
source§

impl<A> TransactionExecutor for MockExecutor<A>where A: Deref + Send + Sync, Address: for<'a> From<&'a <A as Deref>::Target>,

source§

fn sc_call<'life0, 'life1, 'async_trait, OriginalResult>( &'life0 mut self, sc_call_step: &'life1 mut TypedScCall<OriginalResult> ) -> Pin<Box<dyn Future<Output = Result<(), ExecutorError>> + Send + 'async_trait>>where 'life0: 'async_trait, 'life1: 'async_trait, OriginalResult: 'async_trait + Send, MockExecutor<A>: 'async_trait,

Executes a smart contract call within a mocked environment.

This method extracts or determines the caller’s address, performs a smart contract call, and updates the world state accordingly, all within a controlled, mocked environment.

Parameters
  • sc_call_step: A mutable reference to a TypedScCall object representing the smart contract call step.
Type Parameters
  • OriginalResult: The type of the result expected from the smart contract call. Must implement the Send trait.
Returns
  • A Result object with an empty Ok(()) value if the call is successful, or an Err(ExecutorError) if the call fails for any reason.
source§

fn should_skip_deserialization<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where 'life0: 'async_trait, MockExecutor<A>: 'async_trait,

Specifies whether deserialization should be skipped during the smart contract call execution.

In the context of the mocked environment, deserialization is not skipped, hence this method returns false.

Returns
  • A boolean value false, indicating that deserialization should not be skipped.

Auto Trait Implementations§

§

impl<A> !CodecFromSelf for MockExecutor<A>

§

impl<A> !RefUnwindSafe for MockExecutor<A>

§

impl<A> Send for MockExecutor<A>

§

impl<A> Sync for MockExecutor<A>

§

impl<A> Unpin for MockExecutor<A>where A: Unpin,

§

impl<A> !UnwindSafe for MockExecutor<A>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T> InterpretableFrom<&T> for Twhere T: Clone,

§

fn interpret_from(from: &T, _context: &InterpreterContext) -> T

§

impl<T> InterpretableFrom<T> for T

§

fn interpret_from(from: T, _context: &InterpreterContext) -> T

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> ReconstructableFrom<&T> for Twhere T: Clone,

§

fn reconstruct_from(from: &T, _builder: &ReconstructorContext) -> T

§

impl<T> ReconstructableFrom<T> for T

§

fn reconstruct_from(from: T, _builder: &ReconstructorContext) -> T

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more