Struct language_e2e_tests::executor::FakeExecutor
source · pub struct FakeExecutor { /* private fields */ }
Expand description
Provides an environment to run a VM instance.
This struct is a mock in-memory implementation of the Diem executor.
Implementations§
source§impl FakeExecutor
impl FakeExecutor
sourcepub fn from_genesis(write_set: &WriteSet) -> Self
pub fn from_genesis(write_set: &WriteSet) -> Self
Creates an executor from a genesis WriteSet
.
sourcepub fn from_saved_genesis(saved_genesis_blob: &[u8]) -> Self
pub fn from_saved_genesis(saved_genesis_blob: &[u8]) -> Self
Create an executor from a saved genesis blob
sourcepub fn from_genesis_file() -> Self
pub fn from_genesis_file() -> Self
Creates an executor from the genesis file GENESIS_FILE_LOCATION
sourcepub fn from_fresh_genesis() -> Self
pub fn from_fresh_genesis() -> Self
Creates an executor using the standard genesis.
pub fn allowlist_genesis() -> Self
sourcepub fn from_genesis_with_options(publishing_options: VMPublishingOption) -> Self
pub fn from_genesis_with_options(publishing_options: VMPublishingOption) -> Self
Creates an executor from the genesis file GENESIS_FILE_LOCATION with script/module
publishing options given by publishing_options
. These can only be either Open
or
CustomScript
.
sourcepub fn no_genesis() -> Self
pub fn no_genesis() -> Self
Creates an executor in which no genesis state has been applied yet.
pub fn set_golden_file(&mut self, test_name: &str)
sourcepub fn stdlib_only_genesis() -> Self
pub fn stdlib_only_genesis() -> Self
Creates an executor with only the standard library Move modules published and not other initialization done.
sourcepub fn custom_genesis(
genesis_modules: &[Vec<u8>],
validator_accounts: Option<usize>,
publishing_options: VMPublishingOption
) -> Self
pub fn custom_genesis( genesis_modules: &[Vec<u8>], validator_accounts: Option<usize>, publishing_options: VMPublishingOption ) -> Self
Creates fresh genesis from the stdlib modules passed in.
sourcepub fn create_raw_account(&mut self) -> Account
pub fn create_raw_account(&mut self) -> Account
Create one instance of AccountData
without saving it to data store.
sourcepub fn create_raw_account_data(
&mut self,
balance: u64,
seq_num: u64
) -> AccountData
pub fn create_raw_account_data( &mut self, balance: u64, seq_num: u64 ) -> AccountData
Create one instance of AccountData
without saving it to data store.
sourcepub fn create_xdx_raw_account_data(
&mut self,
balance: u64,
seq_num: u64
) -> AccountData
pub fn create_xdx_raw_account_data( &mut self, balance: u64, seq_num: u64 ) -> AccountData
Create one instance of AccountData
with XDX balance without saving it to data store.
sourcepub fn create_accounts(
&mut self,
size: usize,
balance: u64,
seq_num: u64
) -> Vec<Account> ⓘ
pub fn create_accounts( &mut self, size: usize, balance: u64, seq_num: u64 ) -> Vec<Account> ⓘ
Creates a number of Account
instances all with the same balance and sequence number,
and publishes them to this executor’s data store.
sourcepub fn apply_write_set(&mut self, write_set: &WriteSet)
pub fn apply_write_set(&mut self, write_set: &WriteSet)
Applies a WriteSet
to this executor’s data store.
sourcepub fn add_account_data(&mut self, account_data: &AccountData)
pub fn add_account_data(&mut self, account_data: &AccountData)
Adds an account to this executor’s data store.
sourcepub fn add_module(&mut self, module_id: &ModuleId, module_blob: Vec<u8>)
pub fn add_module(&mut self, module_id: &ModuleId, module_blob: Vec<u8>)
Adds a module to this executor’s data store.
Does not do any sort of verification on the module.
sourcepub fn read_account_resource(&self, account: &Account) -> Option<AccountResource>
pub fn read_account_resource(&self, account: &Account) -> Option<AccountResource>
Reads the resource [Value
] for an account from this executor’s data store.
sourcepub fn read_account_resource_at_address(
&self,
addr: &AccountAddress
) -> Option<AccountResource>
pub fn read_account_resource_at_address( &self, addr: &AccountAddress ) -> Option<AccountResource>
Reads the resource [Value
] for an account under the given address from
this executor’s data store.
sourcepub fn read_balance_resource(
&self,
account: &Account,
balance_currency_code: Identifier
) -> Option<BalanceResource>
pub fn read_balance_resource( &self, account: &Account, balance_currency_code: Identifier ) -> Option<BalanceResource>
Reads the balance resource value for an account from this executor’s data store with the given balance currency_code.
sourcepub fn read_balance_resource_at_address(
&self,
addr: &AccountAddress,
balance_currency_code: Identifier
) -> Option<BalanceResource>
pub fn read_balance_resource_at_address( &self, addr: &AccountAddress, balance_currency_code: Identifier ) -> Option<BalanceResource>
Reads the balance resource value for an account under the given address from this executor’s data store with the given balance currency_code.
sourcepub fn execute_block(
&self,
txn_block: Vec<SignedTransaction>
) -> Result<Vec<TransactionOutput>, VMStatus>
pub fn execute_block( &self, txn_block: Vec<SignedTransaction> ) -> Result<Vec<TransactionOutput>, VMStatus>
Executes the given block of transactions.
Typical tests will call this method and check that the output matches what was expected. However, this doesn’t apply the results of successful transactions to the data store.
sourcepub fn execute_block_and_keep_vm_status(
&self,
txn_block: Vec<SignedTransaction>
) -> Result<Vec<(VMStatus, TransactionOutput)>, VMStatus>
pub fn execute_block_and_keep_vm_status( &self, txn_block: Vec<SignedTransaction> ) -> Result<Vec<(VMStatus, TransactionOutput)>, VMStatus>
Alternate form of ‘execute_block’ that keeps the vm_status before it goes into the
TransactionOutput
sourcepub fn execute_and_apply(
&mut self,
transaction: SignedTransaction
) -> TransactionOutput
pub fn execute_and_apply( &mut self, transaction: SignedTransaction ) -> TransactionOutput
Executes the transaction as a singleton block and applies the resulting write set to the data store. Panics if execution fails
pub fn execute_transaction_block( &self, txn_block: Vec<Transaction> ) -> Result<Vec<TransactionOutput>, VMStatus>
pub fn execute_transaction(&self, txn: SignedTransaction) -> TransactionOutput
sourcepub fn read_from_access_path(&self, path: &AccessPath) -> Option<Vec<u8>>
pub fn read_from_access_path(&self, path: &AccessPath) -> Option<Vec<u8>>
Get the blob for the associated AccessPath
sourcepub fn verify_transaction(&self, txn: SignedTransaction) -> VMValidatorResult
pub fn verify_transaction(&self, txn: SignedTransaction) -> VMValidatorResult
Verifies the given transaction by running it through the VM verifier.
pub fn get_state_view(&self) -> &FakeDataStore
pub fn new_block(&mut self)
pub fn new_block_with_timestamp(&mut self, time_stamp: u64)
pub fn set_block_time(&mut self, new_block_time: u64)
pub fn get_block_time(&mut self) -> u64
pub fn exec( &mut self, module_name: &str, function_name: &str, type_params: Vec<TypeTag>, args: Vec<Vec<u8>> )
pub fn try_exec( &mut self, module_name: &str, function_name: &str, type_params: Vec<TypeTag>, args: Vec<Vec<u8>> ) -> Result<WriteSet, VMStatus>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FakeExecutor
impl !Send for FakeExecutor
impl !Sync for FakeExecutor
impl Unpin for FakeExecutor
impl !UnwindSafe for FakeExecutor
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Pipe for T
impl<T> Pipe for T
§impl<T> PipeAsRef for T
impl<T> PipeAsRef for T
§impl<T> PipeBorrow for T
impl<T> PipeBorrow for T
§impl<T> PipeDeref for T
impl<T> PipeDeref for T
§impl<T> PipeRef for T
impl<T> PipeRef for T
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
§fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§impl<T> Tap for T
impl<T> Tap for T
§fn tap<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
fn tap<F, R>(self, func: F) -> Selfwhere F: FnOnce(&Self) -> R,
§fn tap_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Selfwhere F: FnOnce(&Self) -> R,
tap
in debug builds, and does nothing in release builds.§fn tap_mut<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Selfwhere F: FnOnce(&mut Self) -> R,
§fn tap_mut_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Selfwhere F: FnOnce(&mut Self) -> R,
tap_mut
in debug builds, and does nothing in release builds.§impl<T, U> TapAsRef<U> for Twhere
U: ?Sized,
impl<T, U> TapAsRef<U> for Twhere U: ?Sized,
§fn tap_ref<F, R>(self, func: F) -> Selfwhere
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref<F, R>(self, func: F) -> Selfwhere Self: AsRef<T>, F: FnOnce(&T) -> R,
§fn tap_ref_dbg<F, R>(self, func: F) -> Selfwhere
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref_dbg<F, R>(self, func: F) -> Selfwhere Self: AsRef<T>, F: FnOnce(&T) -> R,
tap_ref
in debug builds, and does nothing in release builds.§fn tap_ref_mut<F, R>(self, func: F) -> Selfwhere
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut<F, R>(self, func: F) -> Selfwhere Self: AsMut<T>, F: FnOnce(&mut T) -> R,
§fn tap_ref_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: AsMut<T>, F: FnOnce(&mut T) -> R,
tap_ref_mut
in debug builds, and does nothing in release builds.§impl<T, U> TapBorrow<U> for Twhere
U: ?Sized,
impl<T, U> TapBorrow<U> for Twhere U: ?Sized,
§fn tap_borrow<F, R>(self, func: F) -> Selfwhere
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow<F, R>(self, func: F) -> Selfwhere Self: Borrow<T>, F: FnOnce(&T) -> R,
§fn tap_borrow_dbg<F, R>(self, func: F) -> Selfwhere
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow_dbg<F, R>(self, func: F) -> Selfwhere Self: Borrow<T>, F: FnOnce(&T) -> R,
tap_borrow
in debug builds, and does nothing in release builds.§fn tap_borrow_mut<F, R>(self, func: F) -> Selfwhere
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Selfwhere Self: BorrowMut<T>, F: FnOnce(&mut T) -> R,
§fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: BorrowMut<T>, F: FnOnce(&mut T) -> R,
tap_borrow_mut
in debug builds, and does nothing in release
builds.§impl<T> TapDeref for T
impl<T> TapDeref for T
§fn tap_deref<F, R>(self, func: F) -> Selfwhere
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref<F, R>(self, func: F) -> Selfwhere Self: Deref, F: FnOnce(&Self::Target) -> R,
self
for inspection.§fn tap_deref_dbg<F, R>(self, func: F) -> Selfwhere
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Selfwhere Self: Deref, F: FnOnce(&Self::Target) -> R,
tap_deref
in debug builds, and does nothing in release builds.§fn tap_deref_mut<F, R>(self, func: F) -> Selfwhere
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Selfwhere Self: DerefMut, F: FnOnce(&mut Self::Target) -> R,
self
for modification.§fn tap_deref_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: DerefMut, F: FnOnce(&mut Self::Target) -> R,
tap_deref_mut
in debug builds, and does nothing in release
builds.