Overview of Tryorama packages
main@holochain/tryorama.repository·main·Indexed 42 days ago
https://github.com/holochain/tryoramaA tool for running multiple Holochain conductors locally, enabling developers to simulate a network of nodes and test complex multi-node behaviors using standard JavaScript test runners. It provides a hierarchical structure of Scenarios, Players, and Conductors to manage the lifecycle of hApps and verify application behavior.
@holochain/tryorama.Tryorama is organized into three hierarchical layers:
Player represents a single participant in the simulation. It is composed of two primary parts: a Conductor (which manages the Holochain runtime and interactions) and an AgentPubKey (the unique identifier for that player).Scenario class provides an abstraction for defining and running test scenarios against Holochain hApps using local conductors.Conductor class is used to manage a single Holochain conductor running on localhost.The Scenario class is the primary abstraction for writing tests against Holochain hApps. It manages a local conductor environment, allowing you to orchestrate multiple conductors (players), install apps, and simulate network interactions.
To use it, you instantiate a Scenario and then use its methods to add conductors, install apps, and manage the lifecycle of the test environment. Always ensure you call cleanUp() or shutDown() to prevent leaking processes.
```typescript
import { Scenario } from '@holochain/tryorama';
// Example conceptual usage
const scenario = new Scenario({ /* options */ });
// ... add conductors, install apps, run tests ...
await scenario.cleanUp();
```埋transportTimeoutS property in your NetworkConfig. This reduces the time Holochain spends waiting for connections to conductors that are no longer running.Install Tryorama via npm to run multiple Holochain conductors locally for testing. This allows you to simulate a network of nodes and use your preferred test runner and assertion library to verify Holochain application behavior.
npm install @holochain/tryoramaTryorama provides tools for managing Holochain Conductors. The library exports its core functionality through several modules:
conductor: Core conductor management logic.conductor-helpers: Helper functions for interacting with conductors.scenario: Tools for defining and running test scenarios.types: TypeScript type definitions used throughout the library.util: General utility functions.A CallableCell is an extension of a standard Holochain cell (ClonedCell or ProvisionedCell) that includes a specialized callZome method.
When you use getCallableCell, the returned object wraps the standard AppWebsocket.callZome method. It automatically injects the correct cell_id from the cell into the request payload, ensuring that the call is routed to the correct location on the conductor. This abstraction allows developers to treat cells as objects with methods rather than raw data structures requiring manual ID management.
// Internal mechanism used by getCallableCell
const callZome = async <T>(request: CellZomeCallRequest, timeout?: number) => {
const callZomeResponse = await appWs.callZome({
...request,
cell_id: cell.cell_id,
payload: request.payload ?? null,
}, timeout);
return callZomeResponse;
};You can control the verbosity of Tryorama logs using the TRYORAMA_LOG_LEVEL environment variable.
Supported levels:
debugverboseinfo (default)To run a test with a specific log level, prepend the command with the environment variable.
TRYORAMA_LOG_LEVEL=debug node test.js