pub struct BlockchainMock {
    pub accounts: HashMap<Address, AccountData>,
    pub builtin_functions: Rc<BuiltinFunctionMap>,
    pub addr_to_denali_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 denali_trace: Scenario,
}

Fields§

§accounts: HashMap<Address, AccountData>§builtin_functions: Rc<BuiltinFunctionMap>§addr_to_denali_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§denali_trace: Scenario

Implementations§

source§

impl BlockchainMock

source

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

source

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

source§

impl BlockchainMock

source

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

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

source

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

Adds a denali 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 denali_sc_deploy(&mut self, sc_deploy_step: ScDeployStep) -> &mut Self

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

source

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

Adds a denali 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 denali_sc_query(&mut self, sc_query_step: ScQueryStep) -> &mut Self

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

source

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

Adds a denali 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 ) -> RequestedResult
where CC: ContractCall<DebugApi>, RequestedResult: CodecFrom<CC::OriginalResult>,

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

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

Use denali_sc_query to embed the SC query in the resulting denali.

source§

impl BlockchainMock

source

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

source§

impl BlockchainMock

source

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

source

pub fn denali_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§

impl BlockchainMock

source

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

source

pub fn add_addr_denali_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 set_current_dir_from_workspace( &mut self, relative_path: &str ) -> &mut Self

Tells the tests where the crate lies relative to the workspace. This ensures that the paths are set correctly, including in debug mode.

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_contract_builder<B: CallableContractBuilder>( &mut self, expression: &str, contract_builder: B )

👎Deprecated since 0.37.0: Got renamed to register_contract, but not completely removed, in order to ease test migration. Please replace with register_contract.
source

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

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_denali_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 TxCacheSource for BlockchainMock

source§

impl TypedScCallExecutor for BlockchainMock

source§

fn execute_typed_sc_call<OriginalResult, RequestedResult>( &mut self, typed_sc_call: TypedScCall<OriginalResult> ) -> RequestedResult
where 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> ) -> RequestedResult
where OriginalResult: TopEncodeMulti, RequestedResult: CodecFrom<OriginalResult>,

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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V