Struct near_sdk::MockedBlockchain [−][src]
Mocked blockchain that can be used in the tests for the smart contracts.
It implements BlockchainInterface
by redirecting calls to VMLogic
. It unwraps errors of
VMLogic
to cause panic during the unit tests similarly to how errors of VMLogic
would cause
the termination of guest program execution. Unit tests can even assert the expected error
message.
Implementations
impl MockedBlockchain
[src]
pub fn new(
context: VMContext,
config: VMConfig,
fees_config: RuntimeFeesConfig,
promise_results: Vec<PromiseResult>,
storage: HashMap<Vec<u8>, Vec<u8>>,
validators: HashMap<AccountId, Balance>,
memory_opt: Option<Box<dyn MemoryLike>>
) -> Self
[src]
context: VMContext,
config: VMConfig,
fees_config: RuntimeFeesConfig,
promise_results: Vec<PromiseResult>,
storage: HashMap<Vec<u8>, Vec<u8>>,
validators: HashMap<AccountId, Balance>,
memory_opt: Option<Box<dyn MemoryLike>>
) -> Self
pub fn take_storage(&mut self) -> HashMap<Vec<u8>, Vec<u8>>
[src]
pub fn created_receipts(&self) -> &Vec<Receipt>
[src]
pub fn outcome(&self) -> VMOutcome
[src]
pub fn gas(&mut self, gas_amount: u32)
[src]
pub fn logs(&self) -> Vec<String>
[src]
Trait Implementations
impl BlockchainInterface for MockedBlockchain
[src]
unsafe fn read_register(&self, register_id: u64, ptr: u64)
[src]
unsafe fn register_len(&self, register_id: u64) -> u64
[src]
unsafe fn current_account_id(&self, register_id: u64)
[src]
unsafe fn signer_account_id(&self, register_id: u64)
[src]
unsafe fn signer_account_pk(&self, register_id: u64)
[src]
unsafe fn predecessor_account_id(&self, register_id: u64)
[src]
unsafe fn input(&self, register_id: u64)
[src]
unsafe fn block_index(&self) -> u64
[src]
unsafe fn block_timestamp(&self) -> u64
[src]
unsafe fn epoch_height(&self) -> u64
[src]
unsafe fn storage_usage(&self) -> u64
[src]
unsafe fn account_balance(&self, balance_ptr: u64)
[src]
unsafe fn account_locked_balance(&self, balance_ptr: u64)
[src]
unsafe fn attached_deposit(&self, balance_ptr: u64)
[src]
unsafe fn prepaid_gas(&self) -> u64
[src]
unsafe fn used_gas(&self) -> u64
[src]
unsafe fn random_seed(&self, register_id: u64)
[src]
unsafe fn sha256(&self, value_len: u64, value_ptr: u64, register_id: u64)
[src]
unsafe fn keccak256(&self, value_len: u64, value_ptr: u64, register_id: u64)
[src]
unsafe fn keccak512(&self, value_len: u64, value_ptr: u64, register_id: u64)
[src]
unsafe fn value_return(&self, value_len: u64, value_ptr: u64)
[src]
unsafe fn panic(&self)
[src]
unsafe fn panic_utf8(&self, len: u64, ptr: u64)
[src]
unsafe fn log_utf8(&self, len: u64, ptr: u64)
[src]
unsafe fn log_utf16(&self, len: u64, ptr: u64)
[src]
unsafe fn abort(&self, msg_ptr: u32, filename_ptr: u32, line: u32, col: u32)
[src]
unsafe fn promise_create(
&self,
account_id_len: u64,
account_id_ptr: u64,
method_name_len: u64,
method_name_ptr: u64,
arguments_len: u64,
arguments_ptr: u64,
amount_ptr: u64,
gas: u64
) -> u64
[src]
&self,
account_id_len: u64,
account_id_ptr: u64,
method_name_len: u64,
method_name_ptr: u64,
arguments_len: u64,
arguments_ptr: u64,
amount_ptr: u64,
gas: u64
) -> u64
unsafe fn promise_then(
&self,
promise_index: u64,
account_id_len: u64,
account_id_ptr: u64,
method_name_len: u64,
method_name_ptr: u64,
arguments_len: u64,
arguments_ptr: u64,
amount_ptr: u64,
gas: u64
) -> u64
[src]
&self,
promise_index: u64,
account_id_len: u64,
account_id_ptr: u64,
method_name_len: u64,
method_name_ptr: u64,
arguments_len: u64,
arguments_ptr: u64,
amount_ptr: u64,
gas: u64
) -> u64
unsafe fn promise_and(
&self,
promise_idx_ptr: u64,
promise_idx_count: u64
) -> u64
[src]
&self,
promise_idx_ptr: u64,
promise_idx_count: u64
) -> u64
unsafe fn promise_batch_create(
&self,
account_id_len: u64,
account_id_ptr: u64
) -> u64
[src]
&self,
account_id_len: u64,
account_id_ptr: u64
) -> u64
unsafe fn promise_batch_then(
&self,
promise_index: u64,
account_id_len: u64,
account_id_ptr: u64
) -> u64
[src]
&self,
promise_index: u64,
account_id_len: u64,
account_id_ptr: u64
) -> u64
unsafe fn promise_batch_action_create_account(&self, promise_index: u64)
[src]
unsafe fn promise_batch_action_deploy_contract(
&self,
promise_index: u64,
code_len: u64,
code_ptr: u64
)
[src]
&self,
promise_index: u64,
code_len: u64,
code_ptr: u64
)
unsafe fn promise_batch_action_function_call(
&self,
promise_index: u64,
method_name_len: u64,
method_name_ptr: u64,
arguments_len: u64,
arguments_ptr: u64,
amount_ptr: u64,
gas: u64
)
[src]
&self,
promise_index: u64,
method_name_len: u64,
method_name_ptr: u64,
arguments_len: u64,
arguments_ptr: u64,
amount_ptr: u64,
gas: u64
)
unsafe fn promise_batch_action_transfer(
&self,
promise_index: u64,
amount_ptr: u64
)
[src]
&self,
promise_index: u64,
amount_ptr: u64
)
unsafe fn promise_batch_action_stake(
&self,
promise_index: u64,
amount_ptr: u64,
public_key_len: u64,
public_key_ptr: u64
)
[src]
&self,
promise_index: u64,
amount_ptr: u64,
public_key_len: u64,
public_key_ptr: u64
)
unsafe fn promise_batch_action_add_key_with_full_access(
&self,
promise_index: u64,
public_key_len: u64,
public_key_ptr: u64,
nonce: u64
)
[src]
&self,
promise_index: u64,
public_key_len: u64,
public_key_ptr: u64,
nonce: u64
)
unsafe fn promise_batch_action_add_key_with_function_call(
&self,
promise_index: u64,
public_key_len: u64,
public_key_ptr: u64,
nonce: u64,
allowance_ptr: u64,
receiver_id_len: u64,
receiver_id_ptr: u64,
method_names_len: u64,
method_names_ptr: u64
)
[src]
&self,
promise_index: u64,
public_key_len: u64,
public_key_ptr: u64,
nonce: u64,
allowance_ptr: u64,
receiver_id_len: u64,
receiver_id_ptr: u64,
method_names_len: u64,
method_names_ptr: u64
)
unsafe fn promise_batch_action_delete_key(
&self,
promise_index: u64,
public_key_len: u64,
public_key_ptr: u64
)
[src]
&self,
promise_index: u64,
public_key_len: u64,
public_key_ptr: u64
)
unsafe fn promise_batch_action_delete_account(
&self,
promise_index: u64,
beneficiary_id_len: u64,
beneficiary_id_ptr: u64
)
[src]
&self,
promise_index: u64,
beneficiary_id_len: u64,
beneficiary_id_ptr: u64
)
unsafe fn promise_results_count(&self) -> u64
[src]
unsafe fn promise_result(&self, result_idx: u64, register_id: u64) -> u64
[src]
unsafe fn promise_return(&self, promise_id: u64)
[src]
unsafe fn storage_write(
&self,
key_len: u64,
key_ptr: u64,
value_len: u64,
value_ptr: u64,
register_id: u64
) -> u64
[src]
&self,
key_len: u64,
key_ptr: u64,
value_len: u64,
value_ptr: u64,
register_id: u64
) -> u64
unsafe fn storage_read(
&self,
key_len: u64,
key_ptr: u64,
register_id: u64
) -> u64
[src]
&self,
key_len: u64,
key_ptr: u64,
register_id: u64
) -> u64
unsafe fn storage_remove(
&self,
key_len: u64,
key_ptr: u64,
register_id: u64
) -> u64
[src]
&self,
key_len: u64,
key_ptr: u64,
register_id: u64
) -> u64
unsafe fn storage_has_key(&self, key_len: u64, key_ptr: u64) -> u64
[src]
unsafe fn validator_stake(
&self,
account_id_len: u64,
account_id_ptr: u64,
stake_ptr: u64
)
[src]
&self,
account_id_len: u64,
account_id_ptr: u64,
stake_ptr: u64
)
unsafe fn validator_total_stake(&self, stake_ptr: u64)
[src]
fn as_mut_mocked_blockchain(&mut self) -> Option<&mut MockedBlockchain>
[src]
fn as_mocked_blockchain(&self) -> Option<&MockedBlockchain>
[src]
Auto Trait Implementations
impl !RefUnwindSafe for MockedBlockchain
impl !Send for MockedBlockchain
impl !Sync for MockedBlockchain
impl Unpin for MockedBlockchain
impl !UnwindSafe for MockedBlockchain
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,