### Scenario.installSameAppForPlayers Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.installsameappforplayers.md Installs the same provided app for the provided players. The app is installed into each player's conductor sequentially. ```APIDOC ## Scenario.installSameAppForPlayers() ### Description Installs the same provided app for the provided players. The app is installed into each player's conductor sequentially, once the previous has completed installation. ### Method Promise ### Endpoint installSameAppForPlayers ### Parameters #### Path Parameters - **appWithOptions** (AppWithOptions) - Required - - **players** (Player[]) - Required - The players the apps are installed for ### Response #### Success Response (200) - **PlayerApp[]** (PlayerApp[]) - An array of player apps. ### Request Example ```json { "appWithOptions": "", "players": "" } ``` ### Response Example ```json [ "", "" ] ``` ``` -------------------------------- ### Create Players and Install Apps Separately Source: https://context7.com/holochain/tryorama/llms.txt Use `addPlayers` to create conductors and agents first, then `installAppsForPlayers` to install hApps. This is useful for generating agent keys before app installation, such as for membrane proofs. ```typescript import { runScenario, AppWithOptions } from "@holochain/tryorama"; await runScenario(async (scenario) => { // Create 2 players with conductors and agent keys const players = await scenario.addPlayers(2); // Access the pre-generated agent keys (useful for membrane proofs) const aliceAgentKey = players[0].agentPubKey; const bobAgentKey = players[1].agentPubKey; // Define apps to install (one per player) const appsWithOptions: AppWithOptions[] = [ { appBundleSource: { type: "path", value: "./my-app.happ" } }, { appBundleSource: { type: "path", value: "./my-app.happ" } }, ]; // Install apps for the players const [aliceApp, bobApp] = await scenario.installAppsForPlayers( appsWithOptions, players, ); // Or install the same app for all players const playerApps = await scenario.installSameAppForPlayers( { appBundleSource: { type: "path", value: "./my-app.happ" } }, players, ); // Use the installed apps await aliceApp.cells[0].callZome({ zome_name: "coordinator", fn_name: "init", payload: null, }); }); ``` -------------------------------- ### Install Tryorama Source: https://github.com/holochain/tryorama/blob/main/README.md Install the Tryorama package using npm. This command is typically run at the beginning of a project setup. ```sh npm install @holochain/tryorama ``` -------------------------------- ### Scenario.installAppsForPlayers Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.installappsforplayers.md Installs provided applications for specified players sequentially. ```APIDOC ## POST /scenario/installAppsForPlayers ### Description Installs the provided apps for the provided players. The number of players must be at least as high as the number of apps. Each app is installed sequentially, once the previous has completed installation. ### Method POST ### Endpoint /scenario/installAppsForPlayers ### Parameters #### Request Body - **appsWithOptions** (AppWithOptions[]) - Required - The apps with options to be installed - **players** (Player[]) - Required - The players the apps are installed for ### Request Example ```json { "appsWithOptions": [ { "appId": "my-app", "options": {} } ], "players": [ { "uuid": "player-1" } ] } ``` ### Response #### Success Response (200) - **PlayerApp[]** - An array of player apps. #### Response Example ```json [ { "appId": "my-app", "cellId": { "dna": { "id": "some-dna-hash" }, "agent": { "id": "some-agent-pubkey" } }, "callZome": "some-zome-function" } ] ``` ### Errors If any of the app options contains an agent pub key, an error is thrown, because the agent pub keys of the players will be used for app installation. ``` -------------------------------- ### installSameAppForPlayers Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.md Installs the same provided app for the provided players sequentially. ```APIDOC ## POST /api/scenario/installSameAppForPlayers ### Description Installs the same provided app for the provided players. The app is installed into each player's conductor sequentially, once the previous has completed installation. ### Method POST ### Endpoint /api/scenario/installSameAppForPlayers ### Parameters #### Request Body - **appWithOptions** (object) - Required - The app configuration to install on each player. - **players** (array) - Required - An array of players to install the app for. ``` -------------------------------- ### Example: Sending and Receiving Signals Source: https://github.com/holochain/tryorama/blob/main/README.md This example illustrates how to set up and handle signals within a Holochain scenario. It shows the registration of a signal handler and its invocation. ```typescript await scenario.addPlayerWithHapp(alice, happ, { signal: async (signal) => { t.deepEqual(signal, { foo: "bar" }); }, }); await alice.installAgentsHapps([{ agentId: "bob", happId: happ.id }], { signal: async (signal) => { t.deepEqual(signal, { baz: "qux" }); }, }); }); ``` -------------------------------- ### Conductor.startUp() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.conductor.startup.md Starts the conductor and establishes a web socket connection to the Admin API. ```APIDOC ## Conductor.startUp() ### Description Start the conductor and establish a web socket connection to the Admin API. ### Method Promise ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (void) Returns a Promise that resolves when the conductor has started and the connection is established. #### Response Example N/A ``` -------------------------------- ### Example: Create and Read Entry with 2 Conductors Source: https://github.com/holochain/tryorama/blob/main/README.md This example demonstrates creating and reading an entry within a network of two Holochain conductors. It is part of a larger scenario test. ```typescript await scenario.addPlayerWithHapp(alice, happ, { signal: alice.onSignal }); await scenario.addPlayerWithHapp(bob, happ, { signal: bob.onSignal }); const [alice_zome_caller, bob_zome_caller] = await scenario.callZomes(alice, bob, [ { instanceId: "my_happ", zomeName: "my_zome", fnName: "create_entry", payload: "hello world", }, ]); const result = await alice_zome_caller("my_zome", "get_entry", {}); t.deepEqual(result, "hello world"); const result2 = await bob_zome_caller("my_zome", "get_entry", {}); t.deepEqual(result2, "hello world"); }); ``` -------------------------------- ### installAppsForPlayers Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.md Installs the provided apps for the provided players sequentially. ```APIDOC ## POST /api/scenario/installAppsForPlayers ### Description Installs the provided apps for the provided players. The number of players must be at least as high as the number of apps. Each app is installed sequentially, once the previous has completed installation. ### Method POST ### Endpoint /api/scenario/installAppsForPlayers ### Parameters #### Request Body - **appsWithOptions** (array) - Required - An array of app configurations to install. - **players** (array) - Required - An array of players to install the apps for. ### Errors If any of the app options contains an agent pub key, an error is thrown, because the agent pub keys of the players will be used for app installation. ``` -------------------------------- ### Conductor.installApp Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.conductor.installapp.md Installs an application into the conductor. ```APIDOC ## Conductor.installApp() ### Description Install an application into the conductor. ### Method POST ### Endpoint /conductor/installApp ### Parameters #### Request Body - **appWithOptions** (AppWithOptions) - Required - The application configuration and options to install. ### Request Example ```json { "appWithOptions": { "appId": "your-app-id", "dnaPath": "/path/to/your/dna.dna", "properties": { "some_property": "some_value" } } } ``` ### Response #### Success Response (200) - **appInfo** (AppInfo) - An object containing information about the installed application, including its cells and conductor handle. #### Response Example ```json { "installedAppId": "some-installed-app-id", "cellIds": [ "cell-id-1", "cell-id-2" ] } ``` ``` -------------------------------- ### ConductorOptions.startup Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.conductoroptions.startup.md Controls whether the conductor should start up automatically after creation. ```APIDOC ## ConductorOptions.startup property ### Description Start up conductor after creation. ### Method N/A (Property) ### Endpoint N/A (Property) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **startup** (boolean) - Optional - If true, the conductor will start up automatically after creation. ### Request Example ```json { "startup": true } ``` ### Response #### Success Response (200) N/A (This is a configuration property, not an endpoint with a direct response) #### Response Example N/A ``` -------------------------------- ### Example: Curried Function for Zome Caller Source: https://github.com/holochain/tryorama/blob/main/README.md This example shows how to create a curried function to simplify calling zomes. This can make test code more readable by pre-setting common parameters. ```typescript const get_zome_caller = (player: Player, zome_name: string, instance_id?: string) => async (fn_name: string, payload: any) => player.callZome({ fnName: fn_name, payload, zomeName: zome_name, instanceId: instance_id }); ``` -------------------------------- ### Conductor.installAgentsApps Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.conductor.installagentsapps.md Installs an app for multiple agents into the conductor. ```APIDOC ## Conductor.installAgentsApps() ### Description Install an app for multiple agents into the conductor. ### Method POST ### Endpoint /api/v1/conductor/installAgentsApps ### Parameters #### Request Body - **options** (AgentsAppsOptions) - Required - Configuration options for installing apps for agents. ### Request Example ```json { "options": { "agents": [ { "agentId": "agent1", "appId": "app1" }, { "agentId": "agent2", "appId": "app2" } ] } } ``` ### Response #### Success Response (200) - **AppInfo[]** (Array of AppInfo) - An array of AppInfo objects, each containing details about the installed application for an agent. #### Response Example ```json [ { "installedAppId": "app1-agent1", "cellId": ["agent1", "app1", "hash1"], "roles": ["role1"] }, { "installedAppId": "app2-agent2", "cellId": ["agent2", "app2", "hash2"], "roles": ["role2"] } ] ``` ``` -------------------------------- ### Scenario.addPlayersWithApps() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.addplayerswithapps.md Creates and adds multiple players to the scenario, with an app installed for each player. ```APIDOC ## Scenario.addPlayersWithApps() ### Description Create and add multiple players to the scenario, with an app installed for each player. ### Method POST ### Endpoint /scenario/addPlayersWithApps ### Parameters #### Request Body - **appsWithOptions** (AppWithOptions[]) - Required - An array with an app for each player. ### Response #### Success Response (200) - **PlayerApp[]** - All created player apps. ### Request Example ```json { "appsWithOptions": [ { "appId": "your-app-id-1", "playerOptions": { "name": "player1" } }, { "appId": "your-app-id-2", "playerOptions": { "name": "player2" } } ] } ``` ### Response Example ```json [ { "name": "player1", "cellId": "cell-id-1" }, { "name": "player2", "cellId": "cell-id-2" } ] ``` ``` -------------------------------- ### addPlayerWithApp Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.md Creates and adds a single player with an app installed to the scenario. ```APIDOC ## POST /api/scenario/addPlayerWithApp ### Description Create and add a single player with an app installed to the scenario. This should not be called multiple times in parallel. Instead use `addPlayersWithApps` or `addPlayersWithSameApp`. ### Method POST ### Endpoint /api/scenario/addPlayerWithApp ### Parameters #### Request Body - **appWithOptions** (object) - Required - The app configuration to install for the player. ``` -------------------------------- ### Scenario.addPlayersWithSameApp Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.addplayerswithsameapp.md Creates and adds multiple players to the scenario, installing the same app for each. Conductors are created sequentially. ```APIDOC ## POST /scenario/addPlayersWithSameApp ### Description Create and add multiple players to the scenario, with the same app installed for each player. Each conductor is created sequentially, once the previous has completed startup. ### Method POST ### Endpoint /scenario/addPlayersWithSameApp ### Parameters #### Request Body - **appWithOptions** (AppWithOptions) - Required - Configuration for the application to be installed. - **amount** (number) - Required - The number of players to add. ### Request Example ```json { "appWithOptions": { "sourcePath": "path/to/your/app", "uiPort": 8080 }, "amount": 3 } ``` ### Response #### Success Response (200) - **players** (PlayerApp[]) - A list of all created player apps. ``` -------------------------------- ### Scenario.addPlayerWithApp() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.addplayerwithapp.md Creates and adds a single player with an app installed to the scenario. It is recommended to use `addPlayersWithApps` or `addPlayersWithSameApp` for multiple players. ```APIDOC ## Scenario.addPlayerWithApp() ### Description Create and add a single player with an app installed to the scenario. This should not be called multiple times in parallel. Instead use `addPlayersWithApps` or `addPlayersWithSameApp`. ### Method POST ### Endpoint /scenario/addPlayerWithApp ### Parameters #### Request Body - **appWithOptions** (AppWithOptions) - Required - Description for appWithOptions ### Request Example ```json { "appWithOptions": { "appId": "your-app-id", "ப்பூர்": "path/to/your/app.zip" } } ``` ### Response #### Success Response (200) - **playerApp** (PlayerApp) - A player with the installed app. #### Response Example ```json { "playerApp": { "cellId": "some-cell-id", "agentId": "some-agent-id" } } ``` ``` -------------------------------- ### addPlayersWithSameApp Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.md Creates and adds multiple players to the scenario, with the same app installed for each player. ```APIDOC ## POST /api/scenario/addPlayersWithSameApp ### Description Create and add multiple players to the scenario, with the same app installed for each player. Each conductor is created sequentially, once the previous has completed startup. ### Method POST ### Endpoint /api/scenario/addPlayersWithSameApp ### Parameters #### Request Body - **appWithOptions** (object) - Required - The app configuration to install on each player. - **amount** (number) - Required - The number of players to create. ``` -------------------------------- ### AppOptions Interface Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.appoptions.md This interface defines the optional parameters that can be provided when installing a hApp using Tryorama. These options allow for customization of the hApp's behavior and network settings during testing. ```APIDOC ## AppOptions Interface ### Description Optional arguments when installing a hApp. ### Interface Signature ```typescript export interface AppOptions ``` ### Properties #### agentPubKey - **Type**: AgentPubKey - **Description**: (Optional) The public key of the agent. #### installedAppId - **Type**: string - **Description**: (Optional) App ID to override the app manifest's app name. #### networkConfig - **Type**: NetworkConfig - **Description**: (Optional) Network config for the player. #### networkSeed - **Type**: string - **Description**: (Optional) A network seed to override the hApps' network seed. #### rolesSettings - **Type**: RoleSettingsMap - **Description**: (Optional) Role specific settings or modifiers that will override any settings in the hApp's dna manifest(s). #### signalHandler - **Type**: SignalCb - **Description**: (Optional) A signal handler for the conductor. ``` -------------------------------- ### createConductor Function Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.md Creates a conductor by starting a sandbox conductor via the Holochain CLI. ```APIDOC ## createConductor Function ### Description The function to create a conductor. It starts a sandbox conductor via the Holochain CLI. ### Method N/A (Function definition) ### Endpoint N/A (Function definition) ### Parameters - **signalingServerUrl** (string) - The URL of the signaling server. - **options** (object) - Optional configuration options for the conductor. ``` -------------------------------- ### Define CreateConductorOptions Type Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.createconductoroptions.md This type is used to define options for creating a conductor, specifically picking bootstrapServerUrl, timeout, and label from ConductorOptions. No additional setup is required beyond this type definition. ```typescript export type CreateConductorOptions = Pick; ``` -------------------------------- ### getZomeCaller Function Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.md Gets a shorthand function to call a cell's zome. ```APIDOC ## getZomeCaller Function ### Description Get a shorthand function to call a cell's zome. ### Method N/A (Function definition) ### Endpoint N/A (Function definition) ### Parameters - **cell** (object) - The cell object. - **zomeName** (string) - The name of the zome. ``` -------------------------------- ### Scenario.noDpki Property Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.nodpki.md The `noDpki` property is a boolean flag that can be set on a scenario to indicate whether to disable the default DPKI (Distributed Public Key Infrastructure) setup for the scenario. This is useful for specific testing scenarios where custom DPKI configurations or no DPKI are required. ```APIDOC ## Scenario.noDpki Property ### Description A boolean flag to disable the default DPKI setup for the scenario. ### Type `boolean` ### Example ```typescript const scenario = new Scenario({ // ... other scenario options noDpki: true }); ``` ``` -------------------------------- ### runLocalServices() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.runlocalservices.md Spawns bootstrap and signalling servers to enable peer discovery and connections between peers. ```APIDOC ## runLocalServices() ### Description Spawn bootstrap and signalling server to enable peer discovery and connections between peers. ### Method N/A (This is a function call, not a REST endpoint) ### Endpoint N/A ### Parameters This function does not accept any parameters. ### Request Example ```javascript // Example usage: const { servicesProcess, bootstrapServerUrl, signalingServerUrl } = await runLocalServices(); console.log('Bootstrap Server URL:', bootstrapServerUrl.toString()); console.log('Signaling Server URL:', signalingServerUrl.toString()); // To stop the services later: // servicesProcess.kill(); ``` ### Response #### Success Response Returns a Promise that resolves to an object containing: - **servicesProcess** (ChildProcessWithoutNullStreams): The process object for the spawned services. - **bootstrapServerUrl** (URL): The URL of the bootstrap server. - **signalingServerUrl** (URL): The URL of the signalling server. #### Response Example ```json { "servicesProcess": { /* ChildProcessWithoutNullStreams object */ }, "bootstrapServerUrl": "http://localhost:2888", "signalingServerUrl": "ws://localhost:9000" } ``` ``` -------------------------------- ### Initialize and Configure a Holochain Scenario Source: https://context7.com/holochain/tryorama/llms.txt Instantiate a `Scenario` object to manage Holochain conductors and players. Configure network settings and add players with applications. ```typescript import { Scenario } from "@holochain/tryorama"; // Create a scenario with optional timeout configuration const scenario = new Scenario({ timeout: 60000 }); // Add a single player with an app const alice = await scenario.addPlayerWithApp({ appBundleSource: { type: "path", value: "./workdir/my-app.happ" }, options: { networkSeed: "test-network-123", installedAppId: "my-app", }, }); // Access cells by index or by role name const cellByIndex = alice.cells[0]; const cellByRole = alice.namedCells.get("my_role"); // Add multiple players with different apps const [bob, carol] = await scenario.addPlayersWithApps([ { appBundleSource: { type: "path", value: "./app1.happ" } }, { appBundleSource: { type: "path", value: "./app2.happ" } }, ]); // Add multiple players with the same app const [player1, player2, player3] = await scenario.addPlayersWithSameApp( { appBundleSource: { type: "path", value: "./my-app.happ" } }, 3, // number of players ); // Share all agent info between conductors (speeds up peer discovery) await scenario.shareAllAgents(); // Clean up when done await scenario.cleanUp(); ``` -------------------------------- ### ScenarioOptions Interface Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenariooptions.md Configuration options for creating a Tryorama scenario. ```APIDOC ## ScenarioOptions Interface ### Description Options when creating a scenario. ### Properties #### Query Parameters - **disableLocalServices** (boolean) - Optional - Disables local services. - **timeout** (number) - Optional - Sets the timeout for the scenario. ``` -------------------------------- ### getPlayerStorageArc Function Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.getplayerstoragearc.md A utility function to get the storage arc for a given player and dna hash. ```APIDOC ## getPlayerStorageArc() ### Description A utility function to get the storage arc for a given player and dna hash. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (Promise) - **DhtArc** - The storage DhtArc for the player and DNA hash. #### Response Example ```json { "example": "DhtArc object" } ``` ``` -------------------------------- ### AgentsAppsOptions Type Definition Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.agentsappsoptions.md Defines the structure for specifying applications and agents, with an optional network seed for DNA installation. References AppWithOptions type. ```typescript export type AgentsAppsOptions = { agentsApps: AppWithOptions[]; networkSeed?: string; installedAppId?: InstalledAppId; }; ``` -------------------------------- ### enableAndGetAgentApp Function Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.md Enables an app and builds an agent app object. ```APIDOC ## enableAndGetAgentApp Function ### Description Enable an app and build an agent app object. ### Method N/A (Function definition) ### Endpoint N/A (Function definition) ### Parameters - **adminWs** (WebSocket) - The WebSocket connection to the admin interface. - **appWs** (WebSocket) - The WebSocket connection to the app interface. - **appInfo** (object) - Information about the app. ``` -------------------------------- ### ScenarioOptions.disableLocalServices Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenariooptions.disablelocalservices.md The `disableLocalServices` property is a boolean that, when set to true, prevents local services from being started during a scenario. This is useful for testing scenarios that rely on external or mocked services. ```APIDOC ## ScenarioOptions.disableLocalServices ### Description This property allows you to disable the automatic startup of local services when running a scenario. Set to `true` to prevent local services from being initialized. ### Method Not applicable (property of an options object) ### Endpoint Not applicable (property of an options object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **disableLocalServices** (boolean) - Optional - If `true`, local services will not be started. ### Request Example ```json { "disableLocalServices": true } ``` ### Response This property is part of the configuration options and does not directly produce a response. Its effect is on the test environment setup. ``` -------------------------------- ### Run a Holochain Test Scenario Source: https://context7.com/holochain/tryorama/llms.txt Use `runScenario` to set up a test environment, add players with hApps, interact with zome functions, and synchronize the DHT. Ensures automatic cleanup of conductors. ```typescript import { runScenario, dhtSync } from "@holochain/tryorama"; import { EntryHash } from "@holochain/client"; await runScenario(async (scenario) => { // Add two players with the same hApp const [alice, bob] = await scenario.addPlayersWithApps([ { appBundleSource: { type: "path", value: "./workdir/my-app.happ" } }, { appBundleSource: { type: "path", value: "./workdir/my-app.happ" } }, ]); // Alice creates an entry const content = "Hello Holochain"; const entryHash = await alice.cells[0].callZome({ zome_name: "my_zome", fn_name: "create_entry", payload: content, }); // Wait for DHT synchronization between Alice and Bob await dhtSync([alice, bob], alice.cells[0].cell_id[0]); // Bob reads the entry created by Alice const readContent = await bob.cells[0].callZome({ zome_name: "my_zome", fn_name: "read_entry", payload: entryHash, }); console.log(readContent); // "Hello Holochain" }); ``` -------------------------------- ### AppWithOptions.options Property Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.appwithoptions.options.md The 'options' property of AppWithOptions allows you to specify configuration details for your Holochain application when running tests with Tryorama. This is an optional field. ```APIDOC ## AppWithOptions.options Property ### Description An optional property to configure application-specific settings. ### Method N/A (Property access) ### Endpoint N/A (Property access within an object) ### Parameters N/A ### Request Body N/A ### Response #### Success Response (200) - **options** (AppOptions) - Optional. Configuration options for the application. ``` -------------------------------- ### NetworkConfig.transportTimeoutS Property Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.networkconfig.transporttimeouts.md The network timeout for transport operations. This controls how long Holochain will spend waiting for connections to be established and other low-level network operations. If you are writing tests that start and stop conductors, you may want to set this to a lower value to avoid waiting for connections to conductors that are no longer running. ```APIDOC ## NetworkConfig.transportTimeoutS Property ### Description The network timeout for transport operations. This controls how long Holochain will spend waiting for connections to be established and other low-level network operations. If you are writing tests that start and stop conductors, you may want to set this to a lower value to avoid waiting for connections to conductors that are no longer running. ### Default Value 15 ### Signature ```typescript transportTimeoutS?: number; ``` ``` -------------------------------- ### AppOptions.networkConfig Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.appoptions.networkconfig.md The network configuration for a player. This property is optional. ```APIDOC ## AppOptions.networkConfig ### Description Network config for the player. ### Method N/A (Property) ### Endpoint N/A (Property) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **networkConfig** (NetworkConfig) - Optional - The network configuration object for the player. #### Response Example N/A ``` -------------------------------- ### Scenario.addPlayers() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.addplayers.md Creates conductors with agents and adds them to the scenario. Conductors are created sequentially. ```APIDOC ## Scenario.addPlayers() ### Description Create conductors with agents and add them to the scenario. The specified number of conductors is created and one agent is generated on each conductor. Each conductor is created sequentially, once the previous has completed startup. ### Method `addPlayers` ### Endpoint N/A (This is a method call within a scenario) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **amount** (number) - Required - The number of players to be created. - **networkConfig** (NetworkConfig) - Optional - Optional NetworkConfig. ### Request Example ```typescript // Example usage within a scenario await scenario.addPlayers(2, { network: 'sim2h', dna: dnaPath }); ``` ### Response #### Success Response (200) - **Player[]** - An array of Players. #### Response Example ```json [ { "name": "player1", "dna": "your-dna-hash", "agentId": "agent-id-1" }, { "name": "player2", "dna": "your-dna-hash", "agentId": "agent-id-2" } ] ``` ``` -------------------------------- ### NetworkConfig.initiateJitterMs Property Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.networkconfig.initiatejitterms.md The initiateJitterMs property allows you to configure a jitter value to be added to the initiateIntervalMs. This helps in distributing the roles of gossip initiator and acceptor among peers, preventing any single peer from consistently taking on these roles. Setting this value to 0 disables jitter. The default value is recommended. ```APIDOC ## NetworkConfig.initiateJitterMs ### Description A jitter value to add to the `initiateIntervalMs`. This is used to avoid peers always being the gossip initiator or acceptor. It can be set to `0` to disable jitter, but it is recommended to leave this at the default value. ### Property Type `number` ### Default Value `30` ### Usage Example ```typescript // Assuming 'networkConfig' is an instance of NetworkConfig networkConfig.initiateJitterMs = 50; // Set jitter to 50ms ``` ### Notes - Jitter helps in load balancing gossip initiation. - Setting to 0 disables jitter. - Default value is 30ms. ``` -------------------------------- ### addPlayers Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.md Creates conductors with agents and adds them to the scenario sequentially. ```APIDOC ## POST /api/scenario/addPlayers ### Description Create conductors with agents and add them to the scenario. The specified number of conductors is created and one agent is generated on each conductor. Each conductor is created sequentially, once the previous has completed startup. ### Method POST ### Endpoint /api/scenario/addPlayers ### Parameters #### Request Body - **amount** (number) - Required - The number of conductors to create. - **networkConfig** (object) - Optional - Configuration for the network. ``` -------------------------------- ### AppWithOptions Interface Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.appwithoptions.md The AppWithOptions interface defines the structure for configuring an application with options. ```APIDOC ## AppWithOptions Interface ### Description The `AppWithOptions` interface is used to configure an application with specific options, including its bundle source and optional labels or advanced settings. ### Properties #### `appBundleSource` - **Type**: `AppBundleSource` - **Description**: Specifies the source of the application's bundle. #### `label` (Optional) - **Type**: `string` - **Description**: An optional label for the application. #### `options` (Optional) - **Type**: `AppOptions` - **Description**: Optional advanced configuration options for the application. ``` -------------------------------- ### Conductor.create() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.conductor.create.md Factory method to create a new conductor instance. This instance is configured but not yet running. ```APIDOC ## Conductor.create() ### Description Factory to create a conductor. ### Method Static method ### Endpoint N/A (Static method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (Promise) - **Conductor** (Conductor) - A configured instance of a conductor, not yet running. #### Response Example ```json // Example response is a Promise that resolves to a Conductor object ``` ### Signature ```typescript static create(signalingServerUrl: URL, options?: CreateConductorOptions): Promise; ``` ### Parameters Details - **signalingServerUrl** (URL) - Required - The URL of the signaling server. - **options** (CreateConductorOptions) - Optional - Additional options for conductor creation. ``` -------------------------------- ### Player Interface Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.player.md Details about the Player interface, including its properties. ```APIDOC ## Player Interface ### Description A player consists of a [Conductor](./tryorama.conductor.md) and an agent pub key. ### Properties - **agentPubKey** (AgentPubKey) - Description: The agent's public key. - **conductor** (Conductor) - Description: The conductor associated with the player. ``` -------------------------------- ### dhtSync() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.dhtsync.md Waits until all conductors' DhtOps have been integrated and are identical for a given DNA. ```APIDOC ## dhtSync() ### Description A utility function to wait until all conductors' DhtOps have been integrated, and are identical for a given DNA. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) Resolves when all agents' DHT states match. #### Response Example N/A ### Parameters - **players** (PlayerApp[]) - Required - Array of players. - **dnaHash** (DnaHash) - Required - DNA hash to compare integrated DhtOps from. - **intervalMs** (number) - Optional - Interval to pause between comparisons (defaults to 500 milliseconds). - **timeoutMs** (number) - Optional - A timeout for the delay (defaults to 60000 milliseconds). ``` -------------------------------- ### Scenario Constructor Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario._constructor_.md The Scenario constructor initializes a new Scenario instance. It accepts an optional options object to configure request timeouts. ```APIDOC ## Scenario.(constructor) ### Description Scenario constructor. ### Method constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```json { "options": { "adminTimeout": 10000, "appTimeout": 10000 } } ``` ### Response #### Success Response (200) N/A (Constructor) #### Response Example N/A (Constructor) ``` -------------------------------- ### enableAndGetAgentApp Function Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.enableandgetagentapp.md Enables a Holochain app and returns an agent app object, providing necessary websocket connections and app information. ```APIDOC ## enableAndGetAgentApp() ### Description Enable an app and build an agent app object. ### Method N/A (This is a function call, not a REST endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "adminWs": "AdminWebsocket object", "appWs": "AppWebsocket object", "appInfo": "AppInfo object" } ``` ### Response #### Success Response (AgentApp) - **agentApp** (AgentApp) - An app agent object. #### Response Example ```json { "agentApp": "AgentApp object" } ``` ``` -------------------------------- ### AgentApp Interface Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.agentapp.md Details about the AgentApp interface and its properties. ```APIDOC ## AgentApp Interface ### Description Provides direct access to cells of an app and the agent key. ### Signature ```typescript export interface AgentApp ``` ### Properties #### agentPubKey (AgentPubKey) - Description: The public key of the agent. #### appId (string) - Description: The ID of the application. #### cells (CallableCell[]) - Description: An array of callable cells associated with the agent. #### namedCells (Map) - Description: A map of named cells, keyed by RoleName. ``` -------------------------------- ### NetworkConfig Interface Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.networkconfig.md Defines the configuration options for the network layer in Tryorama tests. ```APIDOC ## NetworkConfig Interface ### Description Defines the configuration options for the network layer in Tryorama tests. This interface allows for fine-tuning of network behavior, particularly related to gossip protocols and transport timeouts. ### Properties #### initiateIntervalMs (number) - Optional The interval in milliseconds between initiating gossip rounds. This controls how often gossip will attempt to find a peer to gossip with. It can be set as low as desired, but is still limited by `minInitiateIntervalMs`. A low value will result in gossip initiating in bursts. *Default: 100* #### initiateJitterMs (number) - Optional A jitter value in milliseconds to add to the `initiateIntervalMs`. This is used to prevent peers from always being the gossip initiator or acceptor. Setting this to `0` disables jitter, but it is recommended to leave it at the default value. *Default: 30* #### minInitiateIntervalMs (number) - Optional The minimum amount of time in milliseconds that must pass before a gossip round can be initiated by a given peer. This acts as a rate-limiting mechanism for incoming gossip and must also be respected when initiating. *Default: 100* #### roundTimeoutMs (number) - Optional The timeout in milliseconds for a round of gossip. This is the maximum duration a gossip round is allowed to take. *Default: 10000* #### targetArcFactor (number) - Optional The target arc factor for gossip. This controls the range of DHT locations that the peer will aim to store and serve during gossip. For leacher nodes that do not contribute to gossip, set this to 0. Values other than 1 or 0 will be rejected. *Default: 1* #### transportTimeoutS (number) - Optional The network timeout in seconds for transport operations. This controls how long Holochain will wait for connections to be established and other low-level network operations. For tests involving starting and stopping conductors, setting this to a lower value can prevent waiting for connections to no longer running conductors. *Default: 15* ``` -------------------------------- ### Utility Functions for Testing Holochain Apps Source: https://context7.com/holochain/tryorama/llms.txt Tryorama provides utility functions for common testing tasks. Use `pause` to halt execution, `areDhtsSynced` to check DHT synchronization, `getPlayerStorageArc` to inspect storage, and `integratedOpsCount` to wait for a specific number of operations. ```typescript import { runScenario, pause, areDhtsSynced, getPlayerStorageArc, integratedOpsCount, addAllAgentsToAllConductors, runLocalServices, stopLocalServices, } from "@holochain/tryorama"; await runScenario(async (scenario) => { const [alice, bob] = await scenario.addPlayersWithSameApp( { appBundleSource: { type: "path", value: "./my-app.happ" } }, 2, ); // Pause execution for a specified time await pause(1000); // Wait 1 second // Check if DHTs are synced without waiting const dnaHash = alice.cells[0].cell_id[0]; const synced = await areDhtsSynced([alice, bob], dnaHash); console.log("DHTs synced:", synced); // Get a player's storage arc const storageArc = await getPlayerStorageArc(alice, dnaHash); console.log("Alice storage arc:", storageArc); // Wait for specific number of integrated ops const cellId = alice.cells[0].cell_id; await integratedOpsCount( alice, cellId, 5, // targetIntegratedOpsCount 500, // intervalMs 30000, // timeoutMs ); // Share agent info between conductors (speeds up discovery) await addAllAgentsToAllConductors(scenario.conductors); }); // Manual service management (usually handled by Scenario) const { servicesProcess, bootstrapServerUrl, signalingServerUrl } = await runLocalServices(); console.log("Bootstrap:", bootstrapServerUrl.href); console.log("Signaling:", signalingServerUrl.href); await stopLocalServices(servicesProcess); ``` -------------------------------- ### ConductorOptions Interface Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.conductoroptions.md Defines the configuration options for a Holochain conductor. ```APIDOC ## ConductorOptions Interface ### Description Defines the configuration options for a Holochain conductor. ### Properties #### bootstrapServerUrl - **bootstrapServerUrl** (URL) - Optional - A bootstrap server URL for peers to discover each other. #### label - **label** (string) - Optional - Label to identify this conductor in logs. #### startup - **startup** (boolean) - Optional - Start up conductor after creation. #### timeout - **timeout** (number) - Optional - Timeout for requests to Admin and App API. ``` -------------------------------- ### Conductor.connectAppWs() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.conductor.connectappws.md Connects a web socket to the App API using the provided authentication token and port. ```APIDOC ## Conductor.connectAppWs() ### Description Connect a web socket to the App API. ### Method POST ### Endpoint /connectAppWs ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **token** (AppAuthenticationToken) - Required - A token to authenticate the connection. - **port** (number) - Required - The websocket port to connect to. ### Request Example ```json { "token": "your_auth_token", "port": 1234 } ``` ### Response #### Success Response (200) - **websocket** (AppWebsocket) - An app websocket. #### Response Example ```json { "websocket": "your_app_websocket_instance" } ``` ``` -------------------------------- ### PlayerApp Interface Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.playerapp.md Details of the PlayerApp interface, including its extended interfaces and properties. ```APIDOC ## PlayerApp Interface ### Description Represents an application instance for a player within the Tryorama testing framework. It extends both `Player` and `AgentApp` interfaces, combining their functionalities. ### Properties #### `appWs` - **Type**: `AppWebsocket` - **Description**: WebSocket connection to the application. ### Extends - [Player](./tryorama.player.md) - [AgentApp](./tryorama.agentapp.md) ``` -------------------------------- ### Scenario.cleanUp() Source: https://github.com/holochain/tryorama/blob/main/docs/tryorama.scenario.cleanup.md Shut down and delete all conductors in the scenario. ```APIDOC ## Scenario.cleanUp() ### Description Shut down and delete all conductors in the scenario. ### Method N/A (This is a method call on an object instance) ### Endpoint N/A (This is a method call on an object instance) ### Parameters None ### Request Example ```javascript // Assuming 'scenario' is an instance of Scenario await scenario.cleanUp(); ``` ### Response #### Success Response (void) This method does not return a value upon successful completion. #### Response Example N/A (void return type) ```