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
15 changes: 15 additions & 0 deletions .github/workflows/e2e-test-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
- name: Setup PNPM
uses: dfinity/ci-tools/actions/setup-pnpm@afeee4fbdc0683a88ec5a74ed7f59a2ce0e833ad # main

- name: Download PocketIC binary
run: node packages/pic/postinstall.mjs

- name: Test
run: pnpm test:pic

Expand All @@ -31,6 +34,12 @@ jobs:
- name: Setup PNPM
uses: dfinity/ci-tools/actions/setup-pnpm@afeee4fbdc0683a88ec5a74ed7f59a2ce0e833ad # main

- name: Download PocketIC binary
run: node packages/pic/postinstall.mjs

- name: Extract NNS state
run: tar -xvf examples/nns_proxy/tests/state/nns_state.tar.xz -C examples/nns_proxy/tests/state

- name: Setup DFX
uses: dfinity/setup-dfx@e50c04f104ee4285ec010f10609483cf41e4d365 # main
with:
Expand Down Expand Up @@ -64,6 +73,12 @@ jobs:
shell: bash
run: bun i --frozen-lockfile

- name: Download PocketIC binary
run: node packages/pic/postinstall.mjs

- name: Extract NNS state
run: tar -xvf examples/nns_proxy/tests/state/nns_state.tar.xz -C examples/nns_proxy/tests/state

- name: Setup DFX
uses: dfinity/setup-dfx@e50c04f104ee4285ec010f10609483cf41e4d365 # main
with:
Expand Down
19 changes: 9 additions & 10 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

