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>
81 lines
2.7 KiB
TypeScript
81 lines
2.7 KiB
TypeScript
import { fundValidators as fundValidatorsScript } from "scripts/fund-validators";
|
|
import { setupValidators as setupValidatorsScript } from "scripts/setup-validators";
|
|
import { updateValidatorSet as updateValidatorSetScript } from "scripts/update-validator-set";
|
|
import { logger } from "utils";
|
|
|
|
/**
|
|
* Configuration options for validator operations.
|
|
*/
|
|
export interface ValidatorOptions {
|
|
rpcUrl: string;
|
|
}
|
|
|
|
/**
|
|
* Funds validators with tokens and ETH.
|
|
*
|
|
* This function ensures validators have the necessary funds to operate by:
|
|
* - Sending ETH for gas fees
|
|
* - Sending required tokens for staking
|
|
* - Verifying balances after funding
|
|
*
|
|
* @param options - Configuration options for funding
|
|
* @param options.rpcUrl - The RPC URL of the Ethereum network
|
|
*
|
|
* @throws {Error} If funding transactions fail
|
|
* @throws {Error} If the network is unreachable
|
|
*/
|
|
export const fundValidators = async (options: ValidatorOptions): Promise<void> => {
|
|
logger.info("💰 Funding validators with tokens and ETH...");
|
|
|
|
await fundValidatorsScript({
|
|
rpcUrl: options.rpcUrl
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Registers validators in the EigenLayer protocol.
|
|
*
|
|
* This function handles the validator registration process:
|
|
* - Creates operator registrations in EigenLayer
|
|
* - Registers operators with the AVS (Actively Validated Service)
|
|
* - Sets up delegation relationships
|
|
* - Configures operator metadata
|
|
*
|
|
* @param options - Configuration options for setup
|
|
* @param options.rpcUrl - The RPC URL of the Ethereum network
|
|
*
|
|
* @throws {Error} If registration transactions fail
|
|
* @throws {Error} If validators are already registered
|
|
* @throws {Error} If required contracts are not deployed
|
|
*/
|
|
export const setupValidators = async (options: ValidatorOptions): Promise<void> => {
|
|
logger.info("📝 Registering validators in EigenLayer...");
|
|
|
|
await setupValidatorsScript({
|
|
rpcUrl: options.rpcUrl
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Updates the validator set on the Substrate chain.
|
|
*
|
|
* This function synchronizes the validator set between Ethereum and Substrate:
|
|
* - Fetches the current validator set from EigenLayer
|
|
* - Prepares validator set update transaction
|
|
* - Submits the update through the bridge
|
|
* - Waits for confirmation on the Substrate side
|
|
*
|
|
* @param options - Configuration options for the update
|
|
* @param options.rpcUrl - The RPC URL of the Ethereum network
|
|
*
|
|
* @throws {Error} If the update transaction fails
|
|
* @throws {Error} If the bridge is not initialized
|
|
* @throws {Error} If validators are not properly registered
|
|
*/
|
|
export const updateValidatorSet = async (options: ValidatorOptions): Promise<void> => {
|
|
logger.info("🔄 Updating validator set on Substrate chain...");
|
|
|
|
await updateValidatorSetScript({
|
|
rpcUrl: options.rpcUrl
|
|
});
|
|
};
|