2024-02-07 11:50:05 -08:00
|
|
|
import { mockRpcPool } from "../../mocks/mockRpcPool";
|
|
|
|
mockRpcPool();
|
|
|
|
|
2024-02-14 11:03:50 -08:00
|
|
|
import { RateLimitedEvmJsonRPCBlockRepository } from "../../../src/infrastructure/repositories/evm/RateLimitedEvmJsonRPCBlockRepository";
|
|
|
|
import { RateLimitedSuiJsonRPCBlockRepository } from "../../../src/infrastructure/repositories/sui/RateLimitedSuiJsonRPCBlockRepository";
|
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 {
|
|
|
|
FileMetadataRepository,
|
|
|
|
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();
|
|
|
|
|
2024-02-14 11:03:50 -08:00
|
|
|
expect(repos.getEvmBlockRepository("ethereum")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
2024-01-24 06:12:26 -08:00
|
|
|
expect(repos.getEvmBlockRepository("ethereum-sepolia")).toBeInstanceOf(
|
2024-02-14 11:03:50 -08:00
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("bsc")).toBeInstanceOf(RateLimitedEvmJsonRPCBlockRepository);
|
|
|
|
expect(repos.getEvmBlockRepository("polygon")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("avalanche")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("oasis")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("fantom")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("karura")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("acala")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("klaytn")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("celo")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
2023-12-11 14:11:42 -08:00
|
|
|
expect(repos.getEvmBlockRepository("arbitrum")).toBeInstanceOf(
|
2024-02-14 11:03:50 -08:00
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
2023-12-11 14:11:42 -08:00
|
|
|
);
|
2024-01-24 06:12:26 -08:00
|
|
|
expect(repos.getEvmBlockRepository("arbitrum-sepolia")).toBeInstanceOf(
|
2024-02-14 11:03:50 -08:00
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
2024-01-24 06:12:26 -08:00
|
|
|
);
|
2023-12-12 05:27:30 -08:00
|
|
|
expect(repos.getEvmBlockRepository("moonbeam")).toBeInstanceOf(
|
2024-02-14 11:03:50 -08:00
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("optimism")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
2023-12-12 05:27:30 -08:00
|
|
|
);
|
2024-01-24 06:12:26 -08:00
|
|
|
expect(repos.getEvmBlockRepository("optimism-sepolia")).toBeInstanceOf(
|
2024-02-14 11:03:50 -08:00
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("base")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
|
|
|
expect(repos.getEvmBlockRepository("base-sepolia")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
2024-01-24 06:12:26 -08:00
|
|
|
);
|
2024-02-22 07:48:13 -08:00
|
|
|
expect(repos.getEvmBlockRepository("ethereum-holesky")).toBeInstanceOf(
|
|
|
|
RateLimitedEvmJsonRPCBlockRepository
|
|
|
|
);
|
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);
|
2024-02-14 11:03:50 -08:00
|
|
|
expect(repos.getSuiRepository()).toBeInstanceOf(RateLimitedSuiJsonRPCBlockRepository);
|
2023-11-30 07:43:37 -08:00
|
|
|
});
|
|
|
|
});
|