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>
105 lines
3.1 KiB
YAML
105 lines
3.1 KiB
YAML
# End-To-End Tests: CI for starting a full ETH private network, deploying AVS and running tests.
|
|
#
|
|
# Overview:
|
|
# 1. Start kurtosis network
|
|
# 2. Deploy AVS contracts
|
|
# 3. Start DataHaven node
|
|
# 4. Run E2E tests
|
|
|
|
name: E2E - Kurtosis Deploy and Verify
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
image-tag:
|
|
description: "The tag of the docker image"
|
|
required: true
|
|
type: string
|
|
workflow_call:
|
|
inputs:
|
|
image-tag:
|
|
description: "The tag of the docker image"
|
|
required: true
|
|
type: string
|
|
|
|
env:
|
|
FOUNDRY_PROFILE: ci
|
|
LOG_LEVEL: debug
|
|
|
|
jobs:
|
|
kurtosis:
|
|
runs-on: ubuntu-latest
|
|
name: E2E Tests with Kurtosis Ethereum Network
|
|
defaults:
|
|
run:
|
|
working-directory: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: d
|
|
- uses: oven-sh/setup-bun@v2
|
|
- name: Install Foundry
|
|
uses: foundry-rs/foundry-toolchain@v1
|
|
- name: Install Kurtosis
|
|
run: |
|
|
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
|
|
sudo apt update
|
|
sudo apt install kurtosis-cli
|
|
kurtosis analytics disable
|
|
- run: kurtosis version
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-bun-
|
|
|
|
- name: Cache Foundry libraries
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ../contracts/lib
|
|
key: ${{ runner.os }}-foundry-libs-${{ hashFiles('.gitmodules') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-foundry-libs-
|
|
|
|
- name: Cache Foundry build artifacts
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: |
|
|
../contracts/out
|
|
../contracts/cache
|
|
key: ${{ runner.os }}-foundry-build-${{ hashFiles('contracts/foundry.toml', 'contracts/**/*.sol') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-foundry-build-
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Download snowbridge binary
|
|
run: |
|
|
docker create --name temp moonsonglabs/snowbridge-relay:latest
|
|
mkdir -p tmp/bin
|
|
docker cp temp:/usr/local/bin/snowbridge-relay tmp/bin/
|
|
chmod +x tmp/bin/snowbridge-relay
|
|
docker rm temp
|
|
- run: tmp/bin/snowbridge-relay --help
|
|
- run: docker pull ${{ inputs.image-tag }}
|
|
- run: |
|
|
docker tag ${{ inputs.image-tag }} moonsonglabs/datahaven:local
|
|
docker images
|
|
- run: bun install
|
|
- run: bun test:e2e
|
|
# Try to collect all docker logs and upload it
|
|
- name: Collect docker logs
|
|
if: always()
|
|
run: |
|
|
mkdir ./logs
|
|
for name in `docker ps -a --format '{{.Names}}'`; do docker logs $name > ./logs/$name.log 2>&1; done
|
|
- name: Upload logs to GitHub
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: logs
|
|
path: logs/
|
|
retention-days: 1
|