Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions ic-canister-client/src/pocket_ic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@ impl PocketIcClient {
{
let args = candid::encode_args(args)?;

let reply = self
.client()
.update_call(self.canister, self.caller, method, args)
.await?;
let reply = if self.is_live() {
let id = self
.client()
.submit_call(self.canister, self.caller, method, args)
.await?;
self.client().await_call_no_ticks(id).await
} else {
self.client()
.update_call(self.canister, self.caller, method, args)
.await
}?;

let decoded = Decode!(&reply, R)?;
Ok(decoded)
Expand All @@ -75,6 +82,14 @@ impl PocketIcClient {
let decoded = Decode!(&reply, R)?;
Ok(decoded)
}

/// Returns true if the client is live.
fn is_live(&self) -> bool {
self.client
.as_ref()
.map(|client| client.url().is_some())
.unwrap_or_default()
}
}

#[async_trait::async_trait]
Expand Down