update test

This commit is contained in:
sanchaymittal 2023-03-13 16:24:10 +07:00
parent 1fc08d8ed1
commit cb32c4faf3
No known key found for this signature in database
GPG Key ID: D794EEBC262F179E

View File

@ -1,12 +1,12 @@
import { expect } from "chai"; import { expect } from "chai";
import hre from "hardhat"; import hre from "hardhat";
const { ethers } = hre; const { ethers, waffle } = hre;
const { provider, deployContract } = waffle;
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/optimism/addresses"; import { addresses } from "../../../scripts/tests/optimism/addresses";
import { abis } from "../../../scripts/constant/abis"; import { abis } from "../../../scripts/constant/abis";
import { ConnectV2ConnextOptimism__factory } from "../../../typechain"; import { ConnectV2ConnextOptimism__factory } from "../../../typechain";
@ -15,7 +15,6 @@ import { Signer, Contract } from "ethers";
describe("Connext Connector [Optimism]", function () { describe("Connext Connector [Optimism]", function () {
const connectorName = "CONNEXT-TEST-A"; const connectorName = "CONNEXT-TEST-A";
let wallet0: Signer, wallet1:Signer;
let dsaWallet0: Contract; let dsaWallet0: Contract;
let masterSigner: Signer; let masterSigner: Signer;
let instaConnectorsV2: Contract; let instaConnectorsV2: Contract;
@ -26,8 +25,11 @@ describe("Connext Connector [Optimism]", function () {
const ethAddr = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; const ethAddr = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const wethAddr = "0x4200000000000000000000000000000000000006"; const wethAddr = "0x4200000000000000000000000000000000000006";
const usdc = new ethers.Contract(usdcAddr, abis.basic.erc20); const wallets = provider.getWallets();
const weth = new ethers.Contract(wethAddr, abis.basic.erc20); const [wallet0, wallet1] = wallets;
// const usdc = new ethers.Contract(usdcAddr, abis.basic.erc20);
// const weth = new ethers.Contract(wethAddr, abis.basic.erc20);
before(async () => { before(async () => {
await hre.network.provider.request({ await hre.network.provider.request({
@ -37,19 +39,14 @@ describe("Connext Connector [Optimism]", function () {
forking: { forking: {
// @ts-ignore // @ts-ignore
jsonRpcUrl: hre.config.networks.hardhat.forking.url, jsonRpcUrl: hre.config.networks.hardhat.forking.url,
blockNumber: 12230000 blockNumber: 7093500
} }
} }
] ]
}); });
[wallet0, wallet1] = await ethers.getSigners();
masterSigner = await getMasterSigner(); masterSigner = await getMasterSigner();
instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
instaConnectorsV2 = await ethers.getContractAt(
abis.core.connectorsV2,
addresses.core.connectorsV2
);
connector = await deployAndEnableConnector({ connector = await deployAndEnableConnector({
connectorName, connectorName,
contractArtifact: ConnectV2ConnextOptimism__factory, contractArtifact: ConnectV2ConnextOptimism__factory,
@ -72,14 +69,12 @@ describe("Connext Connector [Optimism]", function () {
expect(!!dsaWallet0.address).to.be.true; expect(!!dsaWallet0.address).to.be.true;
}); });
it("Deposit ETH & USDC into DSA wallet", async function() { it("Deposit ETH & USDC into DSA wallet", async function () {
await wallet0.sendTransaction({ await wallet0.sendTransaction({
to: dsaWallet0.address, to: dsaWallet0.address,
value: ethers.utils.parseEther("10"), value: ethers.utils.parseEther("10")
}); });
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte( expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10"));
ethers.utils.parseEther("10")
);
// await addLiquidity( // await addLiquidity(
// "usdc", // "usdc",
@ -90,22 +85,19 @@ describe("Connext Connector [Optimism]", function () {
}); });
describe("Main", function () { describe("Main", function () {
it("should xcall with eth", async function () { it("should xcall with eth", async function () {
const amount = ethers.utils.parseEther("10"); const amount = ethers.utils.parseEther("10");
const domainId = 6648936; const domainId = 6648936;
const slippage = 10000; const slippage = 10000;
const relayerFee = ethers.utils.parseEther("1");; const relayerFee = ethers.utils.parseEther("1");
const getId = 0; const getId = 0;
const callData = "0x"; const callData = "0x";
const wallet0Address = await wallet0.getAddress();
const xcallParams: any = [ const xcallParams: any = [
domainId, domainId,
wallet0Address, wallet1.address,
ethAddr, ethAddr,
wallet0Address, wallet1.address,
amount, amount,
slippage, slippage,
relayerFee, relayerFee,
@ -120,7 +112,7 @@ describe("Connext Connector [Optimism]", function () {
} }
]; ];
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet0Address); const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address);
const receipt = await tx.wait(); const receipt = await tx.wait();
}); });
}); });