diff --git a/docs/generated/changelog.html b/docs/generated/changelog.html
index 90dc2414b..b16011a31 100644
--- a/docs/generated/changelog.html
+++ b/docs/generated/changelog.html
@@ -15,6 +15,7 @@
Version 0.12.2
Support for the SubtleCrypto interface in @dfinity/identity using the new ECDSAKeyIdentity
+ CanisterStatus no longer suppresses rootKey errors
Version 0.12.1
diff --git a/e2e/node/basic/canisterStatus.test.ts b/e2e/node/basic/canisterStatus.test.ts
new file mode 100644
index 000000000..5b7e31cf9
--- /dev/null
+++ b/e2e/node/basic/canisterStatus.test.ts
@@ -0,0 +1,40 @@
+import { CanisterStatus, HttpAgent } from '@dfinity/agent';
+import { Principal } from '@dfinity/principal';
+import counter from '../canisters/counter';
+
+jest.setTimeout(30_000);
+describe.only('canister status', () => {
+ it('should fetch successfully', async () => {
+ const counterObj = await (await counter)();
+ const agent = new HttpAgent({ host: `http://localhost:${process.env.REPLICA_PORT}` });
+ await agent.fetchRootKey();
+ const request = await CanisterStatus.request({
+ canisterId: Principal.from(counterObj.canisterId),
+ agent,
+ paths: ['controllers'],
+ });
+
+ expect(Array.isArray(request.get('controllers'))).toBe(true);
+ });
+ it('should throw an error if fetchRootKey has not been called', async () => {
+ const counterObj = await (await counter)();
+ const agent = new HttpAgent({ host: `http://localhost:${process.env.REPLICA_PORT}` });
+ const shouldThrow = async () => {
+ // eslint-disable-next-line no-useless-catch
+ try {
+ const request = await CanisterStatus.request({
+ canisterId: Principal.from(counterObj.canisterId),
+ agent,
+ paths: ['controllers'],
+ }).catch(error => {
+ throw error;
+ });
+ console.log(request);
+ } catch (error) {
+ throw error;
+ }
+ };
+
+ expect(shouldThrow).rejects.toThrow();
+ });
+});
diff --git a/e2e/node/basic/counter.test.ts b/e2e/node/basic/counter.test.ts
index 342dc1630..72d3a1ac0 100644
--- a/e2e/node/basic/counter.test.ts
+++ b/e2e/node/basic/counter.test.ts
@@ -34,15 +34,12 @@ describe('counter', () => {
expect(set1.size < values.length || set2.size < values2.length).toBe(true);
});
it('should increment', async () => {
- const { actor: counter } = await counterCanister();
- try {
- expect(Number(await counter.read())).toEqual(0);
- await counter.inc();
- expect(Number(await counter.read())).toEqual(1);
- await counter.inc();
- expect(Number(await counter.read())).toEqual(2);
- } catch (error) {
- console.error(error);
- }
+ const { actor: counter } = await noncelessCanister();
+
+ expect(Number(await counter.read())).toEqual(0);
+ await counter.inc();
+ expect(Number(await counter.read())).toEqual(1);
+ await counter.inc();
+ expect(Number(await counter.read())).toEqual(2);
});
});
diff --git a/e2e/node/test-setup.ts b/e2e/node/test-setup.ts
index f6a9171df..7f3ee0a57 100644
--- a/e2e/node/test-setup.ts
+++ b/e2e/node/test-setup.ts
@@ -7,12 +7,12 @@
// Note that we can use webpack configuration to make some features available to
// Node.js in a similar way.
-// import { TextEncoder, TextDecoder } from 'text-encoding'; // eslint-disable-line
+import { TextEncoder, TextDecoder } from 'text-encoding'; // eslint-disable-line
// import fetch from 'isomorphic-fetch';
// global.crypto = crypto as unknown as Crypto;
// console.log('subtle', crypto['subtle']); // eslint-disable-line
-// global.TextDecoder = TextDecoder; // eslint-disable-line
-// global.TextEncoder = TextEncoder;
+global.TextDecoder = TextDecoder; // eslint-disable-line
+global.TextEncoder = TextEncoder;
// global.TextDecoder = TextDecoder; // eslint-disable-line
// (global.fetch as any) = fetch;
diff --git a/packages/agent/src/canisterStatus/index.ts b/packages/agent/src/canisterStatus/index.ts
index 5034d53cc..d4c151cce 100644
--- a/packages/agent/src/canisterStatus/index.ts
+++ b/packages/agent/src/canisterStatus/index.ts
@@ -2,7 +2,8 @@
import { lebDecode, PipeArrayBuffer } from '@dfinity/candid';
import { Principal } from '@dfinity/principal';
-import { HttpAgent, HttpAgentOptions, Cbor, Certificate, toHex } from '..';
+import { AgentError } from '../errors';
+import { HttpAgent, Cbor, Certificate, toHex } from '..';
/**
* Types of an entry on the canisterStatus map.
@@ -148,13 +149,19 @@ export const request = async (options: {
}
}
} catch (error) {
- error;
+ // Break on signature verification errors
+ if ((error as AgentError)?.message?.includes('Invalid certificate')) {
+ throw new AgentError((error as AgentError).message);
+ }
if (typeof path !== 'string' && 'key' in path && 'path' in path) {
status.set(path.key, null);
} else {
status.set(path, null);
}
+ console.group();
console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
+ console.warn(error);
+ console.groupEnd();
}
})();
});