Skip to content

Commit

Permalink
test: picjs v0.8.1 (#508)
Browse files Browse the repository at this point in the history
* test: picjs v0.8.0

Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>

* build: picjs beta

Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>

* build: pic v0.8.1

Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>

---------

Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
  • Loading branch information
peterpeterparker committed Apr 27, 2024
1 parent 37a8552 commit 3969004
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 24 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -55,7 +55,7 @@
"@dfinity/identity-secp256k1": "^1.2.0",
"@dfinity/ledger-icrc": "^2.2.1",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@hadronous/pic": "^0.7.0",
"@hadronous/pic": "^0.8.1",
"@ltd/j-toml": "^1.38.0",
"@rollup/plugin-inject": "^5.0.5",
"@sveltejs/adapter-static": "^3.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/tests/satellite.auth.spec.ts
Expand Up @@ -8,7 +8,7 @@ import { Ed25519KeyIdentity } from '@dfinity/identity';
import { toNullable } from '@dfinity/utils';
import { PocketIc, type Actor } from '@hadronous/pic';
import { toArray } from '@junobuild/utils';
import { afterAll, beforeAll, describe, expect } from 'vitest';
import {afterAll, beforeAll, describe, expect, inject} from 'vitest';
import { ADMIN_ERROR_MSG } from './constants/satellite-tests.constants';
import { WASM_PATH, satelliteInitArgs } from './utils/satellite-tests.utils';

Expand All @@ -19,7 +19,7 @@ describe('Satellite authentication', () => {
const controller = Ed25519KeyIdentity.generate();

beforeAll(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const { actor: c } = await pic.setupCanister<SatelliteActor>({
idlFactory: idlFactorSatellite,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/satellite.custom-domains.spec.ts
Expand Up @@ -4,7 +4,7 @@ import { AnonymousIdentity } from '@dfinity/agent';
import { Ed25519KeyIdentity } from '@dfinity/identity';
import { toNullable } from '@dfinity/utils';
import { PocketIc, type Actor } from '@hadronous/pic';
import { afterAll, beforeAll, describe, expect } from 'vitest';
import {afterAll, beforeAll, describe, expect, inject} from 'vitest';
import { ADMIN_ERROR_MSG } from './constants/satellite-tests.constants';
import { WASM_PATH, satelliteInitArgs } from './utils/satellite-tests.utils';

Expand All @@ -15,7 +15,7 @@ describe('Satellite custom domains', () => {
const controller = Ed25519KeyIdentity.generate();

beforeAll(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const { actor: c } = await pic.setupCanister<SatelliteActor>({
idlFactory: idlFactorSatellite,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/satellite.datastore.spec.ts
Expand Up @@ -5,7 +5,7 @@ import { fromNullable, toNullable } from '@dfinity/utils';
import { PocketIc, type Actor } from '@hadronous/pic';
import { toArray } from '@junobuild/utils';
import { nanoid } from 'nanoid';
import { afterAll, beforeAll, describe, expect } from 'vitest';
import {afterAll, beforeAll, describe, expect, inject} from 'vitest';
import { WASM_PATH, satelliteInitArgs } from './utils/satellite-tests.utils';

describe.each([{ memory: { Heap: null } }, { memory: { Stable: null } }])(
Expand All @@ -19,7 +19,7 @@ describe.each([{ memory: { Heap: null } }, { memory: { Stable: null } }])(
const TEST_COLLECTION = 'test';

beforeAll(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const { actor: c } = await pic.setupCanister<SatelliteActor>({
idlFactory: idlFactorSatellite,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/satellite.playground.spec.ts
Expand Up @@ -4,7 +4,7 @@ import { Ed25519KeyIdentity } from '@dfinity/identity';
import { toNullable } from '@dfinity/utils';
import { PocketIc, type Actor } from '@hadronous/pic';
import { toArray } from '@junobuild/utils';
import { afterAll, beforeAll, beforeEach, describe } from 'vitest';
import {afterAll, beforeAll, beforeEach, describe, inject} from 'vitest';
import { WASM_PATH, satelliteInitArgs } from './utils/satellite-tests.utils';

describe.skip('Satellite playground (kind of)', () => {
Expand All @@ -14,7 +14,7 @@ describe.skip('Satellite playground (kind of)', () => {
const controller = Ed25519KeyIdentity.generate();

beforeAll(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const { actor: c } = await pic.setupCanister<SatelliteActor>({
idlFactory: idlFactorSatellite,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/satellite.spec.ts
Expand Up @@ -6,7 +6,7 @@ import { PocketIc, type Actor } from '@hadronous/pic';
import { parse } from '@ltd/j-toml';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { afterAll, beforeAll, describe, expect } from 'vitest';
import {afterAll, beforeAll, describe, expect, inject} from 'vitest';
import { ADMIN_ERROR_MSG, CONTROLLER_ERROR_MSG } from './constants/satellite-tests.constants';
import { WASM_PATH, satelliteInitArgs } from './utils/satellite-tests.utils';

Expand All @@ -17,7 +17,7 @@ describe('Satellite', () => {
const controller = Ed25519KeyIdentity.generate();

beforeAll(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const { actor: c } = await pic.setupCanister<SatelliteActor>({
idlFactory: idlFactorSatellite,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/satellite.storage.spec.ts
Expand Up @@ -8,7 +8,7 @@ import { AnonymousIdentity } from '@dfinity/agent';
import { Ed25519KeyIdentity } from '@dfinity/identity';
import { arrayBufferToUint8Array, fromNullable, toNullable } from '@dfinity/utils';
import { PocketIc, type Actor } from '@hadronous/pic';
import { afterAll, beforeAll, beforeEach, describe, expect } from 'vitest';
import {afterAll, beforeAll, beforeEach, describe, expect, inject} from 'vitest';
import { ADMIN_ERROR_MSG, CONTROLLER_ERROR_MSG } from './constants/satellite-tests.constants';
import { WASM_PATH, satelliteInitArgs } from './utils/satellite-tests.utils';

Expand All @@ -19,7 +19,7 @@ describe('Satellite storage', () => {
const controller = Ed25519KeyIdentity.generate();

beforeAll(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const { actor: c } = await pic.setupCanister<SatelliteActor>({
idlFactory: idlFactorSatellite,
Expand Down
8 changes: 4 additions & 4 deletions src/tests/satellite.upgrade.spec.ts
Expand Up @@ -6,7 +6,7 @@ import type { Principal } from '@dfinity/principal';
import { toNullable } from '@dfinity/utils';
import { PocketIc, type Actor } from '@hadronous/pic';
import { toArray } from '@junobuild/utils';
import { afterEach, beforeEach, describe, expect } from 'vitest';
import {afterEach, beforeEach, describe, expect, inject} from 'vitest';
import { WASM_PATH, downloadSatellite, satelliteInitArgs } from './utils/satellite-tests.utils';

describe('satellite upgrade', () => {
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('satellite upgrade', () => {

describe('v0.0.15 -> v0.0.16', async () => {
beforeEach(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const destination = await downloadSatellite('0.0.15');

Expand Down Expand Up @@ -155,7 +155,7 @@ describe('satellite upgrade', () => {

describe('v0.0.11 -> v0.0.16', async () => {
beforeEach(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const destination = await downloadSatellite('0.0.11');

Expand Down Expand Up @@ -206,7 +206,7 @@ describe('satellite upgrade', () => {

describe('v0.0.16 -> v0.0.16', async () => {
beforeEach(async () => {
pic = await PocketIc.create();
pic = await PocketIc.create(inject('PIC_URL'));

const { actor: c, canisterId: cId } = await pic.setupCanister<SatelliteActor>({
idlFactory: idlFactorSatellite,
Expand Down
5 changes: 5 additions & 0 deletions src/tests/types.d.ts
@@ -0,0 +1,5 @@
export declare module 'vitest' {
export interface ProvidedContext {
PIC_URL: string;
}
}
1 change: 1 addition & 0 deletions vitest.config.ts
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
globalSetup: './vitest.setup.ts',
globals: true,
watch: false,
silent: false,
Expand Down
15 changes: 15 additions & 0 deletions vitest.setup.ts
@@ -0,0 +1,15 @@
import type { GlobalSetupContext } from 'vitest/node';
import { PocketIcServer } from '@hadronous/pic';

let pic: PocketIcServer | undefined;

export async function setup(ctx: GlobalSetupContext): Promise<void> {
pic = await PocketIcServer.start();
const url = pic.getUrl();

ctx.provide('PIC_URL', url);
}

export async function teardown(): Promise<void> {
await pic?.stop();
}

0 comments on commit 3969004

Please sign in to comment.