Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to pic server 2.0.1 #14

Merged
merged 1 commit into from
Feb 4, 2024
Merged
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
14 changes: 7 additions & 7 deletions examples/clock/tests/src/clock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ describe('Clock', () => {

beforeEach(async () => {
pic = await PocketIc.create();
const fixture = await pic.setupCanister<ClockService>(
const fixture = await pic.setupCanister<ClockService>({
idlFactory,
WASM_PATH,
);
wasm: WASM_PATH,
});
actor = fixture.actor;
canisterId = fixture.canisterId;
});
Expand All @@ -36,16 +36,16 @@ describe('Clock', () => {
});

it('should create the correct canister', async () => {
const canisterExists = await pic.checkCanisterExists(canisterId);
const canisterExists = await pic.getCanisterSubnetId(canisterId);

expect(canisterExists).toBe(true);
expect(canisterExists).toBeTruthy();
});

it('should not create any other canister', async () => {
const otherCanisterId = Principal.fromUint8Array(new Uint8Array([0]));
const canisterExists = await pic.checkCanisterExists(otherCanisterId);
const canisterExists = await pic.getCanisterSubnetId(otherCanisterId);

expect(canisterExists).toBe(false);
expect(canisterExists).toBeFalsy();
});

it('should set and get canister cycles', async () => {
Expand Down
25 changes: 12 additions & 13 deletions examples/counter/tests/src/counter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ describe('Counter', () => {

beforeEach(async () => {
pic = await PocketIc.create();
const fixture = await pic.setupCanister<CounterService>(
const fixture = await pic.setupCanister<CounterService>({
idlFactory,
WASM_PATH,
undefined,
IDL.encode(init({ IDL }), [countInitArg]),
);
wasm: WASM_PATH,
arg: IDL.encode(init({ IDL }), [countInitArg]),
});
actor = fixture.actor;
canisterId = fixture.canisterId;
});
Expand Down Expand Up @@ -109,11 +108,11 @@ describe('Counter', () => {
await actor.inc();
const preUpgradeCount = await actor.get();

await pic.upgradeCanister(
await pic.upgradeCanister({
canisterId,
WASM_PATH,
IDL.encode(init({ IDL }), [countInitArg]),
);
wasm: WASM_PATH,
arg: IDL.encode(init({ IDL }), [countInitArg]),
});
const postUpgradeCount = await actor.get();

expect(preUpgradeCount).toEqual(postUpgradeCount);
Expand All @@ -123,11 +122,11 @@ describe('Counter', () => {
await actor.inc();
const preReinstallCount = await actor.get();

await pic.reinstallCode(
await pic.reinstallCode({
canisterId,
WASM_PATH,
IDL.encode(init({ IDL }), [countInitArg]),
);
wasm: WASM_PATH,
arg: IDL.encode(init({ IDL }), [countInitArg]),
});
const postReinstallCount = await actor.get();

expect(postReinstallCount).not.toEqual(preReinstallCount);
Expand Down
9 changes: 6 additions & 3 deletions examples/todo/tests/src/todo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ describe('Todo', () => {

beforeEach(async () => {
pic = await PocketIc.create();
const fixture = await pic.setupCanister<TodoService>(idlFactory, WASM_PATH);
const fixture = await pic.setupCanister<TodoService>({
idlFactory,
wasm: WASM_PATH,
});
actor = fixture.actor;
canisterId = fixture.canisterId;
});
Expand Down Expand Up @@ -210,7 +213,7 @@ describe('Todo', () => {
text: 'Learn WebAssembly',
});

await pic.upgradeCanister(canisterId, WASM_PATH);
await pic.upgradeCanister({ canisterId, wasm: WASM_PATH });

actor.setIdentity(alice);
const aliceAfterUpgradeGetResponse = await actor.get_todos();
Expand Down Expand Up @@ -245,7 +248,7 @@ describe('Todo', () => {
});

const stableMemory = await pic.getStableMemory(canisterId);
await pic.reinstallCode(canisterId, WASM_PATH);
await pic.reinstallCode({ canisterId, wasm: WASM_PATH });
await pic.setStableMemory(canisterId, stableMemory);

actor.setIdentity(alice);
Expand Down
7 changes: 3 additions & 4 deletions packages/pic/postinstall.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const COMMIT_HASH = '307d5847c1d2fe1f5e19181c7d0fcec23f4658b3';
const IS_LINUX = process.platform === 'linux';
const PLATFORM = IS_LINUX ? 'x86_64-linux' : 'x86_64-darwin';
const DOWNLOAD_HOST = 'download.dfinity.systems';
const DOWNLOAD_PATH = `/ic/${COMMIT_HASH}/openssl-static-binaries/${PLATFORM}/pocket-ic.gz`;
const VERSION = '2.0.1';
const DOWNLOAD_PATH = `https://github.com/dfinity/pocketic/releases/download/${VERSION}/pocket-ic-${PLATFORM}.gz`;

const TARGET_PATH = resolve(__dirname, 'pocket-ic');

async function downloadPicBinary() {
const response = await fetch(`https://${DOWNLOAD_HOST}${DOWNLOAD_PATH}`);
const response = await fetch(DOWNLOAD_PATH);

await pipeline(response.body, createGunzip(), createWriteStream(TARGET_PATH));

Expand Down
Loading
Loading