LocalTestEnvironment
@midnight-ntwrk/testkit-js v3.1.0
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
getEnvironmentConfiguration()
getEnvironmentConfiguration():
EnvironmentConfiguration
Returns the configuration for the testnet environment services.
Returns
Object containing URLs for testnet services:
- indexer: GraphQL API endpoint for the indexer
- indexerWS: WebSocket endpoint for the indexer
- node: RPC endpoint for the blockchain node
- faucet: API endpoint for requesting test tokens
- proofServer: URL for the proof generation server
Overrides
TestEnvironment.getEnvironmentConfiguration
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?
string[] | undefined
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