fixed mainnet 0x test

This commit is contained in:
pradyuman-verma 2021-12-12 18:51:58 +05:30
parent f6e147290b
commit 2f6f66f640

View File

@ -1,48 +1,42 @@
import { expect } from "chai";
import hre from "hardhat"; import hre from "hardhat";
const { web3, deployments, waffle, ethers } = hre; //check
const { provider, deployContract } = waffle;
import axios from "axios"; import axios from "axios";
import { expect } from "chai";
const { ethers } = hre; //check
import { BigNumber } from "bignumber.js"; import { BigNumber } from "bignumber.js";
import { ConnectV2ZeroEx, ConnectV2ZeroEx__factory } from "../../../typechain";
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector"; import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import { encodeSpells } from "../../../scripts/tests/encodeSpells"; import { encodeSpells } from "../../../scripts/tests/encodeSpells";
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { addLiquidity } from "../../../scripts/tests/addLiquidity";
import { addresses } from "../../../scripts/tests/mainnet/addresses"; import { addresses } from "../../../scripts/tests/mainnet/addresses";
import { abis } from "../../../scripts/constant/abis"; import { abis } from "../../../scripts/constant/abis";
import { tokens } from "../../../scripts/tests/mainnet/tokens"; import { ConnectV2ZeroEx, ConnectV2ZeroEx__factory } from "../../../typechain";
import { constants } from "../../../scripts/constant/constant";
import er20abi from "../../../scripts/constant/abi/basics/erc20.json"; import er20abi from "../../../scripts/constant/abi/basics/erc20.json";
import type { Signer, Contract } from "ethers";
describe("ZeroEx", function() { describe("ZeroEx", function() {
const connectorName = "zeroEx-test"; const connectorName = "zeroEx-test";
let dsaWallet0: any; let dsaWallet0: Contract;
let masterSigner: any; let wallet0: Signer, wallet1: Signer;
let masterSigner: Signer;
let instaConnectorsV2: any; let instaConnectorsV2: any;
let connector: any; let connector: any;
const wallets = provider.getWallets();
const [wallet0, wallet1, wallet2, wallet3] = wallets;
before(async () => { before(async () => {
// await hre.network.provider.request({ await hre.network.provider.request({
// method: "hardhat_reset", method: "hardhat_reset",
// params: [ params: [
// { {
// forking: { forking: {
// // @ts-ignore // @ts-ignore
// jsonRpcUrl: hre.config.networks.forking.url, jsonRpcUrl: hre.config.networks.hardhat.forking.url,
// blockNumber: 13300000, blockNumber: 12796965,
// }, },
// }, },
// ], ],
// }); });
[wallet0, wallet1] = await ethers.getSigners();
masterSigner = await getMasterSigner(); masterSigner = await getMasterSigner();
instaConnectorsV2 = await ethers.getContractAt( instaConnectorsV2 = await ethers.getContractAt(
abis.core.connectorsV2, abis.core.connectorsV2,
@ -54,18 +48,18 @@ describe("ZeroEx", function() {
signer: masterSigner, signer: masterSigner,
connectors: instaConnectorsV2, connectors: instaConnectorsV2,
}); });
// console.log("Connector address", connector.address); console.log("Connector address", connector.address);
}); });
it("Should have contracts deployed.", async function() { it("Should have contracts deployed.", async function() {
expect(!!instaConnectorsV2.address).to.be.true; expect(!!instaConnectorsV2.address).to.be.true;
expect(!!connector.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() { describe("DSA wallet setup", function() {
it("Should build DSA v2", async function() { it("Should build DSA v2", async function() {
dsaWallet0 = await buildDSAv2(wallet0.address); dsaWallet0 = await buildDSAv2(wallet0.getAddress());
expect(!!dsaWallet0.address).to.be.true; expect(!!dsaWallet0.address).to.be.true;
}); });
@ -160,7 +154,7 @@ describe("ZeroEx", function() {
]; ];
const tx = await dsaWallet0 const tx = await dsaWallet0
.connect(wallet0) .connect(wallet0)
.cast(...encodeSpells(spells), wallet1.address); .cast(...encodeSpells(spells), wallet1.getAddress());
const receipt = await tx.wait(); const receipt = await tx.wait();
// console.log(receipt); // console.log(receipt);