pub struct Pic { /* private fields */ }Expand description
Pic Thin wrapper around a PocketIC instance.
This type intentionally exposes only a minimal API surface; callers should
use pic() to obtain an instance and then perform installs/calls.
Callers must hold a PicSerialGuard for the full Pic lifetime.
Implementations§
Source§impl Pic
impl Pic
Sourcepub fn update_call<T, A>(
&self,
canister_id: Principal,
method: &str,
args: A,
) -> Result<T, Error>
pub fn update_call<T, A>( &self, canister_id: Principal, method: &str, args: A, ) -> Result<T, Error>
Generic update call helper (serializes args + decodes result).
Sourcepub fn update_call_as<T, A>(
&self,
canister_id: Principal,
caller: Principal,
method: &str,
args: A,
) -> Result<T, Error>
pub fn update_call_as<T, A>( &self, canister_id: Principal, caller: Principal, method: &str, args: A, ) -> Result<T, Error>
Generic update call helper with an explicit caller principal.
Sourcepub fn query_call<T, A>(
&self,
canister_id: Principal,
method: &str,
args: A,
) -> Result<T, Error>
pub fn query_call<T, A>( &self, canister_id: Principal, method: &str, args: A, ) -> Result<T, Error>
Generic query call helper.
Source§impl Pic
impl Pic
Sourcepub fn dump_canister_debug(&self, canister_id: Principal, context: &str)
pub fn dump_canister_debug(&self, canister_id: Principal, context: &str)
Dump basic PocketIC status and log context for one canister.
Source§impl Pic
impl Pic
Sourcepub fn create_and_install_root_canister(
&self,
wasm: Vec<u8>,
) -> Result<Principal, Error>
pub fn create_and_install_root_canister( &self, wasm: Vec<u8>, ) -> Result<Principal, Error>
Install a root canister with the default root init arguments.
Sourcepub fn create_and_install_canister(
&self,
role: CanisterRole,
wasm: Vec<u8>,
) -> Result<Principal, Error>
pub fn create_and_install_canister( &self, role: CanisterRole, wasm: Vec<u8>, ) -> Result<Principal, Error>
Install a canister with the given type and wasm bytes.
Install failures are treated as fatal in tests.
Sourcepub fn create_and_install_with_args(
&self,
wasm: Vec<u8>,
init_bytes: Vec<u8>,
install_cycles: u128,
) -> Principal
pub fn create_and_install_with_args( &self, wasm: Vec<u8>, init_bytes: Vec<u8>, install_cycles: u128, ) -> Principal
Install one arbitrary wasm module with caller-provided init bytes.
This is the generic install path for downstreams that use canic-testkit
without depending on Canic canister init payload conventions.
Sourcepub fn try_create_and_install_with_args(
&self,
wasm: Vec<u8>,
init_bytes: Vec<u8>,
install_cycles: u128,
) -> Result<Principal, PicInstallError>
pub fn try_create_and_install_with_args( &self, wasm: Vec<u8>, init_bytes: Vec<u8>, install_cycles: u128, ) -> Result<Principal, PicInstallError>
Install one arbitrary wasm module with caller-provided init bytes.
Sourcepub fn wait_for_ready(
&self,
canister_id: Principal,
tick_limit: usize,
context: &str,
)
pub fn wait_for_ready( &self, canister_id: Principal, tick_limit: usize, context: &str, )
Wait until one canister reports canic_ready.
Sourcepub fn wait_for_all_ready<I>(
&self,
canister_ids: I,
tick_limit: usize,
context: &str,
)where
I: IntoIterator<Item = Principal>,
pub fn wait_for_all_ready<I>(
&self,
canister_ids: I,
tick_limit: usize,
context: &str,
)where
I: IntoIterator<Item = Principal>,
Wait until all provided canisters report canic_ready.
Sourcepub fn wait_out_install_code_rate_limit(&self, cooldown: Duration)
pub fn wait_out_install_code_rate_limit(&self, cooldown: Duration)
Wait out the PocketIC install_code cooldown window inside the same instance.
Source§impl Pic
impl Pic
Sourcepub fn capture_controller_snapshots<I>(
&self,
controller_id: Principal,
canister_ids: I,
) -> Option<ControllerSnapshots>where
I: IntoIterator<Item = Principal>,
pub fn capture_controller_snapshots<I>(
&self,
controller_id: Principal,
canister_ids: I,
) -> Option<ControllerSnapshots>where
I: IntoIterator<Item = Principal>,
Capture one restorable snapshot per canister using a shared controller.
Sourcepub fn restore_controller_snapshots(
&self,
controller_id: Principal,
snapshots: &ControllerSnapshots,
)
pub fn restore_controller_snapshots( &self, controller_id: Principal, snapshots: &ControllerSnapshots, )
Restore a previously captured snapshot set using the same controller.
Source§impl Pic
impl Pic
Sourcepub fn advance_time(&self, duration: Duration)
pub fn advance_time(&self, duration: Duration)
Advance PocketIC wall-clock time by one duration.
Sourcepub fn create_canister(&self) -> Principal
pub fn create_canister(&self) -> Principal
Create one canister with PocketIC default settings.
Sourcepub fn add_cycles(&self, canister_id: Principal, amount: u128)
pub fn add_cycles(&self, canister_id: Principal, amount: u128)
Add cycles to one existing canister.
Sourcepub fn install_canister(
&self,
canister_id: Principal,
wasm_module: Vec<u8>,
arg: Vec<u8>,
sender: Option<Principal>,
)
pub fn install_canister( &self, canister_id: Principal, wasm_module: Vec<u8>, arg: Vec<u8>, sender: Option<Principal>, )
Install one wasm module on one existing canister.
Sourcepub fn upgrade_canister(
&self,
canister_id: Principal,
wasm_module: Vec<u8>,
arg: Vec<u8>,
sender: Option<Principal>,
) -> Result<(), RejectResponse>
pub fn upgrade_canister( &self, canister_id: Principal, wasm_module: Vec<u8>, arg: Vec<u8>, sender: Option<Principal>, ) -> Result<(), RejectResponse>
Upgrade one existing canister with a new wasm module.
Sourcepub fn reinstall_canister(
&self,
canister_id: Principal,
wasm_module: Vec<u8>,
arg: Vec<u8>,
sender: Option<Principal>,
) -> Result<(), RejectResponse>
pub fn reinstall_canister( &self, canister_id: Principal, wasm_module: Vec<u8>, arg: Vec<u8>, sender: Option<Principal>, ) -> Result<(), RejectResponse>
Reinstall one existing canister with a new wasm module.
Sourcepub fn submit_call(
&self,
canister_id: Principal,
sender: Principal,
method: &str,
payload: Vec<u8>,
) -> Result<RawMessageId, RejectResponse>
pub fn submit_call( &self, canister_id: Principal, sender: Principal, method: &str, payload: Vec<u8>, ) -> Result<RawMessageId, RejectResponse>
Submit one raw update call without executing it immediately.
Sourcepub fn await_call(
&self,
message_id: RawMessageId,
) -> Result<Vec<u8>, RejectResponse>
pub fn await_call( &self, message_id: RawMessageId, ) -> Result<Vec<u8>, RejectResponse>
Await one previously submitted raw update call.
Sourcepub fn canister_status(
&self,
canister_id: Principal,
sender: Option<Principal>,
) -> Result<CanisterStatusResult, RejectResponse>
pub fn canister_status( &self, canister_id: Principal, sender: Option<Principal>, ) -> Result<CanisterStatusResult, RejectResponse>
Fetch one canister status snapshot from PocketIC.
Sourcepub fn fetch_canister_logs(
&self,
canister_id: Principal,
sender: Principal,
) -> Result<Vec<CanisterLogRecord>, RejectResponse>
pub fn fetch_canister_logs( &self, canister_id: Principal, sender: Principal, ) -> Result<Vec<CanisterLogRecord>, RejectResponse>
Fetch one canister log stream from PocketIC.
Sourcepub fn current_time_nanos(&self) -> u64
pub fn current_time_nanos(&self) -> u64
Capture the current PocketIC wall-clock time as nanoseconds since epoch.
Sourcepub fn restore_time_nanos(&self, nanos_since_epoch: u64)
pub fn restore_time_nanos(&self, nanos_since_epoch: u64)
Restore PocketIC wall-clock and certified time from a captured nanosecond value.