Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Renames `v3ResponseBody` to `v4ResponseBody`
- Renames `isV3ResponseBody` to `isV4ResponseBody`
- Renames `HttpV3ApiNotSupportedErrorCode` to `HttpV4ApiNotSupportedErrorCode`
- feat(agent)!: use `/api/v3` for query and read_state requests
- feat(assets)!: replaces `@dfinity/{agent,candid,principal}` deps with `@icp-sdk/core`
- feat(assets)!: drops support for cjs for the `@dfinity/assets` package
- feat(auth-client)!: `@dfinity/auth-client` has been deprecated. Migrate to [`@icp-sdk/auth`](https://js.icp.build/auth/latest/upgrading/v4)
Expand Down
46 changes: 23 additions & 23 deletions e2e/node/basic/__snapshots__/syncTime.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,6 @@ exports[`syncTime > on async creation > should sync time on when enabled > V4 re
}
`;

exports[`syncTime > on async creation > should sync time on when enabled > V4 read state body two 1`] = `
{
"content": {
"ingress_expiry": 1746103140000000000n,
"paths": [
[
{
"data": [
116,
105,
109,
101,
],
"type": "Buffer",
},
],
],
"request_type": "read_state",
"sender": Any<Uint8Array>,
},
}
`;

exports[`syncTime > on error > should not sync time by default > V4 call body 1`] = `
{
"content": {
Expand Down Expand Up @@ -116,6 +93,29 @@ exports[`syncTime > on error > should not sync time by default > V4 call body 1`
}
`;

exports[`syncTime > on error > should sync time when the local time does not match the subnet time > V3 read state body one 1`] = `
{
"content": {
"ingress_expiry": 1746103140000000000n,
"paths": [
[
{
"data": [
116,
105,
109,
101,
],
"type": "Buffer",
},
],
],
"request_type": "read_state",
"sender": Any<Uint8Array>,
},
}
`;

exports[`syncTime > on error > should sync time when the local time does not match the subnet time > V2 read state body one 1`] = `
{
"content": {
Expand Down
20 changes: 10 additions & 10 deletions e2e/node/basic/canisterStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import {
MockReplica,
mockSyncTimeResponse,
prepareV2ReadStateSubnetResponse,
prepareV3ReadStateSubnetResponse,
} from '../utils/mock-replica.ts';
import { randomIdentity, randomKeyPair } from '../utils/identity.ts';

Expand Down Expand Up @@ -62,7 +62,7 @@

expect(subnet).toBeDefined();

const principal = Principal.fromText(subnet.subnetId);

Check failure on line 65 in e2e/node/basic/canisterStatus.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20)

basic/canisterStatus.test.ts > canister status > should fetch the subnet id of a given canister

TypeError: Cannot read properties of null (reading 'subnetId') ❯ basic/canisterStatus.test.ts:65:49

Check failure on line 65 in e2e/node/basic/canisterStatus.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 22)

basic/canisterStatus.test.ts > canister status > should fetch the subnet id of a given canister

TypeError: Cannot read properties of null (reading 'subnetId') ❯ basic/canisterStatus.test.ts:65:49

Check failure on line 65 in e2e/node/basic/canisterStatus.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 24)

basic/canisterStatus.test.ts > canister status > should fetch the subnet id of a given canister

TypeError: Cannot read properties of null (reading 'subnetId') ❯ basic/canisterStatus.test.ts:65:49
expect(principal).toBeDefined();
});

Expand Down Expand Up @@ -92,14 +92,14 @@
identity,
});

const { responseBody: subnetResponseBody } = await prepareV2ReadStateSubnetResponse({
const { responseBody: subnetResponseBody } = await prepareV3ReadStateSubnetResponse({
nodeIdentity,
canisterRanges: [[canisterId.toUint8Array(), canisterId.toUint8Array()]],
keyPair: subnetKeyPair,
date: replicaDate,
});
// first try, fails
mockReplica.setV2ReadStateSpyImplOnce(canisterId.toString(), (_req, res) => {
mockReplica.setV3ReadStateSpyImplOnce(canisterId.toString(), (_req, res) => {
res.status(200).send(subnetResponseBody);
});
// syncs time
Expand All @@ -124,7 +124,7 @@
expect(err.cause.code).toBeInstanceOf(CertificateTimeErrorCode);
expect(err.message).toContain('Certificate is signed more than 5 minutes in the past');
}
expect(mockReplica.getV2ReadStateSpy(canisterId.toString())).toHaveBeenCalledTimes(4);
expect(mockReplica.getV3ReadStateSpy(canisterId.toString())).toHaveBeenCalledTimes(4);
});

it('should sync time and succeed if the certificate is not fresh', async () => {
Expand All @@ -137,14 +137,14 @@
identity,
});

const { responseBody: subnetResponseBody } = await prepareV2ReadStateSubnetResponse({
const { responseBody: subnetResponseBody } = await prepareV3ReadStateSubnetResponse({
nodeIdentity,
canisterRanges: [[canisterId.toUint8Array(), canisterId.toUint8Array()]],
keyPair: subnetKeyPair,
date: replicaDate,
});
// first try, fails
mockReplica.setV2ReadStateSpyImplOnce(canisterId.toString(), (_req, res) => {
mockReplica.setV3ReadStateSpyImplOnce(canisterId.toString(), (_req, res) => {
res.status(200).send(subnetResponseBody);
});
// sync time, we return the replica date to make the agent sync time properly
Expand All @@ -162,7 +162,7 @@
paths: ['subnet'],
}),
).resolves.not.toThrow();
expect(mockReplica.getV2ReadStateSpy(canisterId.toString())).toHaveBeenCalledTimes(4);
expect(mockReplica.getV3ReadStateSpy(canisterId.toString())).toHaveBeenCalledTimes(4);
});

it('should not sync time and succeed if the certificate is not fresh and disableTimeVerification is true', async () => {
Expand All @@ -175,13 +175,13 @@
identity,
});

const { responseBody: subnetResponseBody } = await prepareV2ReadStateSubnetResponse({
const { responseBody: subnetResponseBody } = await prepareV3ReadStateSubnetResponse({
nodeIdentity,
canisterRanges: [[canisterId.toUint8Array(), canisterId.toUint8Array()]],
keyPair: subnetKeyPair,
date: replicaDate,
});
mockReplica.setV2ReadStateSpyImplOnce(canisterId.toString(), (_req, res) => {
mockReplica.setV3ReadStateSpyImplOnce(canisterId.toString(), (_req, res) => {
res.status(200).send(subnetResponseBody);
});

Expand All @@ -193,7 +193,7 @@
disableCertificateTimeVerification: true,
}),
).resolves.not.toThrow();
expect(mockReplica.getV2ReadStateSpy(canisterId.toString())).toHaveBeenCalledTimes(1);
expect(mockReplica.getV3ReadStateSpy(canisterId.toString())).toHaveBeenCalledTimes(1);
});
});
});
Loading
Loading