From 029b974cd2f777d2b2838823da3ffa1c837d116d Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 14 Mar 2024 14:42:22 +0100 Subject: [PATCH] Fix broken unit tests --- typescript/src/lib/ethereum/bridge.ts | 5 ++++- typescript/src/lib/ethereum/tbtc-token.ts | 5 ++++- typescript/test/lib/ethereum.test.ts | 19 ------------------- typescript/test/services/deposits.test.ts | 15 +++++++++++++-- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index 51f1ee7a6..b27494c5e 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -57,7 +57,10 @@ export class EthereumBridge extends EthersContractHandle implements Bridge { - constructor(config: EthersContractConfig, chainId: Chains.Ethereum) { + constructor( + config: EthersContractConfig, + chainId: Chains.Ethereum = Chains.Ethereum.Local + ) { let deployment: EthersContractDeployment switch (chainId) { diff --git a/typescript/src/lib/ethereum/tbtc-token.ts b/typescript/src/lib/ethereum/tbtc-token.ts index 201c13345..cc6585db2 100644 --- a/typescript/src/lib/ethereum/tbtc-token.ts +++ b/typescript/src/lib/ethereum/tbtc-token.ts @@ -23,7 +23,10 @@ export class EthereumTBTCToken extends EthersContractHandle implements TBTCToken { - constructor(config: EthersContractConfig, chainId: Chains.Ethereum) { + constructor( + config: EthersContractConfig, + chainId: Chains.Ethereum = Chains.Ethereum.Local + ) { let deployment: EthersContractDeployment switch (chainId) { diff --git a/typescript/test/lib/ethereum.test.ts b/typescript/test/lib/ethereum.test.ts index b4fb9650a..92c62404f 100644 --- a/typescript/test/lib/ethereum.test.ts +++ b/typescript/test/lib/ethereum.test.ts @@ -5,7 +5,6 @@ import { EthereumBridge, EthereumTBTCToken, ethereumAddressFromSigner, - ethereumNetworkFromSigner, Hex, } from "../../src" import { @@ -691,22 +690,4 @@ describe("Ethereum", () => { }) }) }) - - describe("ethereumNetworkFromSigner", () => { - context("when the signer is a wallet", () => { - const [mockSigner] = new MockProvider().getWallets() - it("should return the signer's network", async () => { - expect(await ethereumNetworkFromSigner(mockSigner)).to.be.eql("local") - }) - }) - - context("when the signer is a provider", () => { - const mockProvider = getDefaultProvider() - it("should return the signer's network", async () => { - expect(await ethereumNetworkFromSigner(mockProvider)).to.be.eql( - "mainnet" - ) - }) - }) - }) }) diff --git a/typescript/test/services/deposits.test.ts b/typescript/test/services/deposits.test.ts index f7f08879c..50450497e 100644 --- a/typescript/test/services/deposits.test.ts +++ b/typescript/test/services/deposits.test.ts @@ -22,6 +22,7 @@ import { DepositsService, EthereumAddress, extractBitcoinRawTxVectors, + L2Chain, } from "../../src" import { MockBitcoinClient } from "../utils/mock-bitcoin-client" import { MockTBTCContracts } from "../utils/mock-tbtc-contracts" @@ -1620,7 +1621,12 @@ describe("Deposits", () => { let depositService: DepositsService beforeEach(async () => { - depositService = new DepositsService(tbtcContracts, bitcoinClient) + depositService = new DepositsService( + tbtcContracts, + bitcoinClient, + // Mock cross-chain contracts resolver. + (_: L2Chain) => undefined + ) }) context("when default depositor is not set", () => { @@ -1801,7 +1807,12 @@ describe("Deposits", () => { let depositService: DepositsService beforeEach(async () => { - depositService = new DepositsService(tbtcContracts, bitcoinClient) + depositService = new DepositsService( + tbtcContracts, + bitcoinClient, + // Mock cross-chain contracts resolver. + (_: L2Chain) => undefined + ) }) context("when active wallet is not set", () => {