Skip to main content

LocalTestEnvironment

Midnight.js API Reference v2.0.2


Midnight.js API Reference / @midnight-ntwrk/midnight-js-testing / LocalTestEnvironment

Class: LocalTestEnvironment

Test environment for local development using Docker containers Manages containers for node, indexer and proof server components

Extends​

Constructors​

Constructor​

new LocalTestEnvironment(logger): LocalTestEnvironment

Creates a new LocalTestEnvironment instance

Parameters​

logger​

Logger

Logger instance for recording operations

Returns​

LocalTestEnvironment

Overrides​

TestEnvironment.constructor

Properties​

dockerEnv​

dockerEnv: StartedDockerComposeEnvironment


genesisMintWalletSeed​

readonly genesisMintWalletSeed: string[]


MAX_NUMBER_OF_WALLETS​

readonly static MAX_NUMBER_OF_WALLETS: 4 = 4

Methods​

getMidnightWalletProvider()​

getMidnightWalletProvider(): Promise<MidnightWalletProvider>

Starts a single wallet instance.

Returns​

Promise<MidnightWalletProvider>

A promise that resolves to the started wallet

Throws​

If no wallet could be started

Inherited from​

TestEnvironment.getMidnightWalletProvider


shutdown()​

shutdown(saveWalletState?): Promise<void>

Shuts down the test environment, closing walletProviders and stopping containers

Parameters​

saveWalletState?​

boolean

Returns​

Promise<void>

Overrides​

TestEnvironment.shutdown


start()​

start(maybeProofServerContainer?): Promise<EnvironmentConfiguration>

Starts the test environment by creating and configuring Docker containers

Parameters​

maybeProofServerContainer?​

ProofServerContainer

Optional proof server container

Returns​

Promise<EnvironmentConfiguration>

The environment configuration

Throws​

If trying to inject proof server container when starting new environment

Overrides​

TestEnvironment.start


startMidnightWalletProviders()​

startMidnightWalletProviders(amount, seeds): Promise<MidnightWalletProvider[]>

Creates and starts the specified number of wallet providers

Parameters​

amount​

number = 1

seeds​

undefined | string[]

Returns​

Promise<MidnightWalletProvider[]>

A promise that resolves to an array of started wallets

Throws​

If requested amount exceeds maximum supported walletProviders

Overrides​

TestEnvironment.startMidnightWalletProviders


startWithInjectedEnvironment()​

startWithInjectedEnvironment(dockerEnv, ports): Promise<EnvironmentConfiguration>

Instead of starting the test environment by building the docker containers from the default configuration files in this package, start the test environment by passing an existing StartedDockerComposeEnvironment along with the ports for the containers in the environment.

Parameters​

dockerEnv​

StartedDockerComposeEnvironment

A started docker compose environment

ports​

ComponentPortsConfiguration

The ports of the containers in the given environment

Returns​

Promise<EnvironmentConfiguration>

The environment configuration