datahaven/test/utils
Ahmad Kaouk 41788d56bb
test: refactor e2e tests (#365)
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>
2025-12-24 13:31:40 +01:00
..
blockscout.ts test: Add E2E Tests (#36) 2025-04-14 16:22:43 -03:00
constants.ts test: refactor e2e tests (#365) 2025-12-24 13:31:40 +01:00
contracts.ts test: Update validator set e2e test (#126) 2025-10-02 11:23:40 +00:00
docker.ts test: port ethereum tests from moonbeam (#278) 2025-11-22 10:02:05 +01:00
events.ts test: refactor e2e tests (#365) 2025-12-24 13:31:40 +01:00
index.ts test: port ethereum tests from moonbeam (#278) 2025-11-22 10:02:05 +01:00
input.ts fix: 🚨 Add error in TS for missing awaits (#81) 2025-05-19 22:28:43 +00:00
kurtosis.ts test: port ethereum tests from moonbeam (#278) 2025-11-22 10:02:05 +01:00
logger.ts feat: Add Polkadot API support to CLI and e2e testing infra (#68) 2025-05-13 03:03:21 +00:00
papi.ts test: refactor e2e tests (#365) 2025-12-24 13:31:40 +01:00
parameters.ts perf: Batch runtime parameter updates to speed up E2E setup (#368) 2025-12-22 15:57:32 +01:00
parser.ts fix: 🔨 Fix Kurtosis & Snowbridge relay configs for Fulu fork (#356) 2025-12-18 15:50:09 +01:00
rpc.ts test: Add E2E Tests (#36) 2025-04-14 16:22:43 -03:00
service-mappings.ts test: port ethereum tests from moonbeam (#278) 2025-11-22 10:02:05 +01:00
shell.ts Fix: command cli deploy contracts (#319) 2025-11-27 15:06:04 +01:00
types.ts perf: Batch runtime parameter updates to speed up E2E setup (#368) 2025-12-22 15:57:32 +01:00
validators.ts test: refactor e2e tests (#365) 2025-12-24 13:31:40 +01:00
viem.ts fix: 🚨 Add error in TS for missing awaits (#81) 2025-05-19 22:28:43 +00:00
waits.ts feat: 🚀 Add deploy command to CLI (#87) 2025-06-12 10:24:03 +02:00