From 534a364705af2bd6069e431bba7d52dd1db3437f Mon Sep 17 00:00:00 2001 From: Saad Ahmed Siddiqui Date: Wed, 30 Oct 2024 11:22:43 +0100 Subject: [PATCH] fix: tests --- src/types/SharedConfigTypes.ts | 1 + tests/e2e/indexing.spec.ts | 5 +++-- tests/unit/parseLogs.spec.ts | 26 +++++++++++++------------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/types/SharedConfigTypes.ts b/src/types/SharedConfigTypes.ts index 033d72b0..736c15bf 100644 --- a/src/types/SharedConfigTypes.ts +++ b/src/types/SharedConfigTypes.ts @@ -4,6 +4,7 @@ */ import { BaseConfig } from "@buildwithsygma/core" + export interface SharedConfig extends BaseConfig<"ethereum" | "substrate"> { rpcUrl: string } diff --git a/tests/e2e/indexing.spec.ts b/tests/e2e/indexing.spec.ts index 54bfb231..af76a8f0 100644 --- a/tests/e2e/indexing.spec.ts +++ b/tests/e2e/indexing.spec.ts @@ -4,8 +4,9 @@ SPDX-License-Identifier: LGPL-3.0-only */ import { expect } from "chai" import axios from "axios" +import { Network } from "@buildwithsygma/core" import { Transfer, Resource, Fee, Deposit, Execution, Domain } from "@prisma/client" -import { DomainTypes } from "../../src/indexer/config" + import { DepositType } from "../../src/indexer/services/evmIndexer/evmTypes" const NUMBER_OF_TRANSFERS = 35 @@ -62,7 +63,7 @@ describe("Indexer e2e tests", function () { const transfers = res.data as Array for (const transfer of transfers) { - if (transfer.fromDomain.name.toLowerCase() == DomainTypes.SUBSTRATE) { + if (transfer.fromDomain.name.toLowerCase() == Network.SUBSTRATE) { substrateDeposits++ } switch (transfer.resource.type) { diff --git a/tests/unit/parseLogs.spec.ts b/tests/unit/parseLogs.spec.ts index b8c4d6a6..3939f3a7 100644 --- a/tests/unit/parseLogs.spec.ts +++ b/tests/unit/parseLogs.spec.ts @@ -4,8 +4,8 @@ SPDX-License-Identifier: LGPL-3.0-only */ import { expect } from "chai" import sinon from "sinon" +import { EthereumConfig, Network, ResourceType, SubstrateConfig } from "@buildwithsygma/core" import { ApiPromise, WsProvider } from "@polkadot/api" -import { Domain, DomainTypes, ResourceTypes } from "../../src/indexer/config" import { parseDestination } from "../../src/indexer/utils/evm" describe("Events parser", function () { @@ -32,10 +32,10 @@ describe("Events parser", function () { "0x000000000000000000000000000000000000000000000000000000000007a1200004a271ced214dee6b4c59e3a0f0088878aeccf849a49031eed30140ae5594f4b6833e488bf6c4c9e94c246d90abfdb0000000000000000000000000000000000000000000000000000018b3d2082f5" const domain = { id: 2, - type: DomainTypes.EVM, - } as unknown as Domain + type: Network.EVM, + } as unknown as EthereumConfig - const destination = await parseDestination(hexData, domain, ResourceTypes.PERMISSIONLESS_GENERIC) + const destination = await parseDestination(hexData, domain, ResourceType.PERMISSIONLESS_GENERIC) expect(destination).to.be.deep.equal("0xdee6b4c59e3a0f0088878aeccf849a49031eed30") }) @@ -44,10 +44,10 @@ describe("Events parser", function () { "0x000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000145c1f5961696bad2e73f73417f07ef55c62a2dc5b0102" const domain = { id: 2, - type: DomainTypes.EVM, - } as unknown as Domain + type: Network.EVM, + } as unknown as EthereumConfig - const destination = await parseDestination(hexData, domain, ResourceTypes.FUNGIBLE) + const destination = await parseDestination(hexData, domain, ResourceType.FUNGIBLE) expect(destination).to.be.deep.equal("0x5c1f5961696bad2e73f73417f07ef55c62a2dc5b") }) @@ -58,8 +58,8 @@ describe("Events parser", function () { "0x00000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000002400010100d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" const domain = { id: 3, - type: DomainTypes.SUBSTRATE, - } as unknown as Domain + type: Network.SUBSTRATE, + } as unknown as SubstrateConfig sinon.stub(WsProvider.prototype, "connect") mockToJson.returns({ @@ -72,7 +72,7 @@ describe("Events parser", function () { }, }, }) - const destination = await parseDestination(hexData, domain, ResourceTypes.FUNGIBLE) + const destination = await parseDestination(hexData, domain, ResourceType.FUNGIBLE) expect(destination).to.equal("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY") }) @@ -82,8 +82,8 @@ describe("Events parser", function () { const hexData = "0x000000" const domain = { id: 3, - type: DomainTypes.SUBSTRATE, - } as unknown as Domain + type: Network.SUBSTRATE, + } as unknown as SubstrateConfig mockToJson.returns({ parents: 0, @@ -93,7 +93,7 @@ describe("Events parser", function () { }) sinon.stub(WsProvider.prototype, "connect") - const result = await parseDestination(hexData, domain, ResourceTypes.FUNGIBLE) + const result = await parseDestination(hexData, domain, ResourceType.FUNGIBLE) expect(result).to.equal("") }) })