pub struct BlockchainMock {
    pub accounts: HashMap<Address, AccountData>,
    pub builtin_functions: Rc<BuiltinFunctionMap>,
    pub addr_to_pretty_string_map: HashMap<Address, String>,
    pub new_addresses: HashMap<(Address, u64), Address>,
    pub previous_block_info: BlockInfo,
    pub current_block_info: BlockInfo,
    pub contract_map: ContractMap,
    pub current_dir: PathBuf,
    pub scenario_trace: Scenario,
}

Fields§

§accounts: HashMap<Address, AccountData>§builtin_functions: Rc<BuiltinFunctionMap>§addr_to_pretty_string_map: HashMap<Address, String>§new_addresses: HashMap<(Address, u64), Address>§previous_block_info: BlockInfo§current_block_info: BlockInfo§contract_map: ContractMap§current_dir: PathBuf§scenario_trace: Scenario

Implementations§

source§

impl BlockchainMock

source

pub fn perform_check_state( &mut self, check_state_step: CheckStateStep ) -> &mut Self

source

pub fn perform_dump_state(&mut self) -> &mut Self

source§

impl BlockchainMock

source

pub fn perform_sc_call(&mut self, sc_call_step: ScCallStep) -> &mut Self

Adds a SC call step, as specified in the sc_call_step argument, then executes it.

source

pub fn perform_sc_call_get_result<OriginalResult, RequestedResult>( &mut self, typed_sc_call: TypedScCall<OriginalResult> ) -> RequestedResultwhere OriginalResult: TopEncodeMulti, RequestedResult: CodecFrom<OriginalResult>,

Adds a SC call step, executes it and retrieves the transaction result (“out” field).

The transaction is expected to complete successfully.

It takes the contract_call argument separately from the SC call step, so we can benefit from type inference in the result.

source§

impl BlockchainMock

source

pub fn perform_sc_deploy(&mut self, sc_deploy_step: ScDeployStep) -> &mut Self

Adds a SC deploy step, as specified in the sc_deploy_step argument, then executes it.

source

pub fn perform_sc_deploy_get_result<OriginalResult, RequestedResult>( &mut self, typed_sc_deploy: TypedScDeploy<OriginalResult> ) -> (Address, RequestedResult)where OriginalResult: TopEncodeMulti, RequestedResult: CodecFrom<OriginalResult>,

Adds a SC deploy step, executes it and retrieves the transaction result (“out” field).

The transaction is expected to complete successfully.

It takes the contract_call argument separately from the SC call step, so we can benefit from type inference in the result.

source§

impl BlockchainMock

source

pub fn perform_sc_query(&mut self, sc_query_step: ScQueryStep) -> &mut Self

Adds a SC query step, as specified in the sc_query_step argument, then executes it.

source

pub fn perform_sc_query_expect_result<OriginalResult, RequestedResult>( &mut self, typed_sc_query: TypedScQuery<OriginalResult> ) -> RequestedResultwhere OriginalResult: TopEncodeMulti, RequestedResult: CodecFrom<OriginalResult>,

Adds a SC query step, but sets the contract call data and returns the result.

It also sets in the trace the expected result to be the actual returned result.

It is the duty of the test developer to check that the result is actually correct after the call.

source§

impl BlockchainMock

source

pub fn quick_query<CC, RequestedResult>( &mut self, contract_call: CC ) -> RequestedResultwhere CC: ContractCall<DebugApi>, RequestedResult: CodecFrom<CC::OriginalResult>,

Performs a SC query to a contract, leaves no scenario trace behind.

Meant to be used for the test to investigate the state of the contract.

Use mandos_sc_query to embed the SC query in the resulting scenario.

source§

impl BlockchainMock

source

pub fn perform_set_state(&mut self, set_state_step: SetStateStep) -> &mut Self

source§

impl BlockchainMock

source

pub fn perform_transfer(&mut self, transfer_step: TransferStep) -> &mut Self

source

pub fn perform_validator_reward( &mut self, validator_rewards_step: ValidatorRewardStep ) -> &mut Self

source§

impl BlockchainMock

source

pub fn new() -> Self

source§

impl BlockchainMock

source

pub fn account_exists(&self, address: &Address) -> bool

source

pub fn contains_contract(&self, contract_path_expr: &str) -> bool

source

pub fn commit_updates(&mut self, updates: BlockchainUpdate)

source

pub fn increase_account_nonce(&mut self, address: &Address)

source

pub fn subtract_tx_gas( &mut self, address: &Address, gas_limit: u64, gas_price: u64 )

source

pub fn increase_validator_reward(&mut self, address: &Address, amount: &BigUint)

source

pub fn with_borrowed<F, R>(&mut self, f: F) -> Rwhere F: FnOnce(Self) -> (R, Self),

source§

impl BlockchainMock

source

pub fn add_account(&mut self, acct: AccountData)

source

pub fn add_addr_scenario_string(&mut self, address: Address)

source

pub fn validate_and_add_account(&mut self, acct: AccountData)

source

pub fn update_accounts(&mut self, accounts: HashMap<Address, AccountData>)

