diff --git a/packages/pic/postinstall.mjs b/packages/pic/postinstall.mjs index 45a476d..52bca39 100644 --- a/packages/pic/postinstall.mjs +++ b/packages/pic/postinstall.mjs @@ -9,7 +9,7 @@ const __dirname = dirname(__filename); const IS_LINUX = process.platform === 'linux'; const PLATFORM = IS_LINUX ? 'x86_64-linux' : 'x86_64-darwin'; -const VERSION = '5.0.0'; +const VERSION = '6.0.0'; const DOWNLOAD_PATH = `https://github.com/dfinity/pocketic/releases/download/${VERSION}/pocket-ic-${PLATFORM}.gz`; const TARGET_PATH = resolve(__dirname, 'pocket-ic'); diff --git a/packages/pic/src/pocket-ic-client-types.ts b/packages/pic/src/pocket-ic-client-types.ts index 50c983d..d722138 100644 --- a/packages/pic/src/pocket-ic-client-types.ts +++ b/packages/pic/src/pocket-ic-client-types.ts @@ -20,6 +20,7 @@ export interface CreateInstanceRequest { bitcoin?: BitcoinSubnetConfig; system?: SystemSubnetConfig[]; application?: ApplicationSubnetConfig[]; + verifiedApplication?: VerifiedApplicationSubnetConfig[]; processingTimeoutMs?: number; nonmainnetFeatures?: boolean; } @@ -58,6 +59,10 @@ export type ApplicationSubnetConfig = SubnetConfig; export type ApplicationSubnetStateConfig = NewSubnetStateConfig; +export type VerifiedApplicationSubnetConfig = + SubnetConfig; +export type VerifiedApplicationSubnetStateConfig = NewSubnetStateConfig; + export interface NewSubnetStateConfig { type: SubnetStateType.New; } @@ -86,6 +91,7 @@ export interface EncodedCreateInstanceSubnetConfig { bitcoin?: EncodedSubnetConfig; system: EncodedSubnetConfig[]; application: EncodedSubnetConfig[]; + verified_application: EncodedSubnetConfig[]; } export interface EncodedSubnetConfig { @@ -174,6 +180,9 @@ export function encodeCreateInstanceRequest( application: encodeManySubnetConfigs( defaultOptions.application ?? [defaultApplicationSubnet], ), + verified_application: encodeManySubnetConfigs( + defaultOptions.verifiedApplication, + ), }, nonmainnet_features: defaultOptions.nonmainnetFeatures ?? false, }; diff --git a/packages/pic/src/pocket-ic-client.ts b/packages/pic/src/pocket-ic-client.ts index 8544cd4..3bbac41 100644 --- a/packages/pic/src/pocket-ic-client.ts +++ b/packages/pic/src/pocket-ic-client.ts @@ -54,7 +54,7 @@ import { decodeCanisterCallResponse, } from './pocket-ic-client-types'; -const PROCESSING_TIME_VALUE_MS = 10_000; +const PROCESSING_TIME_VALUE_MS = 30_000; export class PocketIcClient { private isInstanceDeleted = false; diff --git a/packages/pic/src/pocket-ic-server.ts b/packages/pic/src/pocket-ic-server.ts index f51d422..b818ba3 100644 --- a/packages/pic/src/pocket-ic-server.ts +++ b/packages/pic/src/pocket-ic-server.ts @@ -69,7 +69,6 @@ export class PocketIcServer { const pid = process.ppid; const picFilePrefix = `pocket_ic_${pid}`; const portFilePath = tmpFile(`${picFilePrefix}.port`); - const readyFilePath = tmpFile(`${picFilePrefix}.ready`); const serverProcess = spawn(binPath, ['--pid', pid.toString()]); @@ -95,16 +94,13 @@ export class PocketIcServer { return await poll( async () => { - const isPocketIcReady = await exists(readyFilePath); - - if (isPocketIcReady) { - const portString = await readFileAsString(portFilePath); - const port = parseInt(portString); - - return new PocketIcServer(serverProcess, port); + const portString = await readFileAsString(portFilePath); + const port = parseInt(portString); + if (isNaN(port)) { + throw new BinTimeoutError(); } - throw new BinTimeoutError(); + return new PocketIcServer(serverProcess, port); }, { intervalMs: POLL_INTERVAL_MS, timeoutMs: POLL_TIMEOUT_MS }, ); @@ -154,7 +150,7 @@ export class PocketIcServer { } const POLL_INTERVAL_MS = 20; -const POLL_TIMEOUT_MS = 5_000; +const POLL_TIMEOUT_MS = 30_000; class NullStream extends Writable { _write( diff --git a/packages/pic/src/pocket-ic-types.ts b/packages/pic/src/pocket-ic-types.ts index fc92b4f..e0959fc 100644 --- a/packages/pic/src/pocket-ic-types.ts +++ b/packages/pic/src/pocket-ic-types.ts @@ -52,6 +52,13 @@ export interface CreateInstanceOptions { */ application?: ApplicationSubnetConfig[]; + /** + * Configuration options for creating verified application subnets. + * A verified application subnet will be created for each configuration object provided. + * If no config objects are provided, no verified application subnets are setup. + */ + verifiedApplication?: VerifiedApplicationSubnetConfig[]; + /** * How long the PocketIC client should wait for a response from the server. */ @@ -163,6 +170,17 @@ export type ApplicationSubnetConfig = */ export type ApplicationSubnetStateConfig = NewSubnetStateConfig; +/** + * Options for creating a verified application subnet. + */ +export type VerifiedApplicationSubnetConfig = + SubnetConfig; + +/** + * Options for a verified application subnet's state. + */ +export type VerifiedApplicationSubnetStateConfig = NewSubnetStateConfig; + /** * Options for creating a new subnet an empty state. */