Skip to content

Commit df090e0

Browse files
committed
refactor(test): migrate e2e suites from mocha to vitest (7 packages)
Migrates e2e test suites in tron-sdk, starknet-sdk, cosmos-sdk, rebalancer, aleo-sdk, svm-sdk, radix-sdk from mocha/chai to vitest. Drops mocha-steps from the catalog entirely (zero consumers remain). ## Packages migrated - tron-sdk: 1 integration test (TronWallet) - starknet-sdk: 7 e2e tests + shell runner (env-var test selection preserved) - cosmos-sdk: 4 e2e tests + global setup (testcontainers-driven cosmos localnet) - rebalancer: 9 e2e tests + harness helpers (TestHelpers.ts, ForkIndexer.test.ts). Unit config unchanged — separate vitest.e2e.config.ts - aleo-sdk: 7 e2e tests + global setup + warp-artifact-test-suite helper - svm-sdk: 10 e2e tests + global setup. Narrowed unit vitest.config.ts include to exclude e2e files for defense in depth - radix-sdk: 5 e2e tests + global setup ## Patterns applied - Created vitest.e2e.config.ts per package with `globalSetup`, `fileParallelism: false`, 300s timeouts - Mocha `before()`/`after()` lifecycle hooks that started/stopped containers → vitest `globalSetup` default-exported setup function returning a teardown. Runs once before all e2e worker processes. - `describe('X', function () { this.timeout(N); ... })` → arrow functions; timeout sourced from config - `.to.be.rejectedWith(msg)` → `.rejects.toThrow(msg)` where present - Removed all `chai.use(chaiAsPromised)` + corresponding imports - Dropped mocha/`@types/mocha`/mocha-steps/ts-node from affected packages' devDeps - Removed now-orphan chai/chai-as-promised/`@types/chai`/`@types/chai-as-promised` from tron-sdk, svm-sdk, radix-sdk (no remaining imports) ## mocha-steps shim 2 files used mocha-steps' `step(name, fn)` (aleo-sdk's 6_hook_artifacts and svm-sdk's cross-collateral-token). `step()` registers a test but skips remaining siblings on failure. Inlined a 7-line shim per describe block that preserves this semantic via a local `__stepFailed` flag + `ctx.skip()`. In aleo-sdk's case each of 3 sibling describes gets its own shim so a failure in one group doesn't skip later groups. ## Global setup + worker process boundary Vitest's `globalSetup` runs in a separate process from test workers, so module-level state doesn't flow through. In radix-sdk the setup previously exported `DEPLOYED_TEST_CHAIN_METADATA` as a module-level const populated by `before()`. Replaced with `getDeployedTestChainMetadata()` that reads addresses back from env vars (`RADIX_E2E_PACKAGE_ADDRESS`, `RADIX_E2E_XRD_ADDRESS`) which the setup writes before tests run. Other packages that only needed container lifecycle (not setup-produced state) did not need this indirection. ## Catalog cleanup - `mocha-steps` — removed. No remaining consumers after the e2e migration. - `mocha`, `@types/mocha`, `chai`, `chai-as-promised`, `@types/chai`, `@types/chai-as-promised` — retained. Still used by: cli e2e (not migrated here — 101 files with bash-orchestrated anvil); hardhat tests in sdk/relayer/infra/helloworld (hardhat embeds mocha, can't be swapped). - `sinon`, `@types/sinon` — retained. Still used by hybrid hardhat packages. ## Verified - `pnpm build` — 29/29 turbo tasks pass - Unit tests unaffected: rebalancer (367), sdk (532), svm-sdk (55), radix-sdk (5), plus all other packages - E2e tests themselves require containers (Docker / anvil / aleo node / etc.) to run — only the migration's structural correctness was verified locally; actual e2e execution happens in CI environments that provide those dependencies
1 parent b58b88d commit df090e0

84 files changed

Lines changed: 623 additions & 908 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pnpm-lock.yaml

Lines changed: 12 additions & 158 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ catalog:
128128

