mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
## Implement E2E Testing Framework with Isolated Networks ### Summary Refactors the existing E2E testing infrastructure to provide isolated test environments with parallel execution support. Each test suite now runs in its own network namespace, preventing resource conflicts. ### Key Changes - **New Testing Framework** (`test/framework/`): Base classes for test lifecycle management with automatic setup/teardown - **Launcher Module** (`test/launcher/`): Extracted network orchestration logic from CLI handlers for reusability - **Parallel Execution**: Added `test-parallel.ts` script with concurrency limits to prevent resource exhaustion - **Test Isolation**: Each suite gets unique network IDs (format: `suiteName-timestamp`) and Docker networks - **Improved Test Organization**: Migrated tests to new framework, deprecated old test structure ### Test Improvements - Added 4 new test suites demonstrating framework usage. : - `contracts.test.ts` - Smart contract deployment/interaction - `datahaven-substrate.test.ts` - Substrate API operations - `cross-chain.test.ts` - Snowbridge cross-chain messaging - `ethereum-basic.test.ts` - Ethereum network operations > [!WARNING] The test suites themselves are bad and shouldn't be consider examples of good tests. They were AI generated just to test the concurrency of test runners ### Documentation - Added comprehensive framework overview (`E2E_FRAMEWORK_OVERVIEW.md`) - Updated README with parallel testing commands - Added test patterns and best practices ### Breaking Changes - Old test suites moved to `e2e - DEPRECATED/` directory - Test execution now requires extending `BaseTestSuite` class ### Testing Run tests with: `bun test:e2e` or `bun test:e2e:parallel` (with concurrency limits) ### TODO - [ ] Implement good test examples. - [ ] Implement useful test utils (like waiting for an event to show up in DataHaven or Ethereum). - [ ] Enforce tests with CI (currently cannot be done due to intermittent error when sending a transaction with PAPI). --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
54 lines
2 KiB
TypeScript
54 lines
2 KiB
TypeScript
import { setDataHavenParameters as setDataHavenParametersScript } from "scripts/set-datahaven-parameters";
|
|
import { logger } from "utils";
|
|
import type { ParameterCollection } from "utils/parameters";
|
|
import type { LaunchedNetwork } from "./types/launchedNetwork";
|
|
|
|
/**
|
|
* Configuration options for setting DataHaven runtime parameters.
|
|
*/
|
|
export interface ParametersOptions {
|
|
launchedNetwork: LaunchedNetwork;
|
|
collection: ParameterCollection;
|
|
}
|
|
|
|
/**
|
|
* Sets DataHaven runtime parameters from a parameter collection.
|
|
*
|
|
* This function updates various runtime parameters on the DataHaven chain:
|
|
* - Bridge configuration parameters
|
|
* - Network timing parameters
|
|
* - Validator configuration
|
|
* - Fee structures
|
|
* - Other protocol-specific settings
|
|
*
|
|
* The parameters are collected throughout the deployment process and
|
|
* applied in a single transaction to minimize gas costs and ensure
|
|
* consistency.
|
|
*
|
|
* @param options - Configuration options for setting parameters
|
|
* @param options.launchedNetwork - The launched network instance containing connection details
|
|
* @param options.collection - The parameter collection containing all parameters to set
|
|
*
|
|
* @throws {Error} If the parameter file generation fails
|
|
* @throws {Error} If the RPC connection cannot be established
|
|
* @throws {Error} If the parameter update transaction fails
|
|
*/
|
|
export const setDataHavenParameters = async (options: ParametersOptions): Promise<void> => {
|
|
logger.info("⚙️ Setting DataHaven runtime parameters...");
|
|
|
|
const { launchedNetwork, collection } = options;
|
|
|
|
// Generate the parameters file from the collection
|
|
const parametersFilePath = await collection.generateParametersFile();
|
|
|
|
// Get the WebSocket RPC URL from the launched network
|
|
const rpcUrl = `ws://127.0.0.1:${launchedNetwork.getPublicWsPort()}`;
|
|
|
|
// Execute the parameter update
|
|
await setDataHavenParametersScript({
|
|
rpcUrl,
|
|
parametersFilePath
|
|
});
|
|
|
|
logger.success("DataHaven parameters set successfully");
|
|
};
|