From 2f6f66f640e93bd0c4ea649130641092856b5066 Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Sun, 12 Dec 2021 18:51:58 +0530 Subject: [PATCH] fixed mainnet 0x test --- test/mainnet/0x/zeroEx.test.ts | 56 +++++++++++++++------------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/test/mainnet/0x/zeroEx.test.ts b/test/mainnet/0x/zeroEx.test.ts index 6700524b..ec498bf6 100644 --- a/test/mainnet/0x/zeroEx.test.ts +++ b/test/mainnet/0x/zeroEx.test.ts @@ -1,48 +1,42 @@ -import { expect } from "chai"; import hre from "hardhat"; -const { web3, deployments, waffle, ethers } = hre; //check -const { provider, deployContract } = waffle; import axios from "axios"; +import { expect } from "chai"; +const { ethers } = hre; //check import { BigNumber } from "bignumber.js"; -import { ConnectV2ZeroEx, ConnectV2ZeroEx__factory } from "../../../typechain"; - import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector"; import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; import { encodeSpells } from "../../../scripts/tests/encodeSpells"; import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; -import { addLiquidity } from "../../../scripts/tests/addLiquidity"; - import { addresses } from "../../../scripts/tests/mainnet/addresses"; import { abis } from "../../../scripts/constant/abis"; -import { tokens } from "../../../scripts/tests/mainnet/tokens"; -import { constants } from "../../../scripts/constant/constant"; - +import { ConnectV2ZeroEx, ConnectV2ZeroEx__factory } from "../../../typechain"; import er20abi from "../../../scripts/constant/abi/basics/erc20.json"; +import type { Signer, Contract } from "ethers"; describe("ZeroEx", function() { const connectorName = "zeroEx-test"; - let dsaWallet0: any; - let masterSigner: any; + let dsaWallet0: Contract; + let wallet0: Signer, wallet1: Signer; + let masterSigner: Signer; let instaConnectorsV2: any; let connector: any; - const wallets = provider.getWallets(); - const [wallet0, wallet1, wallet2, wallet3] = wallets; - before(async () => { - // await hre.network.provider.request({ - // method: "hardhat_reset", - // params: [ - // { - // forking: { - // // @ts-ignore - // jsonRpcUrl: hre.config.networks.forking.url, - // blockNumber: 13300000, - // }, - // }, - // ], - // }); + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + // @ts-ignore + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 12796965, + }, + }, + ], + }); + [wallet0, wallet1] = await ethers.getSigners(); + masterSigner = await getMasterSigner(); instaConnectorsV2 = await ethers.getContractAt( abis.core.connectorsV2, @@ -54,18 +48,18 @@ describe("ZeroEx", function() { signer: masterSigner, connectors: instaConnectorsV2, }); - // console.log("Connector address", connector.address); + console.log("Connector address", connector.address); }); it("Should have contracts deployed.", async function() { expect(!!instaConnectorsV2.address).to.be.true; expect(!!connector.address).to.be.true; - expect(!!masterSigner.address).to.be.true; + expect(!!(await masterSigner.getAddress())).to.be.true; }); describe("DSA wallet setup", function() { it("Should build DSA v2", async function() { - dsaWallet0 = await buildDSAv2(wallet0.address); + dsaWallet0 = await buildDSAv2(wallet0.getAddress()); expect(!!dsaWallet0.address).to.be.true; }); @@ -160,7 +154,7 @@ describe("ZeroEx", function() { ]; const tx = await dsaWallet0 .connect(wallet0) - .cast(...encodeSpells(spells), wallet1.address); + .cast(...encodeSpells(spells), wallet1.getAddress()); const receipt = await tx.wait(); // console.log(receipt);