129129
# Testing
130130
mocha: ^11.5.0
131-
mocha-steps: ^1.3.0
132131
chai: ^4.5.0
133132
chai-as-promised: ^8.0.1
134133
sinon: ^13.0.2

typescript/aleo-sdk/.mocharc-e2e.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

typescript/aleo-sdk/package.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,14 @@
4949
},
5050
"devDependencies": {
5151
"@hyperlane-xyz/tsconfig": "workspace:^",
52-
"@types/chai": "catalog:",
53-
"@types/chai-as-promised": "catalog:",
54-
"@types/mocha": "catalog:",
5552
"@types/node": "catalog:",
5653
"@types/unzipper": "^0",
57-
"chai": "catalog:",
58-
"chai-as-promised": "catalog:",
59-
"mocha": "catalog:",
60-
"mocha-steps": "catalog:",
6154
"node-fetch": "^3.3.2",
6255
"oxfmt": "catalog:",
6356
"testcontainers": "catalog:",
64-
"ts-node": "catalog:",
65-
"typescript": "catalog:"
57+
"typescript": "catalog:",
58+
"vite": "catalog:",
59+
"vitest": "catalog:"
6660
},
6761
"peerDependencies": {
6862
"testcontainers": "catalog:"

typescript/aleo-sdk/scripts/run-e2e-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export ALEO_ISM_MANAGER_SUFFIX="custom"
1212

1313
if [ -n "${ALEO_SDK_E2E_TEST}" ]; then
1414
echo "Running only ${ALEO_SDK_E2E_TEST} test"
15-
pnpm mocha --config .mocharc-e2e.json "src/tests/${ALEO_SDK_E2E_TEST}.e2e-test.ts"
15+
pnpm vitest run --config vitest.e2e.config.ts "src/tests/${ALEO_SDK_E2E_TEST}.e2e-test.ts"
1616
else
17-
pnpm mocha --config .mocharc-e2e.json "src/tests/*.e2e-test.ts"
17+
pnpm vitest run --config vitest.e2e.config.ts
1818
fi
1919

2020
echo "Completed E2E tests"

typescript/aleo-sdk/src/tests/5_ism_artifacts.e2e-test.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import chai, { expect } from 'chai';
2-
import chaiAsPromised from 'chai-as-promised';
1+
import { beforeAll, describe, expect, it } from 'vitest';
32

43
import { AltVM } from '@hyperlane-xyz/provider-sdk';
54
import { type ISigner } from '@hyperlane-xyz/provider-sdk/altvm';
@@ -22,11 +21,7 @@ import { normalizeConfig } from '@hyperlane-xyz/utils';
2221
import { AleoSigner } from '../clients/signer.js';
2322
import { AleoIsmArtifactManager } from '../ism/ism-artifact-manager.js';
2423

25-
chai.use(chaiAsPromised);
26-
27-
describe('5. aleo sdk ISM artifacts (readers and writers) e2e tests', async function () {
28-
this.timeout(100_000);
29-
24+
describe('5. aleo sdk ISM artifacts (readers and writers) e2e tests', () => {
3025
let signer: AleoSigner;
3126
let providerSdkSigner: ISigner<AnnotatedTx, TxReceipt>;
3227
let artifactManager: AleoIsmArtifactManager;
@@ -38,7 +33,7 @@ describe('5. aleo sdk ISM artifacts (readers and writers) e2e tests', async func
3833
'0x98A56EdE1d6Dd386216DA8217D9ac1d2EE7c27c7',
3934
].sort();
4035

41-
before(async () => {
36+
beforeAll(async () => {
4237
const localnetRpc = 'http://localhost:3030';
4338
// test private key with funds
4439
const privateKey =
@@ -169,7 +164,7 @@ describe('5. aleo sdk ISM artifacts (readers and writers) e2e tests', async func
169164
const DOMAIN_2 = 96;
170165
const DOMAIN_3 = 100;
171166

172-
before(async () => {
167+
beforeAll(async () => {
173168
// Create Test ISM for routing
174169
const testWriter = artifactManager.createWriter(
175170
AltVM.IsmType.TEST_ISM,

0 commit comments

Comments
 (0)