diff --git a/e2e/node/basic/trap.test.ts b/e2e/node/basic/trap.test.ts index d6bee77e..160d3160 100644 --- a/e2e/node/basic/trap.test.ts +++ b/e2e/node/basic/trap.test.ts @@ -4,7 +4,14 @@ import util from 'util'; import exec from 'child_process'; const execAsync = util.promisify(exec.exec); -const { stdout } = await execAsync('dfx canister id trap'); +// eslint-disable-next-line prefer-const +let stdout; +try { + ({ stdout } = await execAsync('dfx canister id trap')); +} catch { + await execAsync('dfx deploy trap'); + ({ stdout } = await execAsync('dfx canister id trap')); +} export const idlFactory = ({ IDL }) => { return IDL.Service({ diff --git a/packages/agent/src/utils/callAndPoll.ts b/packages/agent/src/utils/callAndPoll.ts index 2a4521d3..52ae8157 100644 --- a/packages/agent/src/utils/callAndPoll.ts +++ b/packages/agent/src/utils/callAndPoll.ts @@ -1,5 +1,5 @@ import { Principal } from '@dfinity/principal'; -import { Agent, Certificate, bufFromBufLike, polling } from '..'; +import { Agent, Certificate, bufFromBufLike, polling, v3ResponseBody } from '..'; import { AgentError } from '../errors'; /** @@ -31,8 +31,8 @@ export async function callAndPoll(options: { }); let certificate: Certificate; - if (response.body && response.body.certificate) { - const cert = response.body.certificate; + if (response.body && (response.body as v3ResponseBody).certificate) { + const cert = (response.body as v3ResponseBody).certificate; // Create certificate to validate the responses certificate = await Certificate.create({ certificate: bufFromBufLike(cert),