From a2348a8074b9397ecbb27bfd7466f28ecde09abd Mon Sep 17 00:00:00 2001 From: james-a-morris Date: Tue, 5 Sep 2023 17:16:43 -0400 Subject: [PATCH] fix: resolve validate flow ts --- test/UBAClient.validateFlow.ts | 30 ++++++++++++++++++++++++++---- test/types/index.ts | 1 + test/utils/utils.ts | 7 +++++-- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/test/UBAClient.validateFlow.ts b/test/UBAClient.validateFlow.ts index 30940ae31..68c16d000 100644 --- a/test/UBAClient.validateFlow.ts +++ b/test/UBAClient.validateFlow.ts @@ -9,7 +9,7 @@ import { ethers, hubPoolFixture, } from "./utils"; -import { CHAIN_ID_TEST_LIST, expect, randomAddress, toBNWei } from "./constants"; +import { BigNumber, CHAIN_ID_TEST_LIST, expect, randomAddress, toBNWei } from "./constants"; import { SpokePoolClientsByChain, UbaFlow, UbaInflow, UbaOutflow } from "../src/interfaces"; import { MockConfigStoreClient, MockHubPoolClient, MockSpokePoolClient, MockUBAClient } from "./mocks"; import { UBA_MIN_CONFIG_STORE_VERSION } from "../src/common"; @@ -37,7 +37,23 @@ const realizedLpFeePct = toBNWei("0.13"); // Make these test flows partial types so we can leave some of the params undefined until we get to the individual // tests. -let partialInflow: Omit, partialOutflow: Omit; +let partialInflow: Omit; +let partialOutflow: Omit & { + fillAmount: BigNumber; + totalFilledAmount: BigNumber; + depositor: string; + destinationToken: string; + recipient: string; + relayerFeePct: BigNumber; + updatableRelayData: { + recipient: string; + isSlowRelay: boolean; + message: string; + payoutAdjustmentPct: BigNumber; + relayerFeePct: BigNumber; + }; + message: string; +}; describe("UBAClient: Flow validation", function () { beforeEach(async function () { @@ -243,7 +259,10 @@ describe("UBAClient: Flow validation", function () { const expectedLpFee = inflow.amount.mul(baselineFee).div(toBNWei(1)); expect(result?.lpFee).to.equal(expectedLpFee); - deepEqualsWithBigNumber(result?.flow, inflow); + deepEqualsWithBigNumber( + result?.flow as unknown as Record, + inflow as unknown as Record + ); }); }); describe("Outflow", function () { @@ -285,7 +304,10 @@ describe("UBAClient: Flow validation", function () { // LP fee is just the realizedLpFee applied to the amount const expectedLpFee = outflow.amount.mul(outflow.realizedLpFeePct).div(toBNWei(1)); expect(result?.lpFee).to.equal(expectedLpFee); - deepEqualsWithBigNumber(result?.flow, outflow); + deepEqualsWithBigNumber( + result?.flow as unknown as Record, + outflow as unknown as Record + ); // Now, we change the outflow's realizedLpFeePct such that it doesn't match with the deposit, it // should return undefined. diff --git a/test/types/index.ts b/test/types/index.ts index e707c92ef..118c44764 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -2,6 +2,7 @@ import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types"; import type { ethers } from "ethers"; import winston from "winston"; import * as utils from "@across-protocol/contracts-v2/dist/test-utils"; +import { sinon } from "../utils"; export type EthersTestLibrary = typeof ethers & HardhatEthersHelpers; export type SpyLoggerResult = { diff --git a/test/utils/utils.ts b/test/utils/utils.ts index efac50784..f8ad929e5 100644 --- a/test/utils/utils.ts +++ b/test/utils/utils.ts @@ -36,10 +36,13 @@ const assert = chai.assert; export { assert, chai }; export function deepEqualsWithBigNumber( - x: Iterable | Record, - y: Iterable | Record, + x?: Iterable | Record, + y?: Iterable | Record, omitKeys: string[] = [] ): boolean { + if (x === undefined || y === undefined) { + return false; + } const sortedKeysX = Object.fromEntries( Object.keys(x) .sort()