pub struct Watcher {
pub called_id: bool,
pub called_time: bool,
pub called_balance: bool,
pub called_caller: bool,
pub called_msg_cycles_available: bool,
pub called_msg_cycles_accept: bool,
pub called_msg_cycles_refunded: bool,
pub called_stable_store: bool,
pub called_stable_restore: bool,
pub called_set_certified_data: bool,
pub called_data_certificate: bool,
/* private fields */
}Expand description
A watcher can be used to inspect the calls made in a call.
Fields§
§called_id: boolTrue if the context.id() was called during execution.
called_time: boolTrue if the context.time() was called during execution.
called_balance: boolTrue if the context.balance() was called during execution.
called_caller: boolTrue if the context.caller() was called during execution.
called_msg_cycles_available: boolTrue if the context.msg_cycles_available() was called during execution.
called_msg_cycles_accept: boolTrue if the context.msg_cycles_accept() was called during execution.
called_msg_cycles_refunded: boolTrue if the context.msg_cycles_refunded() was called during execution.
called_stable_store: boolTrue if the context.stable_store() was called during execution.
called_stable_restore: boolTrue if the context.stable_restore() was called during execution.
called_set_certified_data: boolTrue if the context.set_certified_data() was called during execution.
called_data_certificate: boolTrue if the context.data_certificate() was called during execution.
Implementations§
Source§impl Watcher
impl Watcher
Sourcepub fn record_call(&mut self, call: WatcherCall)
pub fn record_call(&mut self, call: WatcherCall)
Push a call to the call history of the watcher.
Sourcepub fn call_count(&self) -> usize
pub fn call_count(&self) -> usize
Return the number of calls made during the last execution.
Sourcepub fn cycles_consumed(&self) -> u64
pub fn cycles_consumed(&self) -> u64
Returns the total amount of cycles consumed in inter-canister calls.
Sourcepub fn cycles_refunded(&self) -> u64
pub fn cycles_refunded(&self) -> u64
Returns the total amount of cycles refunded in inter-canister calls.
Sourcepub fn cycles_sent(&self) -> u64
pub fn cycles_sent(&self) -> u64
Returns the total amount of cycles sent in inter-canister calls, not deducing the refunded amounts.
Sourcepub fn get_call(&self, n: usize) -> &WatcherCall
pub fn get_call(&self, n: usize) -> &WatcherCall
Return the n-th call that took place during the execution.
Sourcepub fn is_method_called(&self, method_name: &str) -> bool
pub fn is_method_called(&self, method_name: &str) -> bool
Returns true if the given method was called during the execution.
Sourcepub fn is_canister_called(&self, canister_id: &Principal) -> bool
pub fn is_canister_called(&self, canister_id: &Principal) -> bool
Returns true if the given canister was called during the execution.
Sourcepub fn is_called(&self, canister_id: &Principal, method_name: &str) -> bool
pub fn is_called(&self, canister_id: &Principal, method_name: &str) -> bool
Returns true if the given method was called.
Sourcepub fn is_modified<T: 'static>(&self) -> bool
pub fn is_modified<T: 'static>(&self) -> bool
Returns true if the given storage item was accessed in a mutable way during the execution. This method tracks calls to:
- context.store()
- context.get_mut()
- context.delete()