Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/internal/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from "node:path";
import type { Sablier } from "@src/types";
import * as fs from "fs-extra";
import { isBroadcastsUnified } from "../../tests/helpers/broadcasts";
import { isBroadcastsUnified } from "../../tests/evm/helpers/broadcasts";
import { log } from "./logger";

const ROOT_DIR = path.join(__dirname, "..", "..");
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ describe("Type-level const validation", () => {
test("Sample ABI files have correct const assertions", () => {
// These imports will fail at compile time if ABIs don't have proper 'as const'
type TestAirdropsV14 =
typeof import("../../src/evm/releases/airdrops/v1.3/abi/SablierMerkleInstant").sablierMerkleInstantAbi;
type TestLockupV10 = typeof import("../../src/evm/releases/lockup/v2.0/abi/SablierLockup").sablierLockupAbi;
type TestFlowV10 = typeof import("../../src/evm/releases/flow/v1.1/abi/SablierFlow").sablierFlowAbi;
typeof import("../../../src/evm/releases/airdrops/v1.3/abi/SablierMerkleInstant").sablierMerkleInstantAbi;
type TestLockupV10 = typeof import("../../../src/evm/releases/lockup/v2.0/abi/SablierLockup").sablierLockupAbi;
type TestFlowV10 = typeof import("../../../src/evm/releases/flow/v1.1/abi/SablierFlow").sablierFlowAbi;

// These type assertions will fail if the ABIs aren't const
type _AssertAirdrops = AssertAsConst<TestAirdropsV14>;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions tests/solana/contracts/catalog.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { sablier } from "@src/sablier";
import { releases } from "@src/solana/releases";
import { describe, expect, it } from "vitest";

describe("Contract catalog", () => {
const releasesToTest = [releases.airdrops["v1.0"], releases.lockup["v1.0"]];

Check failure on line 6 in tests/solana/contracts/catalog.test.ts

View workflow job for this annotation

GitHub Actions / ci

Element implicitly has an 'any' type because expression of type '"v1.0"' can't be used to index type 'Record<Lockup, Release>'.

Check failure on line 6 in tests/solana/contracts/catalog.test.ts

View workflow job for this annotation

GitHub Actions / ci

Element implicitly has an 'any' type because expression of type '"v1.0"' can't be used to index type 'Record<Airdrops, Release>'.

Check failure on line 6 in tests/solana/contracts/catalog.test.ts

View workflow job for this annotation

GitHub Actions / ci

Element implicitly has an 'any' type because expression of type '"v1.0"' can't be used to index type 'Record<Lockup, Release>'.

Check failure on line 6 in tests/solana/contracts/catalog.test.ts

View workflow job for this annotation

GitHub Actions / ci

Element implicitly has an 'any' type because expression of type '"v1.0"' can't be used to index type 'Record<Airdrops, Release>'.

for (const release of releasesToTest) {
it(`should have a valid catalog for ${release.protocol} ${release.version}`, () => {
const deployment = release.deployments[0];
const contract = deployment.contracts[0];
const entry = sablier.solana.contracts.get({
chainId: deployment.chainId,
contractName: contract.name,
release: release,
});
expect(entry).toStrictEqual(contract);
});
}
});
35 changes: 35 additions & 0 deletions tests/solana/contracts/indexed.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { sablier } from "@src/sablier";
import { contracts } from "@src/solana/contracts";
import { Protocol } from "@src/solana/enums";
import type { Sablier } from "@src/types";
import { describe, expect, it } from "vitest";

/**
* These contracts are indexed by the Sablier Indexers, so they require a deployment block number.
* @see https://github.com/sablier-labs/indexers
*/
const INDEXED: Record<Sablier.Solana.Protocol, Set<string>> = {
[Protocol.Airdrops]: new Set([contracts.names.SABLIER_MERKLE_INSTANT]),
[Protocol.Lockup]: new Set([contracts.names.SABLIER_LOCKUP_LINEAR]),
};

describe("Indexed contracts have a deployment block number", () => {
for (const release of sablier.solana.releases.getAll()) {
describe(`${release.protocol} ${release.version}`, () => {
const contracts = sablier.solana.contracts.getAll({ release })!;

for (const contract of contracts) {
if (!INDEXED[release.protocol].has(contract.name)) {
it.skip(`Skipped ${contract.name} because it's not an indexed contract.`, () => {});
continue;
}

const chain = sablier.solana.chains.getOrThrow(contract.chainId);
it(`Contract ${contract.name} should have a deployment block number set on ${chain.name}`, () => {
const errorMsg = `No block number found for ${contract.name}`;
expect(contract.block, errorMsg).toBeDefined();
});
}
});
}
});
73 changes: 73 additions & 0 deletions tests/solana/contracts/queries.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { sablier } from "@src/sablier";
import { releases } from "@src/solana/releases";
import { describe, expect, it } from "vitest";

const allReleasesToTest = [releases.airdrops["v1.0"], releases.lockup["v1.0"]];

Check failure on line 5 in tests/solana/contracts/queries.test.ts

View workflow job for this annotation

GitHub Actions / ci

Element implicitly has an 'any' type because expression of type '"v1.0"' can't be used to index type 'Record<Lockup, Release>'.

Check failure on line 5 in tests/solana/contracts/queries.test.ts

View workflow job for this annotation

GitHub Actions / ci

Element implicitly has an 'any' type because expression of type '"v1.0"' can't be used to index type 'Record<Airdrops, Release>'.

Check failure on line 5 in tests/solana/contracts/queries.test.ts

View workflow job for this annotation

GitHub Actions / ci

Element implicitly has an 'any' type because expression of type '"v1.0"' can't be used to index type 'Record<Lockup, Release>'.

Check failure on line 5 in tests/solana/contracts/queries.test.ts

View workflow job for this annotation

GitHub Actions / ci

Element implicitly has an 'any' type because expression of type '"v1.0"' can't be used to index type 'Record<Airdrops, Release>'.

describe("contractsQueries.get", () => {
describe("{ chainId, contractName, release }", () => {
for (const release of allReleasesToTest) {
it("should return contract when found", () => {
const deployment = release.deployments[0];
const contract = deployment.contracts[0];

const result = sablier.solana.contracts.get({
chainId: deployment.chainId,
contractName: contract.name,
release,
});

expect(result).toStrictEqual(contract);
});
}
});

describe("{ chainId, contractAddress, protocol }", () => {
it("should return contract when found in single release", () => {
const release = allReleasesToTest[0];
const deployment = release.deployments[0];
const contract = deployment.contracts[0];

const result = sablier.solana.contracts.get({
chainId: deployment.chainId,
contractAddress: contract.address,
protocol: release.protocol,
});

expect(result).toStrictEqual(contract);
});
});

describe("{ chainId, contractAddress, protocol, release }", () => {
it("should return contract when found", () => {
const release = allReleasesToTest[0];
const deployment = release.deployments[0];
const contract = deployment.contracts[0];

const result = sablier.solana.contracts.get({
chainId: deployment.chainId,
contractAddress: contract.address,
protocol: release.protocol,
release,
});

expect(result).toStrictEqual(contract);
});
});

describe("{ chainId, contractAddress, release }", () => {
it("should return contract when found", () => {
const release = allReleasesToTest[0];
const deployment = release.deployments[0];
const contract = deployment.contracts[0];

const result = sablier.solana.contracts.get({
chainId: deployment.chainId,
contractAddress: contract.address,
release,
});

expect(result).toStrictEqual(contract);
});
});
});
6 changes: 3 additions & 3 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const VITE_CRON_TESTS = Boolean(process.env.VITE_CRON_TESTS);

function getInclude() {
if (CI && VITE_CRON_TESTS) {
return ["tests/cron/**/*.test.ts"];
return ["tests/**/cron/**/*.test.ts"];
}

return ["tests/**/*.test.ts", "!tests/cron/**/*.ts"];
return ["tests/**/*.test.ts", "!tests/**/cron/**/*.ts"];
}

/**
Expand All @@ -34,7 +34,7 @@ export default defineConfig({
plugins: [tsconfigPaths()],
test: {
environment: "node",
globalSetup: "./tests/helpers/setup.ts",
globalSetup: "./tests/setup.ts",
globals: true,
include: getInclude(),
outputFile: CI ? "./test-results.json" : undefined,
Expand Down
Loading