2023-12-12 05:27:30 -08:00
|
|
|
import { MoonbeamEvmJsonRPCBlockRepository } from "../../../src/infrastructure/repositories/evm/MoonbeamEvmJsonRPCBlockRepository";
|
2023-11-30 07:43:37 -08:00
|
|
|
import { describe, expect, it } from "@jest/globals";
|
2023-12-04 04:47:02 -08:00
|
|
|
import { RepositoriesBuilder } from "../../../src/infrastructure/repositories/RepositoriesBuilder";
|
2023-11-30 07:43:37 -08:00
|
|
|
import { configMock } from "../../mocks/configMock";
|
|
|
|
import {
|
2023-12-11 14:11:42 -08:00
|
|
|
ArbitrumEvmJsonRPCBlockRepository,
|
2023-12-06 08:07:14 -08:00
|
|
|
BscEvmJsonRPCBlockRepository,
|
2023-11-30 07:43:37 -08:00
|
|
|
EvmJsonRPCBlockRepository,
|
|
|
|
FileMetadataRepository,
|
2023-12-13 10:09:33 -08:00
|
|
|
PolygonJsonRPCBlockRepository,
|
2023-11-30 07:43:37 -08:00
|
|
|
PromStatRepository,
|
|
|
|
RateLimitedSolanaSlotRepository,
|
|
|
|
SnsEventRepository,
|
|
|
|
} from "../../../src/infrastructure/repositories";
|
|
|
|
|
|
|
|
describe("RepositoriesBuilder", () => {
|
|
|
|
it("should be throw error because dose not have any chain", async () => {
|
|
|
|
try {
|
|
|
|
// When
|
2023-12-06 08:07:14 -08:00
|
|
|
new RepositoriesBuilder(configMock());
|
2023-11-30 07:43:37 -08:00
|
|
|
} catch (e: Error | any) {
|
|
|
|
// Then
|
|
|
|
expect(e).toBeInstanceOf(Error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be throw error because dose not support test chain", async () => {
|
|
|
|
try {
|
|
|
|
// When
|
2023-12-06 08:07:14 -08:00
|
|
|
new RepositoriesBuilder(configMock());
|
2023-11-30 07:43:37 -08:00
|
|
|
} catch (e) {
|
|
|
|
// Then
|
|
|
|
expect(e).toBeInstanceOf(Error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be return all repositories instances", async () => {
|
|
|
|
// When
|
2023-12-06 08:07:14 -08:00
|
|
|
const repos = new RepositoriesBuilder(configMock());
|
2023-11-30 07:43:37 -08:00
|
|
|
// Then
|
|
|
|
const job = repos.getJobsRepository();
|
|
|
|
expect(job).toBeTruthy();
|
|
|
|
|
|
|
|
expect(repos.getEvmBlockRepository("ethereum")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2024-01-24 06:12:26 -08:00
|
|
|
expect(repos.getEvmBlockRepository("ethereum-sepolia")).toBeInstanceOf(
|
|
|
|
EvmJsonRPCBlockRepository
|
|
|
|
);
|
2023-12-06 08:07:14 -08:00
|
|
|
expect(repos.getEvmBlockRepository("bsc")).toBeInstanceOf(BscEvmJsonRPCBlockRepository);
|
2023-12-13 10:09:33 -08:00
|
|
|
expect(repos.getEvmBlockRepository("polygon")).toBeInstanceOf(PolygonJsonRPCBlockRepository);
|
2023-12-04 04:24:36 -08:00
|
|
|
expect(repos.getEvmBlockRepository("avalanche")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-05 07:49:19 -08:00
|
|
|
expect(repos.getEvmBlockRepository("oasis")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-01 05:09:58 -08:00
|
|
|
expect(repos.getEvmBlockRepository("fantom")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-11-30 07:43:37 -08:00
|
|
|
expect(repos.getEvmBlockRepository("karura")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-01 11:25:02 -08:00
|
|
|
expect(repos.getEvmBlockRepository("acala")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-05 07:49:19 -08:00
|
|
|
expect(repos.getEvmBlockRepository("klaytn")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
|
|
|
expect(repos.getEvmBlockRepository("celo")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-11 14:11:42 -08:00
|
|
|
expect(repos.getEvmBlockRepository("arbitrum")).toBeInstanceOf(
|
|
|
|
ArbitrumEvmJsonRPCBlockRepository
|
|
|
|
);
|
2024-01-24 06:12:26 -08:00
|
|
|
expect(repos.getEvmBlockRepository("arbitrum-sepolia")).toBeInstanceOf(
|
|
|
|
ArbitrumEvmJsonRPCBlockRepository
|
|
|
|
);
|
2023-12-12 05:27:30 -08:00
|
|
|
expect(repos.getEvmBlockRepository("moonbeam")).toBeInstanceOf(
|
|
|
|
MoonbeamEvmJsonRPCBlockRepository
|
|
|
|
);
|
2023-12-04 10:00:48 -08:00
|
|
|
expect(repos.getEvmBlockRepository("optimism")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2024-01-24 06:12:26 -08:00
|
|
|
expect(repos.getEvmBlockRepository("optimism-sepolia")).toBeInstanceOf(
|
|
|
|
EvmJsonRPCBlockRepository
|
|
|
|
);
|
2023-12-04 10:00:48 -08:00
|
|
|
expect(repos.getEvmBlockRepository("base")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2024-01-24 06:12:26 -08:00
|
|
|
expect(repos.getEvmBlockRepository("base-sepolia")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-11-30 07:43:37 -08:00
|
|
|
expect(repos.getMetadataRepository()).toBeInstanceOf(FileMetadataRepository);
|
|
|
|
expect(repos.getSnsEventRepository()).toBeInstanceOf(SnsEventRepository);
|
|
|
|
expect(repos.getStatsRepository()).toBeInstanceOf(PromStatRepository);
|
|
|
|
expect(repos.getSolanaSlotRepository()).toBeInstanceOf(RateLimitedSolanaSlotRepository);
|
|
|
|
});
|
|
|
|
});
|