source

pub fn print_accounts(&self)

source

pub fn put_new_address( &mut self, creator_address: Address, creator_nonce: u64, new_address: Address )

source

pub fn get_new_address( &self, creator_address: Address, creator_nonce: u64 ) -> Option<Address>

source

pub fn validate_account(&self, account: &AccountData)

source

pub fn check_account_has_code(&self, account: &AccountData) -> bool

source§

impl BlockchainMock

source

pub fn interpreter_context(&self) -> InterpreterContext

source

pub fn register_contract_container( &mut self, expression: &str, contract_container: ContractContainer )

source

pub fn register_contract<B: CallableContractBuilder>( &mut self, expression: &str, contract_builder: B )

Links a contract path in a test to a contract implementation.

source

pub fn register_partial_contract<Abi, B>( &mut self, expression: &str, contract_builder: B, sub_contract_name: &str )where Abi: ContractAbiProvider, B: CallableContractBuilder,

Links a contract path in a test to a multi-contract output.

This simulates the effects of building such a contract with only part of the endpoints.

source§

impl BlockchainMock

source

pub fn write_scenario_trace<P: AsRef<Path>>(&mut self, file_path: P)

source§

impl BlockchainMock

source

pub fn create_tx_info(&self, contract_address: &Address) -> BlockchainTxInfo

Trait Implementations§

source§

impl Debug for BlockchainMock

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for BlockchainMock

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl StepHandler for BlockchainMock

source§

fn sc_call_step(&mut self, step: ScCallStep) -> &mut Self

Adds a SC call step, as specified in the sc_call_step argument, then executes it.

source§

fn sc_query_step(&mut self, step: ScQueryStep) -> &mut Self

Adds a SC query step, as specified in the sc_query_step argument, then executes it.

source§

fn sc_deploy_step(&mut self, step: ScDeployStep) -> &mut Self

Adds a SC deploy step, as specified in the sc_deploy_step argument, then executes it.

source§

fn set_state_step(&mut self, step: SetStateStep) -> &mut Self

Adds a SC call step, then executes it.
source§

fn transfer_step(&mut self, step: TransferStep) -> &mut Self

Adds a simple transfer step, then executes it.
source§

fn validator_reward_step(&mut self, step: ValidatorRewardStep) -> &mut Self

Adds a validator reward step, then executes it.
source§

fn check_state_step(&mut self, step: CheckStateStep) -> &mut Self

Adds a check state step, then executes it.
source§

fn dump_state_step(&mut self) -> &mut Self

Adds a dump state step, then executes it.
source§

fn mandos_set_state(&mut self, step: SetStateStep) -> &mut Self

👎Deprecated since 0.39.0: Renamed, use set_state_step instead.
source§

fn mandos_sc_call(&mut self, step: ScCallStep) -> &mut Self

👎Deprecated since 0.39.0: Renamed, use sc_call_step instead.
source§

fn mandos_sc_query(&mut self, step: ScQueryStep) -> &mut Self

👎Deprecated since 0.39.0: Renamed, use sc_query_step instead.
source§

fn mandos_sc_deploy(&mut self, step: ScDeployStep) -> &mut Self

👎Deprecated since 0.39.0: Renamed, use sc_deploy_step instead.
source§

fn mandos_transfer(&mut self, step: TransferStep) -> &mut Self

👎Deprecated since 0.39.0: Renamed, use transfer_step instead.
source§

fn mandos_validator_reward(&mut self, step: ValidatorRewardStep) -> &mut Self

👎Deprecated since 0.39.0: Renamed, use validator_reward_step instead.
source§

fn mandos_check_state(&mut self, step: CheckStateStep) -> &mut Self

👎Deprecated since 0.39.0: Renamed, use check_state_step instead.
source§

fn mandos_dump_state(&mut self) -> &mut Self

👎Deprecated since 0.39.0: Renamed, use dump_state_step instead.
source§

impl TxCacheSource for BlockchainMock

source§

impl TypedScCallExecutor for BlockchainMock

source§

fn execute_typed_sc_call<OriginalResult, RequestedResult>( &mut self, typed_sc_call: TypedScCall<OriginalResult> ) -> RequestedResultwhere OriginalResult: TopEncodeMulti, RequestedResult: CodecFrom<OriginalResult>,

source§

impl TypedScDeployExecutor for BlockchainMock

source§

fn execute_typed_sc_deploy<OriginalResult, RequestedResult>( &mut self, typed_sc_call: TypedScDeploy<OriginalResult> ) -> (Address, RequestedResult)where OriginalResult: TopEncodeMulti, RequestedResult: CodecFrom<OriginalResult>,

source§

impl TypedScQueryExecutor for BlockchainMock

source§

fn execute_typed_sc_query<OriginalResult, RequestedResult>( &mut self, typed_sc_call: TypedScQuery<OriginalResult> ) -> RequestedResultwhere OriginalResult: TopEncodeMulti, RequestedResult: CodecFrom<OriginalResult>,

Auto Trait Implementations§

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.

source§

impl<T> InterpretableFrom<T> for T

source§

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.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
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