Struct dharitri_wasm_debug::world_mock::BlockchainMock
source · 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
impl BlockchainMock
pub fn denali_check_state( &mut self, check_state_step: CheckStateStep ) -> &mut Self
pub fn denali_dump_state(&mut self) -> &mut Self
source§impl BlockchainMock
impl BlockchainMock
sourcepub fn denali_sc_call(&mut self, sc_call_step: ScCallStep) -> &mut Self
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.
sourcepub fn denali_sc_call_get_result<OriginalResult, RequestedResult>(
&mut self,
typed_sc_call: TypedScCall<OriginalResult>
) -> RequestedResultwhere
OriginalResult: TopEncodeMulti,
RequestedResult: CodecFrom<OriginalResult>,
pub fn denali_sc_call_get_result<OriginalResult, RequestedResult>(
&mut self,
typed_sc_call: TypedScCall<OriginalResult>
) -> RequestedResultwhere
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
impl BlockchainMock
sourcepub fn denali_sc_deploy(&mut self, sc_deploy_step: ScDeployStep) -> &mut Self
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.
sourcepub fn denali_sc_deploy_get_result<OriginalResult, RequestedResult>(
&mut self,
typed_sc_deploy: TypedScDeploy<OriginalResult>
) -> (Address, RequestedResult)where
OriginalResult: TopEncodeMulti,
RequestedResult: CodecFrom<OriginalResult>,
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
impl BlockchainMock
sourcepub fn denali_sc_query(&mut self, sc_query_step: ScQueryStep) -> &mut Self
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.
sourcepub fn denali_sc_query_expect_result<OriginalResult, RequestedResult>(
&mut self,
typed_sc_query: TypedScQuery<OriginalResult>
) -> RequestedResultwhere
OriginalResult: TopEncodeMulti,
RequestedResult: CodecFrom<OriginalResult>,
pub fn denali_sc_query_expect_result<OriginalResult, RequestedResult>(
&mut self,
typed_sc_query: TypedScQuery<OriginalResult>
) -> RequestedResultwhere
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
impl BlockchainMock
sourcepub fn quick_query<CC, RequestedResult>(
&mut self,
contract_call: CC
) -> RequestedResult
pub fn quick_query<CC, RequestedResult>( &mut self, contract_call: CC ) -> RequestedResult
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
impl BlockchainMock
pub fn denali_set_state(&mut self, set_state_step: SetStateStep) -> &mut Self
source§impl BlockchainMock
impl BlockchainMock
pub fn denali_transfer(&mut self, transfer_step: TransferStep) -> &mut Self
pub fn denali_validator_reward( &mut self, validator_rewards_step: ValidatorRewardStep ) -> &mut Self
source§impl BlockchainMock
impl BlockchainMock
pub fn account_exists(&self, address: &Address) -> bool
pub fn contains_contract(&self, contract_path_expr: &str) -> bool
pub fn commit_updates(&mut self, updates: BlockchainUpdate)
pub fn increase_account_nonce(&mut self, address: &Address)
pub fn subtract_tx_gas( &mut self, address: &Address, gas_limit: u64, gas_price: u64 )
pub fn increase_validator_reward(&mut self, address: &Address, amount: &BigUint)
source§impl BlockchainMock
impl BlockchainMock
pub fn add_account(&mut self, acct: AccountData)
pub fn add_addr_denali_string(&mut self, address: Address)
pub fn validate_and_add_account(&mut self, acct: AccountData)
pub fn update_accounts(&mut self, accounts: HashMap<Address, AccountData>)
pub fn print_accounts(&self)
pub fn put_new_address( &mut self, creator_address: Address, creator_nonce: u64, new_address: Address )
pub fn get_new_address( &self, creator_address: Address, creator_nonce: u64 ) -> Option<Address>
pub fn validate_account(&self, account: &AccountData)
pub fn check_account_has_code(&self, account: &AccountData) -> bool
source§impl BlockchainMock
impl BlockchainMock
pub fn interpreter_context(&self) -> InterpreterContext
sourcepub fn set_current_dir_from_workspace(
&mut self,
relative_path: &str
) -> &mut Self
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.
sourcepub fn register_contract<B: CallableContractBuilder>(
&mut self,
expression: &str,
contract_builder: B
)
pub fn register_contract<B: CallableContractBuilder>( &mut self, expression: &str, contract_builder: B )
Links a contract path in a test to a contract implementation.
pub fn register_contract_builder<B: CallableContractBuilder>( &mut self, expression: &str, contract_builder: B )
register_contract
, but not completely removed, in order to ease test migration. Please replace with register_contract
.sourcepub fn register_partial_contract<Abi, B>(
&mut self,
expression: &str,
contract_builder: B,
sub_contract_name: &str
)where
Abi: ContractAbiProvider,
B: CallableContractBuilder,
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.