Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit d369fbf

Browse files
barnjamingator-boi
andauthored
Evm: Fix tests post SDK restructure (#137)
Co-authored-by: gator-boi <[email protected]>
1 parent 007929e commit d369fbf

20 files changed

+347
-268
lines changed

.github/workflows/evm.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: EVM CI
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
paths:
6+
- 'evm/**'
7+
push:
8+
branches:
9+
- main
10+
env:
11+
FOUNDRY_PROFILE: ci
12+
jobs:
13+
test:
14+
strategy:
15+
fail-fast: true
16+
name: forge test
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
- name: Install Foundry
23+
uses: foundry-rs/foundry-toolchain@v1
24+
with:
25+
version: nightly
26+
- name: Run Forge build
27+
working-directory: evm
28+
run: make build
29+
- name: Run unit tests
30+
working-directory: evm
31+
run: make unit-test
32+
- name: Run Integration tests
33+
working-directory: evm
34+
run: make integration-test

evm/Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,28 @@ all: build
66

77
.PHONY: unit-test
88
unit-test: build
9-
forge test --fork-url ${AVAX_RPC} -vv
9+
forge test --fork-url ${AVALANCHE_RPC} -vv
1010

1111
.PHONY: integration-test
12-
integration-test: node_modules ts/tests/.env
12+
integration-test: build ts/tests/.env
1313
bash ts/tests/run_integration_test.sh
1414

1515
.PHONY: test
1616
test: forge-test ts/tests/.env
1717
bash ts/tests/run_integration_test.sh
1818

19+
.PHONY: ts/tests/.env
20+
ts/tests/.env:
21+
cp env/testing.env ts/tests/.env
22+
1923
.PHONY: forge-test
2024
forge-test: dependencies
21-
forge test --fork-url ${AVAX_RPC} -vv
25+
forge test --fork-url ${AVALANCHE_RPC} -vv
2226

2327
.PHONY: build
2428
build: dependencies
25-
forge build --skip test
26-
npm run generate
29+
forge build
30+
npm run generate
2731

2832
.PHONY: dependencies
2933
dependencies: node_modules
@@ -33,5 +37,5 @@ clean:
3337
forge clean
3438
rm -rf anvil.log ts/src/types
3539

36-
node_modules:
40+
node_modules: ../package-lock.json
3741
cd .. && npm ci

evm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The testing environments can be found in the following locations:
1515
- [Unit Tests](./forge/tests/)
1616
- [Integration Tests](./ts/tests/)
1717

18-
To run the unit tests, set the `AVAX_RPC` environment variable in `env/testing.env` and run `make unit-test`. To run the integration tests, create a `.env` file in the `ts/tests` directory with the following environment variables:
18+
To run the unit tests, set the `AVALANCHE_RPC` environment variable in `env/testing.env` and run `make unit-test`. To run the integration tests, create a `.env` file in the `ts/tests` directory with the following environment variables:
1919

2020
```
2121
# Mainnet RPCs

evm/env/testing.env

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
export AVAX_RPC=https://api.avax.network/ext/bc/C/rpc
1+
export AVALANCHE_RPC=https://api.avax.network/ext/bc/C/rpc
2+
export ETHEREUM_RPC=https://rpc.ankr.com/eth
3+
export BASE_RPC=https://mainnet.base.org
4+
5+
26
export AVAX_USDC_ADDRESS=0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
37
export AVAX_MESSAGE_TRANSMITTER=0x8186359af5f57fbb40c6b14a588d2a59c0c29880
48
export AVAX_CIRCLE_BRIDGE=0x6b25532e1060ce10cc3b0a99e5683b91bfde6982
@@ -12,4 +16,4 @@ export SUI_TOKEN_BRIDGE_ADDRESS=0xccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca54
1216
export ARB_TOKEN_BRIDGE_ADDRESS=0x0b2402144Bb366A632D14B83F244D2e0e21bD39c
1317
export POLY_TOKEN_BRIDGE_ADDRESS=0x5a58505a96D1dbf8dF91cB21B54419FC36e93fdE
1418
export ARB_CIRCLE_BRIDGE=0x19330d10D9Cc8751218eaf51E8885D058642E08A
15-
export ARB_CIRCLE_INTEGRATION=0x2703483B1a5a7c577e8680de9Df8Be03c6f30e3c
19+
export ARB_CIRCLE_INTEGRATION=0x2703483B1a5a7c577e8680de9Df8Be03c6f30e3c

evm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"generate": "typechain --target=ethers-v5 --out-dir=ts/src/types out/*/*.json"
1414
},
1515
"dependencies": {
16-
"@wormhole-foundation/sdk":"^0.6.8-beta.0",
16+
"@wormhole-foundation/sdk":"^0.6.8",
1717
"ethers": "^5.7.2"
1818
},
1919
"devDependencies": {

evm/ts/src/TokenRouter/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { VAA } from "@wormhole-foundation/sdk";
12
import { LiquidityLayerTransactionResult, PreparedInstruction } from "..";
23
import { ethers } from "ethers";
34
export * from "./evm";
@@ -29,7 +30,7 @@ export abstract class TokenRouter<PreparedTransactionType extends PreparedInstru
2930
redeemer: Buffer | Uint8Array,
3031
redeemerMessage: Buffer | Uint8Array,
3132
minAmountOut?: bigint,
32-
refundAddress?: string
33+
refundAddress?: string,
3334
): Promise<PreparedTransactionType>;
3435

3536
abstract placeFastMarketOrder(
@@ -40,19 +41,19 @@ export abstract class TokenRouter<PreparedTransactionType extends PreparedInstru
4041
maxFee: bigint,
4142
deadline: number,
4243
minAmountOut?: bigint,
43-
refundAddress?: string
44+
refundAddress?: string,
4445
): Promise<PreparedTransactionType>;
4546

4647
abstract redeemFill(response: OrderResponse): Promise<PreparedTransactionType>;
4748

4849
abstract addRouterEndpoint(
4950
chain: number,
5051
endpoint: Endpoint,
51-
domain: number
52+
domain: number,
5253
): Promise<PreparedTransactionType>;
5354

5455
abstract updateFastTransferParameters(
55-
newParams: FastTransferParameters
56+
newParams: FastTransferParameters,
5657
): Promise<PreparedTransactionType>;
5758

5859
abstract enableFastTransfer(enable: boolean): Promise<PreparedTransactionType>;

evm/ts/tests/00__environment.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { ethers } from "ethers";
44
import {
55
ICircleBridge__factory,
66
IMessageTransmitter__factory,
7-
IUSDC__factory,
87
IWormhole__factory,
9-
} from "../src/types";
8+
} from "../src/types/factories";
9+
10+
import { IUSDC__factory } from "../src/types/factories/IUSDC__factory";
1011
import {
1112
parseLiquidityLayerEnvFile,
1213
GUARDIAN_PRIVATE_KEY,
@@ -21,7 +22,7 @@ import {
2122
} from "./helpers";
2223

2324
describe("Environment", () => {
24-
const chainNames: ValidNetwork[] = ["avalanche", "ethereum", "base"];
25+
const chainNames: ValidNetwork[] = ["Avalanche", "Ethereum", "Base"];
2526

2627
for (const chainName of chainNames) {
2728
if (!(chainName in LOCALHOSTS)) {
@@ -34,7 +35,7 @@ describe("Environment", () => {
3435
tokenAddress: usdcAddress,
3536
wormholeAddress,
3637
tokenMessengerAddress,
37-
} = parseLiquidityLayerEnvFile(`${envPath}/${chainName}.env`);
38+
} = parseLiquidityLayerEnvFile(`${envPath}/${chainName.toLowerCase()}.env`);
3839

3940
const localhost = LOCALHOSTS[chainName] as string;
4041

@@ -242,7 +243,9 @@ describe("Environment", () => {
242243
const scripts = `${__dirname}/../../sh`;
243244
const cmd =
244245
`bash ${scripts}/deploy_matching_engine.sh ` +
245-
`-n localnet -c ${chainName} -u ${localhost} -k ${owner.privateKey} ` +
246+
`-n localnet -c ${chainName.toLowerCase()} -u ${localhost} -k ${
247+
owner.privateKey
248+
} ` +
246249
`> /dev/null 2>&1`;
247250
const out = execSync(cmd, { encoding: "utf8" });
248251

@@ -255,7 +258,9 @@ describe("Environment", () => {
255258
const scripts = `${__dirname}/../../sh`;
256259
const cmd =
257260
`bash ${scripts}/upgrade_matching_engine.sh ` +
258-
`-n localnet -c ${chainName} -u ${localhost} -k ${owner.privateKey}` +
261+
`-n localnet -c ${chainName.toLowerCase()} -u ${localhost} -k ${
262+
owner.privateKey
263+
}` +
259264
`> /dev/null 2>&1`;
260265
const out = execSync(cmd, { encoding: "utf8" });
261266
await provider.send("evm_setAutomine", [false]);
@@ -268,7 +273,9 @@ describe("Environment", () => {
268273
const scripts = `${__dirname}/../../sh`;
269274
const cmd =
270275
`bash ${scripts}/deploy_token_router.sh ` +
271-
`-n localnet -c ${chainName} -u ${localhost} -k ${owner.privateKey} ` +
276+
`-n localnet -c ${chainName.toLowerCase()} -u ${localhost} -k ${
277+
owner.privateKey
278+
} ` +
272279
`> /dev/null 2>&1`;
273280
const out = execSync(cmd, { encoding: "utf8" });
274281

@@ -281,7 +288,9 @@ describe("Environment", () => {
281288
const scripts = `${__dirname}/../../sh`;
282289
const cmd =
283290
`bash ${scripts}/upgrade_token_router.sh ` +
284-
`-n localnet -c ${chainName} -u ${localhost} -k ${owner.privateKey}` +
291+
`-n localnet -c ${chainName.toLowerCase()} -u ${localhost} -k ${
292+
owner.privateKey
293+
}` +
285294
`> /dev/null 2>&1`;
286295
const out = execSync(cmd, { encoding: "utf8" });
287296
await provider.send("evm_setAutomine", [false]);

evm/ts/tests/01__registration.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,27 @@ describe("Registration", () => {
1919
const envPath = `${__dirname}/../../env/localnet`;
2020

2121
describe(`Register Token Routers on ${MATCHING_ENGINE_NAME} Matching Engine`, () => {
22-
const env = parseLiquidityLayerEnvFile(`${envPath}/${MATCHING_ENGINE_NAME}.env`);
22+
const env = parseLiquidityLayerEnvFile(
23+
`${envPath}/${MATCHING_ENGINE_NAME.toLowerCase()}.env`,
24+
);
2325
const provider = new ethers.providers.StaticJsonRpcProvider(
2426
LOCALHOSTS[MATCHING_ENGINE_NAME],
2527
);
2628
const assistant = new ethers.Wallet(OWNER_ASSISTANT_PRIVATE_KEY, provider);
2729

28-
const matchingEngineAddress = toNative("Avalanche", env.matchingEngineAddress);
30+
const matchingEngineAddress = toUniversal("Avalanche", env.matchingEngineAddress).toNative(
31+
"Avalanche",
32+
);
2933
const engine = IMatchingEngine__factory.connect(
3034
matchingEngineAddress.toString(),
3135
assistant,
3236
);
3337

3438
for (const chainName of CHAIN_PATHWAYS) {
3539
it(`Register ${chainName}`, async () => {
36-
const targetEnv = parseLiquidityLayerEnvFile(`${envPath}/${chainName}.env`);
40+
const targetEnv = parseLiquidityLayerEnvFile(
41+
`${envPath}/${chainName.toLowerCase()}.env`,
42+
);
3743
const [formattedAddress, mintRecipient] = fetchTokenRouterEndpoint(
3844
targetEnv,
3945
chainName,
@@ -60,7 +66,7 @@ describe("Registration", () => {
6066

6167
for (const chainName of CHAIN_PATHWAYS) {
6268
describe(`Register Token Routers on ${chainName}`, () => {
63-
const env = parseLiquidityLayerEnvFile(`${envPath}/${chainName}.env`);
69+
const env = parseLiquidityLayerEnvFile(`${envPath}/${chainName.toLowerCase()}.env`);
6470
const provider = new ethers.providers.StaticJsonRpcProvider(LOCALHOSTS[chainName]);
6571
const assistant = new ethers.Wallet(OWNER_ASSISTANT_PRIVATE_KEY, provider);
6672
const router = ITokenRouter__factory.connect(env.tokenRouterAddress, assistant);
@@ -71,7 +77,9 @@ describe("Registration", () => {
7177
}
7278

7379
it(`Register ${targetChain}`, async () => {
74-
const targetEnv = parseLiquidityLayerEnvFile(`${envPath}/${targetChain}.env`);
80+
const targetEnv = parseLiquidityLayerEnvFile(
81+
`${envPath}/${targetChain.toLowerCase()}.env`,
82+
);
7583
const [formattedAddress, mintRecipient] = fetchTokenRouterEndpoint(
7684
targetEnv,
7785
chainName,

evm/ts/tests/02__configuration.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
parseLiquidityLayerEnvFile,
1111
} from "./helpers";
1212
import { expect } from "chai";
13-
import { toNative } from "@wormhole-foundation/sdk";
13+
import { toNative, toUniversal } from "@wormhole-foundation/sdk";
1414

1515
const CHAIN_PATHWAYS: ValidNetwork[] = ["Ethereum", "Avalanche", "Base"];
1616

@@ -19,7 +19,7 @@ describe("Configuration", () => {
1919

2020
describe("Token Router Configuration", () => {
2121
for (const chainName of CHAIN_PATHWAYS) {
22-
const env = parseLiquidityLayerEnvFile(`${envPath}/${chainName}.env`);
22+
const env = parseLiquidityLayerEnvFile(`${envPath}/${chainName.toLowerCase()}.env`);
2323
const provider = new ethers.providers.StaticJsonRpcProvider(LOCALHOSTS[chainName]);
2424
const assistant = new ethers.Wallet(OWNER_ASSISTANT_PRIVATE_KEY, provider);
2525
const router = ITokenRouter__factory.connect(env.tokenRouterAddress, assistant);
@@ -52,13 +52,18 @@ describe("Configuration", () => {
5252

5353
describe("Matching Engine Configuration", () => {
5454
it("Set Infinite Approval For Matching Engine", async () => {
55-
const env = parseLiquidityLayerEnvFile(`${envPath}/${MATCHING_ENGINE_NAME}.env`);
55+
const env = parseLiquidityLayerEnvFile(
56+
`${envPath}/${MATCHING_ENGINE_NAME.toLowerCase()}.env`,
57+
);
5658
const provider = new ethers.providers.StaticJsonRpcProvider(
5759
LOCALHOSTS[MATCHING_ENGINE_NAME],
5860
);
5961
const assistant = new ethers.Wallet(OWNER_ASSISTANT_PRIVATE_KEY, provider);
6062

61-
const matchingEngineAddress = toNative("Avalanche", env.matchingEngineAddress);
63+
const matchingEngineAddress = toUniversal(
64+
"Avalanche",
65+
env.matchingEngineAddress,
66+
).toNative("Avalanche");
6267
const engine = IMatchingEngine__factory.connect(
6368
matchingEngineAddress.toString(),
6469
assistant,

evm/ts/tests/03__marketOrder.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ describe("Market Order Business Logic -- CCTP to CCTP", () => {
4444
);
4545
const fromWallet = new ethers.Wallet(WALLET_PRIVATE_KEYS[0], fromProvider);
4646

47-
const fromEnv = parseLiquidityLayerEnvFile(`${envPath}/${fromChainName}.env`);
47+
const fromEnv = parseLiquidityLayerEnvFile(
48+
`${envPath}/${fromChainName.toLowerCase()}.env`,
49+
);
4850
const fromTokenRouter = (() => {
4951
if (fromEnv.chainType === ChainType.Evm) {
5052
return new EvmTokenRouter(
@@ -61,7 +63,7 @@ describe("Market Order Business Logic -- CCTP to CCTP", () => {
6163
const toProvider = new ethers.providers.StaticJsonRpcProvider(LOCALHOSTS[toChainName]);
6264
const toWallet = new ethers.Wallet(WALLET_PRIVATE_KEYS[1], toProvider);
6365

64-
const toEnv = parseLiquidityLayerEnvFile(`${envPath}/${toChainName}.env`);
66+
const toEnv = parseLiquidityLayerEnvFile(`${envPath}/${toChainName.toLowerCase()}.env`);
6567
const toTokenRouter = (() => {
6668
if (toEnv.chainType === ChainType.Evm) {
6769
return new EvmTokenRouter(
@@ -144,7 +146,7 @@ describe("Market Order Business Logic -- CCTP to CCTP", () => {
144146
const circleAttestation = circleAttester.createAttestation(circleBridgeMessage);
145147

146148
const orderResponse: OrderResponse = {
147-
encodedWormholeMessage: serialize(fillVaa),
149+
encodedWormholeMessage: fillVaa,
148150
circleBridgeMessage,
149151
circleAttestation,
150152
};

0 commit comments

Comments
 (0)