UNPKG

@holochain/tryorama

Version:

Toolset to manage Holochain conductors and facilitate running test scenarios

95 lines (94 loc) 2.9 kB
/// <reference types="node" /> import { AppBundleSource } from "@holochain/client"; import { ChildProcessWithoutNullStreams } from "node:child_process"; import { AppOptions, IPlayer } from "../types.js"; import { Conductor } from "./conductor.js"; /** * A player tied to a {@link Conductor}. * * @public */ export interface Player extends IPlayer { conductor: Conductor; } /** * Options when creating a scenario. * * @public */ export interface ScenarioOptions { timeout?: number; } /** * An abstraction of a test scenario to write tests against Holochain hApps, * running on a local conductor. * * @public */ export declare class Scenario { private timeout; noDpki: boolean; dpkiNetworkSeed: string; networkSeed: string; serviceProcess: ChildProcessWithoutNullStreams | undefined; bootstrapServerUrl: URL | undefined; signalingServerUrl: URL | undefined; conductors: Conductor[]; /** * Scenario constructor. * * @param options - Timeout for requests to Admin and App API calls. */ constructor(options?: ScenarioOptions); /** * Create and add a conductor to the scenario. * * @returns The newly added conductor instance. */ addConductor(): Promise<Conductor>; /** * Create and add a single player with an app installed to the scenario. * * @param appBundleSource - The bundle or path to the bundle. * @param options - {@link AppOptions}. * @returns A local player instance. */ addPlayerWithApp(appBundleSource: AppBundleSource, options?: AppOptions): Promise<Player>; /** * Create and add multiple players to the scenario, with an app installed * for each player. * * @param playersApps - An array with an app for each player. * @returns All created players. */ addPlayersWithApps(playersApps: Array<{ appBundleSource: AppBundleSource; options?: AppOptions; }>): Promise<Player[]>; /** * Register all agents of all passed in conductors to each other. This skips * peer discovery through gossip and thus accelerates test runs. * * @public */ shareAllAgents(): Promise<void>; /** * Shut down all conductors in the scenario. */ shutDown(): Promise<void>; /** * Shut down and delete all conductors in the scenario. */ cleanUp(): Promise<void>; private ensureLocalServices; } /** * A wrapper function to create and run a scenario. A scenario is created * and all involved conductors are shut down and cleaned up after running. * * @param testScenario - The test to be run. * @param cleanUp - Whether to delete conductors after running. @defaultValue true * * @public */ export declare const runScenario: (testScenario: (scenario: Scenario) => Promise<void>, cleanUp?: boolean, options?: ScenarioOptions) => Promise<void>;