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β
Propertiesβ
dockerEnvβ
dockerEnv:
StartedDockerComposeEnvironment
genesisMintWalletSeedβ
readonlygenesisMintWalletSeed:string[]
MAX_NUMBER_OF_WALLETSβ
readonlystaticMAX_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β
start()β
start(
maybeProofServerContainer?):Promise<EnvironmentConfiguration>
Starts the test environment by creating and configuring Docker containers
Parametersβ
maybeProofServerContainer?β
Optional proof server container
Returnsβ
Promise<EnvironmentConfiguration>
The environment configuration
Throwsβ
If trying to inject proof server container when starting new environment
Overridesβ
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β
The ports of the containers in the given environment
Returnsβ
Promise<EnvironmentConfiguration>
The environment configuration