DFINITY takes the security of our software products seriously, which includes all source code repositories under the [DFINITY](https://github.com/dfinity) GitHub organization.

> [!IMPORTANT]
> [DFINITY Foundation](https://dfinity.org) has a [Internet Computer (ICP) Bug Bounty program](https://dfinity.org/bug-bounty/) that rewards researchers for finding and reporting vulnerabilities in the Internet Computer. Please check the scope and eligibility criteria outlined in the policy to see if the vulnerability you found qualifies for a reward.
> [!IMPORTANT] > [DFINITY Foundation](https://dfinity.org) has a [Internet Computer (ICP) Bug Bounty program](https://dfinity.org/bug-bounty/) that rewards researchers for finding and reporting vulnerabilities in the Internet Computer. Please check the scope and eligibility criteria outlined in the policy to see if the vulnerability you found qualifies for a reward.

## How to report a vulnerability

Expand All @@ -12,21 +11,21 @@ If you believe you have found a security vulnerability in any of our repositorie

1. **Do not disclose the vulnerability publicly.** Public disclosure could be exploited by attackers before it can be fixed.
2. **Send an email to securitybugs@dfinity.org.** Please include the following information in your email:
* A description of the vulnerability
* Steps to reproduce the vulnerability
* Risk rating of the vulnerability
* Any other relevant information
- A description of the vulnerability
- Steps to reproduce the vulnerability
- Risk rating of the vulnerability
- Any other relevant information

We will respond to your report within 72 hours and work with you to fix the vulnerability as soon as possible.

### Security Updates

We are committed to fixing security vulnerabilities in a timely manner. Once a security vulnerability is reported, we will:

* Investigate the report and confirm the vulnerability.
* Develop a fix for the vulnerability.
* Release a new version of the project that includes the fix.
* Announce the security fix in the project's release notes.
- Investigate the report and confirm the vulnerability.
- Develop a fix for the vulnerability.
- Release a new version of the project that includes the fix.
- Announce the security fix in the project's release notes.

## Preferred Language

Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/clock/tests/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

module.exports = async function (): Promise<void> {
const pic = await PocketIcServer.start({
Expand Down
2 changes: 1 addition & 1 deletion examples/clock/tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clock-tests",
"devDependencies": {
"@dfinity/pic": "workspace:*"
"pic-js-mops": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/clock/tests/src/clock.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve } from 'node:path';
import { Principal } from '@dfinity/principal';
import { Actor, generateRandomIdentity, PocketIc } from '@dfinity/pic';
import { Actor, generateRandomIdentity, PocketIc } from 'pic-js-mops';
import { Identity } from '@dfinity/agent';

import { _SERVICE, idlFactory } from '../../declarations/clock.did';
Expand Down
2 changes: 1 addition & 1 deletion examples/clock/tests/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

declare global {
declare var __PIC__: PocketIcServer;
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/tests/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { GlobalSetupContext } from 'vitest/node';
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

let pic: PocketIcServer | undefined;

Expand Down
2 changes: 1 addition & 1 deletion examples/counter/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "counter-tests",
"type": "module",
"devDependencies": {
"@dfinity/pic": "workspace:*"
"pic-js-mops": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/counter/tests/src/counter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve } from 'node:path';
import { Principal } from '@dfinity/principal';
import { Actor, PocketIc } from '@dfinity/pic';
import { Actor, PocketIc } from 'pic-js-mops';
import { IDL } from '@dfinity/candid';
import { describe, beforeEach, afterEach, it, expect, inject } from 'vitest';

Expand Down
2 changes: 1 addition & 1 deletion examples/google_search/tests/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

module.exports = async function (): Promise<void> {
const pic = await PocketIcServer.start({
Expand Down
2 changes: 1 addition & 1 deletion examples/google_search/tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "google-search-tests",
"devDependencies": {
"@dfinity/pic": "workspace:*"
"pic-js-mops": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/google_search/tests/src/google-search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve } from 'node:path';
import { Principal } from '@dfinity/principal';
import { PocketIc, DeferredActor } from '@dfinity/pic';
import { PocketIc, DeferredActor } from 'pic-js-mops';

import { _SERVICE, idlFactory } from '../../declarations/google_search.did';

Expand Down
2 changes: 1 addition & 1 deletion examples/google_search/tests/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

declare global {
declare var __PIC__: PocketIcServer;
Expand Down
2 changes: 1 addition & 1 deletion examples/multicanister/tests/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

module.exports = async function (): Promise<void> {
const pic = await PocketIcServer.start();
Expand Down
2 changes: 1 addition & 1 deletion examples/multicanister/tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "multicanister-tests",
"devDependencies": {
"@dfinity/pic": "workspace:*"
"pic-js-mops": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/multicanister/tests/src/multicanister.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve } from 'path';
import { Actor, PocketIc, SubnetStateType } from '@dfinity/pic';
import { Actor, PocketIc, SubnetStateType } from 'pic-js-mops';
import { IDL } from '@dfinity/candid';

import {
Expand Down
2 changes: 1 addition & 1 deletion examples/multicanister/tests/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

declare global {
declare var __PIC__: PocketIcServer;
Expand Down
2 changes: 1 addition & 1 deletion examples/nns_proxy/tests/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

module.exports = async function (): Promise<void> {
const pic = await PocketIcServer.start();
Expand Down
2 changes: 1 addition & 1 deletion examples/nns_proxy/tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nns-proxy-tests",
"devDependencies": {
"@dfinity/pic": "workspace:*"
"pic-js-mops": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/nns_proxy/tests/src/nns-proxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
PocketIc,
SubnetStateType,
generateRandomIdentity,
} from '@dfinity/pic';
} from 'pic-js-mops';
import { _SERVICE, idlFactory } from '../../declarations/nns_proxy.did';
import { Governance } from './support/governance';

Expand Down
2 changes: 1 addition & 1 deletion examples/nns_proxy/tests/src/support/candid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface UpdateElectedReplicaVersionsPayload {

export function encodeUpdateElectedReplicaVersionsPayload(
arg: UpdateElectedReplicaVersionsPayload,
): ArrayBuffer {
): Uint8Array {
return IDL.encode([UpdateElectedReplicaVersionsPayload], [arg]);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/nns_proxy/tests/src/support/governance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Actor, PocketIc } from '@dfinity/pic';
import { Actor, PocketIc } from 'pic-js-mops';
import { AnonymousIdentity, Identity } from '@dfinity/agent';
import { Principal } from '@dfinity/principal';
import { createHash, randomBytes } from 'node:crypto';
Expand Down
2 changes: 1 addition & 1 deletion examples/nns_proxy/tests/src/support/ledger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AnonymousIdentity, Identity } from '@dfinity/agent';
import { Principal } from '@dfinity/principal';
import { Actor, PocketIc } from '@dfinity/pic';
import { Actor, PocketIc } from 'pic-js-mops';
import {
_SERVICE as LedgerService,
SubAccount,
Expand Down
2 changes: 1 addition & 1 deletion examples/nns_proxy/tests/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

declare global {
declare var __PIC__: PocketIcServer;
Expand Down
2 changes: 1 addition & 1 deletion examples/todo/tests/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

module.exports = async function (): Promise<void> {
const pic = await PocketIcServer.start();
Expand Down
2 changes: 1 addition & 1 deletion examples/todo/tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "todo-tests",
"devDependencies": {
"@dfinity/pic": "workspace:*"
"pic-js-mops": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/todo/tests/src/todo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'node:path';
import { Principal } from '@dfinity/principal';
import { AnonymousIdentity } from '@dfinity/agent';
import { Actor, PocketIc, createIdentity } from '@dfinity/pic';
import { Actor, PocketIc, createIdentity } from 'pic-js-mops';
import { _SERVICE, idlFactory } from '../../declarations/todo.did';

const WASM_PATH = resolve(
Expand Down
2 changes: 1 addition & 1 deletion examples/todo/tests/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PocketIcServer } from '@dfinity/pic';
import { PocketIcServer } from 'pic-js-mops';

declare global {
declare var __PIC__: PocketIcServer;
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
"postinstall": "tar -xvf examples/nns_proxy/tests/state/nns_state.tar.xz -C examples/nns_proxy/tests/state"
},
"devDependencies": {
"@dfinity/agent": "^2.3.0",
"@dfinity/candid": "^2.3.0",
"@dfinity/identity": "^2.3.0",
"@dfinity/principal": "^2.3.0",
"@dfinity/agent": "^3.4.3",
"@dfinity/candid": "^3.4.3",
"@dfinity/identity": "^3.4.3",
"@dfinity/principal": "^3.4.3",
"@tsconfig/node22": "^22.0.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.13.10",
"@types/node": "22.13.10",
"bip39": "^3.1.0",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
"prettier": "3.4.1",
"ts-jest": "^29.2.6",
"ts-node": "^10.9.2",
"typescript": "^5.8.2",
"typescript": "5.8.2",
"vitest": "^2.1.9"
},
"pnpm": {
Expand Down
3 changes: 3 additions & 0 deletions packages/pic/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const config: Config = {
globalSetup: '<rootDir>/tests/global-setup.ts',
globalTeardown: '<rootDir>/tests/global-teardown.ts',
testTimeout: 60_000,
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
};

export default config;
4 changes: 3 additions & 1 deletion packages/pic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
],
"files": [
"dist",
"src"
"src",
"postinstall.mjs"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"postinstall": "node ./postinstall.mjs",
"prepublishOnly": "tsc -p ./tsconfig.json"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/pic/src/pocket-ic-server-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export interface StartServerOptions {
*/
ttl?: number;


/**
* Path to the PocketIC binary.
*/
Expand Down
11 changes: 8 additions & 3 deletions packages/pic/src/pocket-ic-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ export class PocketIcServer {
const picFilePrefix = `pocket_ic_${pid}`;
const portFilePath = tmpFile(`${picFilePrefix}.port`);

const serverProcess = spawn(binPath, ['--port-file', portFilePath, '--ttl', options.ttl ? options.ttl.toString() : '60']);
const serverProcess = spawn(binPath, [
'--port-file',
portFilePath,
'--ttl',
options.ttl ? options.ttl.toString() : '60',
]);

if (options.showRuntimeLogs) {
serverProcess.stdout.pipe(process.stdout);
Expand Down Expand Up @@ -133,8 +138,8 @@ export class PocketIcServer {
this.serverProcess.kill();

const picFilePrefix = `pocket_ic_${process.ppid}`;
rmSync(tmpFile(`${picFilePrefix}.port`), {force: true});
rmSync(tmpFile(`${picFilePrefix}.ready`), {force: true});
rmSync(tmpFile(`${picFilePrefix}.port`), { force: true });
rmSync(tmpFile(`${picFilePrefix}.ready`), { force: true });
});
}

Expand Down
Loading
Loading