Skip to content

Commit f1bca04

Browse files
feat(orc-458): setup tests for repo
1 parent 77f865b commit f1bca04

File tree

11 files changed

+1036
-383
lines changed

11 files changed

+1036
-383
lines changed

contracts/twg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import { wallet } from '@providers';
33
import { getDeployedAddress } from '@configs';
44
import abi from 'abi/TriggerableWithdrawalsGateway.json';
55

6-
export const twgAddress = getDeployedAddress('triggerableWithdrawalsGateway.implementation.address');
6+
export const twgAddress = getDeployedAddress('triggerableWithdrawalsGateway.implementation');
77
export const twgContract = new Contract(twgAddress, abi, wallet);

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
"scripts": {
44
"testnet": "./testnet.sh",
55
"start": "./run.sh",
6+
"test": "vitest",
7+
"test:run": "vitest run",
68
"lint": "eslint **/*.ts",
7-
"format": "eslint **/*.ts --fix",
9+
"format": "es",
810
"check-types": "tsc --noEmit"
911
},
1012
"devDependencies": {
@@ -23,7 +25,8 @@
2325
"prettier": "^3.0.3",
2426
"ts-node": "^10.9.1",
2527
"tsconfig-paths": "^4.1.2",
26-
"typescript": "^5.0.2"
28+
"typescript": "^5.0.2",
29+
"vitest": "^4.0.7"
2730
},
2831
"dependencies": {
2932
"@chainsafe/bls-keygen": "^0.4.0",

tests/setup.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { beforeAll, afterAll, beforeEach } from 'vitest';
2+
import { AnvilRunner, CliRunner } from './utils';
3+
4+
export const MAINNET_TEST_CONFIG = {
5+
DEPLOYED: 'deployed-mainnet.json',
6+
EL_CHAIN_ID: '1',
7+
EL_NETWORK_NAME: 'mainnet',
8+
EL_API_PROVIDER: 'http://127.0.0.1:8545',
9+
CHAIN_ID: '1',
10+
NETWORK: 'mainnet',
11+
LIDO_CLI_NON_INTERACTIVE: 'true',
12+
PRIVATE_KEY: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
13+
} as const;
14+
15+
export function applyTestConfig(config: typeof MAINNET_TEST_CONFIG = MAINNET_TEST_CONFIG): void {
16+
console.log('🔧 Applying test configuration (overriding .env)...');
17+
console.log(` DEPLOYED: ${config.DEPLOYED}`);
18+
console.log(` NETWORK: ${config.NETWORK}`);
19+
console.log(` CHAIN_ID: ${config.CHAIN_ID}`);
20+
21+
Object.entries(config).forEach(([key, value]) => {
22+
if (value !== undefined) {
23+
process.env[key] = value;
24+
}
25+
});
26+
27+
console.log('✅ Test configuration applied successfully');
28+
}
29+
30+
applyTestConfig();
31+
32+
export let anvilRunner: AnvilRunner;
33+
export let cliRunner: CliRunner;
34+
35+
beforeAll(async () => {
36+
console.log('Starting test suite...');
37+
38+
anvilRunner = new AnvilRunner();
39+
cliRunner = new CliRunner();
40+
41+
await anvilRunner.start();
42+
await new Promise((resolve) => setTimeout(resolve, 3000));
43+
await anvilRunner.setupPermissions();
44+
});
45+
46+
beforeEach(async () => {
47+
await anvilRunner.refillTestAccount();
48+
});
49+
50+
afterAll(async () => {
51+
if (anvilRunner) {
52+
await anvilRunner.stop();
53+
}
54+
console.log('Test suite completed.');
55+
});

0 commit comments

Comments
 (0)