From 2e2666b8c43befd119d3062f0c6e576f41ce79af Mon Sep 17 00:00:00 2001 From: Mark Aiken Date: Mon, 13 Dec 2021 22:56:50 -0800 Subject: [PATCH] Address PR feedback --- scripts/tests/addLiquidity.ts | 6 ++--- test/polygon/qidao/qidao.test.ts | 22 ++++++++++--------- .../constant => test/polygon}/qidao/vaults.ts | 0 3 files changed, 15 insertions(+), 13 deletions(-) rename {scripts/constant => test/polygon}/qidao/vaults.ts (100%) diff --git a/scripts/tests/addLiquidity.ts b/scripts/tests/addLiquidity.ts index f820d2a3..20dfc428 100644 --- a/scripts/tests/addLiquidity.ts +++ b/scripts/tests/addLiquidity.ts @@ -8,7 +8,7 @@ const mineTx = async (tx: any) => { }; const tokenMapping: Record = { - eth:{ + mainnet:{ usdc: { impersonateSigner: "0xfcb19e6a322b27c06842a71e8c725399f049ae3a", address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", @@ -76,9 +76,9 @@ const tokenMapping: Record = { } }; -export async function addLiquidity(tokenName: string, address: any, amt: any, chain: string) { +export async function addLiquidity(tokenName: string, address: any, amt: any) { const [signer] = await ethers.getSigners(); - const _chain = chain ? chain : 'eth'; + const _chain = String(process.env.networkType); tokenName = tokenName.toLowerCase(); if (!tokenMapping[_chain][tokenName]) { throw new Error( diff --git a/test/polygon/qidao/qidao.test.ts b/test/polygon/qidao/qidao.test.ts index bbc9c6f1..4daf463f 100644 --- a/test/polygon/qidao/qidao.test.ts +++ b/test/polygon/qidao/qidao.test.ts @@ -1,5 +1,6 @@ import {Contract, Signer} from "ethers"; + const { expect } = require("chai"); const hre = require("hardhat"); const { abis } = require("../../../scripts/constant/abis"); @@ -8,20 +9,20 @@ const { tokens } = require("../../../scripts/tests/polygon/tokens"); const { deployAndEnableConnector } = require("../../../scripts/tests/deployAndEnableConnector"); const { getMasterSigner } = require("../../../scripts/tests/getMasterSigner"); const { buildDSAv2 } = require("../../../scripts/tests/buildDSAv2"); -const ConnectV2QiDaoPolygon = require("../../../artifacts/contracts/polygon/connectors/qidao/main.sol/ConnectV2QiDaoPolygon.json"); +import {ConnectV2QiDaoPolygon__factory} from "../../../typechain"; const { parseEther } = require("@ethersproject/units"); const { encodeSpells } = require("../../../scripts/tests/encodeSpells"); -const { vaults } = require("../../../scripts/constant/qidao/vaults"); +const { vaults } = require("./vaults"); const { addLiquidity } = require("../../../scripts/tests/addLiquidity"); const { ethers } = hre; describe("QiDao", function() { const connectorName = "QIDAO-TEST-A"; - let wallet0: any, wallet1: any; - let dsaWallet0: any; + let wallet0: Signer, wallet1: Signer; + let dsaWallet0: Contract; let instaConnectorsV2: Contract; - let connector: any; + let connector: Contract; let masterSigner: Signer; before(async () => { @@ -30,6 +31,7 @@ describe("QiDao", function() { params: [ { forking: { + // @ts-ignore jsonRpcUrl: hre.config.networks.hardhat.forking.url, }, }, @@ -43,7 +45,7 @@ describe("QiDao", function() { ); connector = await deployAndEnableConnector({ connectorName, - contractArtifact: ConnectV2QiDaoPolygon, + contractArtifact: ConnectV2QiDaoPolygon__factory, signer: masterSigner, connectors: instaConnectorsV2, }); @@ -57,7 +59,7 @@ describe("QiDao", function() { describe("DSA wallet setup", function() { it("Should build DSA v2", async function() { - dsaWallet0 = await buildDSAv2(wallet0.address); + dsaWallet0 = await buildDSAv2(await wallet0.getAddress()); expect(!!dsaWallet0.address).to.be.true; }); @@ -71,7 +73,7 @@ describe("QiDao", function() { ); }); it("Deposit LINK into DSA wallet", async function() { - await addLiquidity("link", dsaWallet0.address, parseEther("100"), "polygon") + await addLiquidity("link", dsaWallet0.address, parseEther("100")); }) }); @@ -110,7 +112,7 @@ describe("QiDao", function() { const tx = await dsaWallet0 .connect(wallet0) - .cast(...encodeSpells(spells), wallet1.address); + .cast(...encodeSpells(spells), await wallet1.getAddress()); await tx.wait(); @@ -154,7 +156,7 @@ describe("QiDao", function() { const tx = await dsaWallet0 .connect(wallet0) - .cast(...encodeSpells(spells), wallet1.address); + .cast(...encodeSpells(spells), await wallet1.getAddress()); await tx.wait(); diff --git a/scripts/constant/qidao/vaults.ts b/test/polygon/qidao/vaults.ts similarity index 100% rename from scripts/constant/qidao/vaults.ts rename to test/polygon/qidao/vaults.ts