@holochain/tryorama
Version:
Toolset to manage Holochain conductors and facilitate running test scenarios
144 lines (143 loc) • 4.12 kB
TypeScript
/// <reference types="node" />
import { AdminWebsocket, AppBundleSource, AppWebsocket, AttachAppInterfaceRequest, AppAuthenticationToken } from "@holochain/client";
import { URL } from "node:url";
import { AgentsAppsOptions, AppOptions, IConductor } from "../types.js";
/**
* The network type the conductor should use to communicate with peers.
*
* @public
*/
export declare enum NetworkType {
WebRtc = "webrtc",
Mem = "mem"
}
/**
* @public
*/
export interface ConductorOptions {
/**
* Start up conductor after creation.
*
* @defaultValue true
*/
startup?: boolean;
/**
* The network type the conductor should use.
*
* @defaultValue quic
*/
networkType?: NetworkType;
/**
* A bootstrap server URL for peers to discover each other.
*/
bootstrapServerUrl?: URL;
/**
* Disable DPKI in the conductor instance.
*
* unstable
*/
/**
* Set a DPKI network seed in the conductor instance.
*
* Defaults to "deepkey-test".
*
* unstable
*/
/**
* Timeout for requests to Admin and App API.
*/
timeout?: number;
}
/**
* Options for using the conductor factory.
*
* @public
*/
export type CreateConductorOptions = Pick<ConductorOptions, "bootstrapServerUrl" | "networkType" | "timeout">;
/**
* The function to create a conductor. It starts a sandbox conductor via the
* Holochain CLI.
*
* @returns A conductor instance.
*
* @public
*/
export declare const createConductor: (signalingServerUrl: URL, options?: ConductorOptions) => Promise<Conductor>;
/**
* A class to manage a conductor running on localhost.
*
* @public
*/
export declare class Conductor implements IConductor {
private conductorProcess;
private conductorDir;
private adminApiUrl;
private _adminWs;
private _appWs;
private readonly timeout;
private constructor();
/**
* Factory to create a conductor.
*
* @returns A configured instance of a conductor, not yet running.
*/
static create(signalingServerUrl: URL, options?: CreateConductorOptions): Promise<Conductor>;
/**
* Start the conductor and establish a web socket connection to the Admin
* API.
*/
startUp(): Promise<void>;
/**
* Close Admin and App API connections and kill the conductor process.
*/
shutDown(): Promise<number | null>;
private connectAdminWs;
/**
* Attach a web socket to the App API.
*
* @param request - Specify a port for the web socket (optional).
* @returns The app interface port.
*/
attachAppInterface(request?: AttachAppInterfaceRequest): Promise<number>;
/**
* Connect a web socket to the App API,
*
* @param token - A token to authenticate the connection.
* @param port - The websocket port to connect to.
* @returns An app websocket.
*/
connectAppWs(token: AppAuthenticationToken, port: number): Promise<AppWebsocket>;
/**
* Get the path of the directory that contains all files and folders of the
* conductor.
*
* @returns The conductor's temporary directory.
*/
getTmpDirectory(): string;
/**
* Get all Admin API methods.
*
* @returns The Admin API web socket.
*/
adminWs(): AdminWebsocket;
/**
* Install an application into the conductor.
*
* @param appBundleSource - The bundle or path to the bundle.
* @param options - {@link AppOptions} for the hApp bundle (optional).
* @returns An agent app with cells and conductor handle.
*/
installApp(appBundleSource: AppBundleSource, options?: AppOptions): Promise<import("@holochain/client").AppInfo>;
/**
* Install an app for multiple agents into the conductor.
*/
installAgentsApps(options: AgentsAppsOptions): Promise<import("@holochain/client").AppInfo[]>;
}
/**
* Run the `hc` command to delete all conductor data.
*
* @returns A promise that resolves when the command is complete.
*
* @public
*/
export declare const cleanAllConductors: () => Promise<void>;