mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
This PR significantly refactors and improves the end-to-end testing framework and infrastructure. The primary focus was on simplifying the test suites, improving reliability through better resource management, and hardening the relayer infrastructure. All E2E tests are now passing on the CI and demonstrate consistent reliability when run locally. ### Key Changes #### 1. E2E Test Suite Refactor & Cleanup * **Simplified Test Logic**: Heavily refactored the core test suites (`native-token-transfer.test.ts`, `rewards-message.test.ts`, and `validator-set-update.test.ts`). The new implementation is much cleaner, utilizing shared helpers to reduce boilerplate. * **Utility Consolidation**: Removed redundant utility files (`storage.ts`, `rewards-helpers.ts`) and simplified `events.ts`. Event waiting now uses `rxjs` for Substrate and native `viem` watchers for Ethereum, which is more robust and easier to maintain. * **Better Connector Management**: Unified the creation and cleanup of test clients in `ConnectorFactory`. It now handles the lifecycle of WebSocket connections more gracefully, including clearing the `socketClientCache` to prevent reconnection noise during teardown. #### 2. Infrastructure & Stability * **Relayer Relaunch Policy**: Added a restart policy for Snowbridge relayer containers. They are now configured with `--restart on-failure:5`, ensuring that relayers automatically relaunch if they crash during the sensitive initialization phase. * **WebSocket Integration**: * Updated the `ConnectorFactory` to prefer **WebSockets** for the Ethereum public client, which is essential for efficient, event-heavy E2E testing. * Enhanced `launchKurtosisNetwork` to correctly identify and register the Execution Layer's WebSocket endpoint from Kurtosis. * **Disabled Contract Injection**: This PR temporarily disables the automatic injection of contracts into the genesis state by default. * *Reason*: I encountered issues generating a valid `state-diff.json` for the latest contract versions. Even after applying several workarounds, the injected state remained unstable. As a result, I've reverted to manual contract deployment during the launch sequence for better reliability for now. #### 3. Documentation & Maintenance * Removed obsolete documentation (`event-utilities-guide.md`) that no longer reflects the simplified event-handling API. * Cleaned up `test/launcher/validators.ts` and moved logic into more appropriate helpers. --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
159 lines
5.4 KiB
YAML
159 lines
5.4 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
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: read
|
|
|
|
env:
|
|
FOUNDRY_PROFILE: ci
|
|
LOG_LEVEL: debug
|
|
DOCKER_HOST: unix:///run/user/1020/podman/podman.sock
|
|
KURTOSIS_CORE_IMAGE: ghcr.io/stiiifff/kurtosis/kurtosis-core
|
|
KURTOSIS_ENGINE_IMAGE: ghcr.io/stiiifff/kurtosis/kurtosis-engine
|
|
KURTOSIS_VERSION: 1.11.1
|
|
INJECT_CONTRACTS: false
|
|
|
|
jobs:
|
|
kurtosis:
|
|
runs-on:
|
|
group: DH-Testing
|
|
name: E2E Tests with Kurtosis Ethereum Network
|
|
defaults:
|
|
run:
|
|
working-directory: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 0
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version-file: test/.bun-version
|
|
- name: Install Foundry
|
|
uses: foundry-rs/foundry-toolchain@v1
|
|
- name: Pull Kurtosis images
|
|
run: |
|
|
docker pull ${{ env.KURTOSIS_CORE_IMAGE }}:${{ env.KURTOSIS_VERSION }}
|
|
docker pull ${{ env.KURTOSIS_ENGINE_IMAGE }}:${{ env.KURTOSIS_VERSION }}
|
|
- name: Install Kurtosis
|
|
run: |
|
|
# Install Kurtosis locally without sudo
|
|
# SHA256 checksum for patched kurtosis binary (stiiifff fork v1.11.99)
|
|
KURTOSIS_SHA256="5e88e98c1b255362268b4c385cdb6bbba7e82b333c4b2c05bc0bff7de0560b2a"
|
|
|
|
if ! command -v kurtosis &> /dev/null; then
|
|
echo "Installing Kurtosis $KURTOSIS_VERSION locally"
|
|
mkdir -p ~/.local/bin
|
|
# wget -q -O kurtosis-cli.tar.gz "https://github.com/kurtosis-tech/kurtosis-cli-release-artifacts/releases/download/${KURTOSIS_VERSION}/kurtosis-cli_${KURTOSIS_VERSION}_linux_amd64.tar.gz"
|
|
# tar -xzf kurtosis-cli.tar.gz -C ~/.local/bin
|
|
# rm kurtosis-cli.tar.gz
|
|
# For now, we use a patched version of Kurtosis CLI & Engine that supports Podman properly
|
|
wget -q -O ~/.local/bin/kurtosis https://github.com/stiiifff/kurtosis/releases/download/1.11.99/kurtosis
|
|
|
|
# Verify checksum before making executable
|
|
echo "Verifying kurtosis checksum..."
|
|
echo "${KURTOSIS_SHA256} $HOME/.local/bin/kurtosis" | sha256sum -c -
|
|
|
|
chmod +x ~/.local/bin/kurtosis
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
else
|
|
echo "Kurtosis is already installed: $(kurtosis version)"
|
|
fi
|
|
kurtosis analytics disable
|
|
kurtosis version
|
|
- name: Configure Kurtosis cluster = podman
|
|
run: |
|
|
# Get the config path from Kurtosis itself (portable)
|
|
CFG_PATH="$(kurtosis config path)"
|
|
mkdir -p "$(dirname "$CFG_PATH")"
|
|
# Create/update config with a podman cluster entry
|
|
cat > "$CFG_PATH" <<'YML'
|
|
config-version: 6
|
|
should-send-metrics: true
|
|
kurtosis-clusters:
|
|
docker:
|
|
type: "docker"
|
|
podman:
|
|
type: "podman"
|
|
YML
|
|
kurtosis cluster set podman
|
|
kurtosis cluster get
|
|
- name: Start Kurtosis engine with Podman
|
|
run: |
|
|
kurtosis engine stop
|
|
kurtosis clean
|
|
kurtosis engine start
|
|
kurtosis engine status
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
|
|
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:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Download Snowbridge relay binary
|
|
run: |
|
|
docker create --name temp datahavenxyz/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 -fv temp
|
|
tmp/bin/snowbridge-relay --help
|
|
|
|
- name: Pull DataHaven node image
|
|
run: |
|
|
docker pull ghcr.io/datahaven-xyz/datahaven/datahaven:${{ inputs.image-tag }}
|
|
docker tag ghcr.io/datahaven-xyz/datahaven/datahaven:${{ inputs.image-tag }} datahavenxyz/datahaven:local
|
|
|
|
- run: bun install
|
|
- name: Run E2E tests
|
|
run: bun test:e2e
|
|
|
|
- name: Delete volumes not used
|
|
if: always()
|
|
run: podman system prune --volumes -f
|