Skip to content

feat(svm): add svm test node hook at root level #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const config: HardhatUserConfig = {
},
mocha: {
timeout: 100000,
require: ["./test/setup.ts"],
},
watcher: {
test: {
Expand Down
14 changes: 3 additions & 11 deletions test/Solana.SvmCpiEventsClient.Integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { CHAIN_IDs } from "@across-protocol/constants";
import { SvmSpokeClient } from "@across-protocol/contracts";
import { getSolanaChainId, intToU8Array32, u8Array32ToInt } from "@across-protocol/contracts/dist/src/svm/web3-v1";
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
import { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, TOKEN_2022_PROGRAM_ADDRESS } from "@solana-program/token-2022";
import { address, Address, KeyPairSigner } from "@solana/kit";
import { Address, KeyPairSigner, address } from "@solana/kit";
import { expect } from "chai";
import { BigNumber } from "ethers";
import { arrayify, hexlify } from "ethers/lib/utils";
Expand All @@ -28,8 +29,6 @@ import {
mintTokens,
requestSlowFill,
} from "./utils/svm/utils";
import { validatorSetup, validatorTeardown } from "./utils/svm/validator.setup";
import { CHAIN_IDs } from "@across-protocol/constants";

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

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

after(async () => {
await validatorTeardown();
});

it("fetches all events", async () => {
const payerAta = await mintTokens(signer, solanaClient, mint.address, tokenAmount * 2n + 1n);
await sendCreateDeposit(payerAta, tokenAmount, tokenAmount);
Expand Down Expand Up @@ -377,7 +369,7 @@ describe("SvmCpiEventsClient (integration)", () => {
expect(fillEvent.inputAmount.toString()).to.equal(BigInt(relayData.inputAmount).toString());
expect(fillEvent.outputAmount.toString()).to.equal(BigInt(relayData.outputAmount).toString());
expect(fillEvent.originChainId).to.equal(Number(relayData.originChainId));
expect(fillEvent.depositId).to.equal(u8Array32ToInt(relayData.depositId));
expect(fillEvent.depositId).to.equal(u8Array32ToInt(Array.from(relayData.depositId)));
expect(fillEvent.fillDeadline).to.equal(Number(relayData.fillDeadline));
expect(fillEvent.exclusivityDeadline).to.equal(Number(relayData.exclusivityDeadline));
});
Expand Down
8 changes: 6 additions & 2 deletions test/multicall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ describe("getMulticallAddress", () => {
});
});

describe("getMulticall3", async () => {
const provider = (await ethers.getSigners()).at(0).provider;
describe("getMulticall3", function () {
let provider;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but having an async test prevented me from using the only option to run specific tests. Moving the async initialization to a before hook resolved the issue and follows best practices.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call +1


before(async function () {
provider = (await ethers.getSigners()).at(0)?.provider;
});

it("should return undefined for an unsupported chainId", () => {
const chainId = 100; // Unsupported chain (Mumbai)
Expand Down
11 changes: 11 additions & 0 deletions test/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { validatorSetup, validatorTeardown } from "./utils/svm/validator.setup";

before(async function () {
/* Local validator spin‑up can take a few seconds */
this.timeout(60_000);
await validatorSetup();
});

after(() => {
validatorTeardown();
});