Skip to content

Commit 5582642

Browse files
authored
feat(svm): add svm test node hook at root level (#1037)
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
1 parent 9d93433 commit 5582642

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

hardhat.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const config: HardhatUserConfig = {
1919
},
2020
mocha: {
2121
timeout: 100000,
22+
require: ["./test/setup.ts"],
2223
},
2324
watcher: {
2425
test: {

test/Solana.SvmCpiEventsClient.Integration.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { CHAIN_IDs } from "@across-protocol/constants";
12
import { SvmSpokeClient } from "@across-protocol/contracts";
23
import { getSolanaChainId, intToU8Array32, u8Array32ToInt } from "@across-protocol/contracts/dist/src/svm/web3-v1";
34
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
45
import { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, TOKEN_2022_PROGRAM_ADDRESS } from "@solana-program/token-2022";
5-
import { address, Address, KeyPairSigner } from "@solana/kit";
6+
import { Address, KeyPairSigner, address } from "@solana/kit";
67
import { expect } from "chai";
78
import { BigNumber } from "ethers";
89
import { arrayify, hexlify } from "ethers/lib/utils";
@@ -28,8 +29,6 @@ import {
2829
mintTokens,
2930
requestSlowFill,
3031
} from "./utils/svm/utils";
31-
import { validatorSetup, validatorTeardown } from "./utils/svm/validator.setup";
32-
import { CHAIN_IDs } from "@across-protocol/constants";
3332

3433
// Define an extended interface for our Solana client with chainId
3534
interface ExtendedSolanaClient extends ReturnType<typeof createDefaultSolanaClient> {
@@ -213,9 +212,6 @@ describe("SvmCpiEventsClient (integration)", () => {
213212
};
214213

215214
before(async function () {
216-
/* Local validator spin‑up can take a few seconds */
217-
this.timeout(60_000);
218-
await validatorSetup();
219215
signer = await generateKeyPairSignerWithSol(solanaClient);
220216
({ state } = await initializeSvmSpoke(signer, solanaClient, signer.address));
221217
({ mint, decimals } = await createMint(signer, solanaClient));
@@ -224,10 +220,6 @@ describe("SvmCpiEventsClient (integration)", () => {
224220
eventAuthority = await getEventAuthority();
225221
});
226222

227-
after(async () => {
228-
await validatorTeardown();
229-
});
230-
231223
it("fetches all events", async () => {
232224
const payerAta = await mintTokens(signer, solanaClient, mint.address, tokenAmount * 2n + 1n);
233225
await sendCreateDeposit(payerAta, tokenAmount, tokenAmount);
@@ -377,7 +369,7 @@ describe("SvmCpiEventsClient (integration)", () => {
377369
expect(fillEvent.inputAmount.toString()).to.equal(BigInt(relayData.inputAmount).toString());
378370
expect(fillEvent.outputAmount.toString()).to.equal(BigInt(relayData.outputAmount).toString());
379371
expect(fillEvent.originChainId).to.equal(Number(relayData.originChainId));
380-
expect(fillEvent.depositId).to.equal(u8Array32ToInt(relayData.depositId));
372+
expect(fillEvent.depositId).to.equal(u8Array32ToInt(Array.from(relayData.depositId)));
381373
expect(fillEvent.fillDeadline).to.equal(Number(relayData.fillDeadline));
382374
expect(fillEvent.exclusivityDeadline).to.equal(Number(relayData.exclusivityDeadline));
383375
});

test/multicall.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ describe("getMulticallAddress", () => {
2626
});
2727
});
2828

29-
describe("getMulticall3", async () => {
30-
const provider = (await ethers.getSigners()).at(0).provider;
29+
describe("getMulticall3", function () {
30+
let provider;
31+
32+
before(async function () {
33+
provider = (await ethers.getSigners()).at(0)?.provider;
34+
});
3135

3236
it("should return undefined for an unsupported chainId", () => {
3337
const chainId = 100; // Unsupported chain (Mumbai)

test/setup.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { validatorSetup, validatorTeardown } from "./utils/svm/validator.setup";
2+
3+
before(async function () {
4+
/* Local validator spin‑up can take a few seconds */
5+
this.timeout(60_000);
6+
await validatorSetup();
7+
});
8+
9+
after(() => {
10+
validatorTeardown();
11+
});

0 commit comments

Comments
 (0)