fixed quickswap tests

This commit is contained in:
pradyuman-verma 2021-12-15 17:52:53 +05:30
parent 99d9d17f23
commit 4f5fb523be
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F

View File

@ -17,7 +17,7 @@ import type { Signer, Contract } from "ethers";
const DAI_ADDR = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"; const DAI_ADDR = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063";
describe("Quickswap", function () { describe("Quickswap", function () {
const connectorName = "Quickpswap-v1.1"; const connectorName = "Quickswap-v1";
let dsaWallet0: Contract; let dsaWallet0: Contract;
let masterSigner: Signer; let masterSigner: Signer;
@ -33,23 +33,20 @@ describe("Quickswap", function() {
{ {
forking: { forking: {
// @ts-ignore // @ts-ignore
jsonRpcUrl: hre.config.networks.hardhat.forking.url, jsonRpcUrl: hre.config.networks.hardhat.forking.url
blockNumber: 13005785, // blockNumber: 13005785
}, }
}, }
], ]
}); });
masterSigner = await getMasterSigner(); masterSigner = await getMasterSigner();
instaConnectorsV2 = await ethers.getContractAt( instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
abis.core.connectorsV2,
addresses.core.connectorsV2
);
connector = await deployAndEnableConnector({ connector = await deployAndEnableConnector({
connectorName, connectorName,
contractArtifact: ConnectV2Quickswap__factory, contractArtifact: ConnectV2Quickswap__factory,
signer: masterSigner, signer: masterSigner,
connectors: instaConnectorsV2, connectors: instaConnectorsV2
}); });
console.log("Connector address", connector.address); console.log("Connector address", connector.address);
}); });
@ -69,42 +66,19 @@ describe("Quickswap", function() {
it("Deposit ETH & DAI into DSA wallet", async function () { it("Deposit ETH & DAI 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("dai", dsaWallet0.address, ethers.utils.parseEther("10000"));
"dai",
dsaWallet0.address,
ethers.utils.parseEther("100000")
);
});
it("Deposit ETH & USDT into DSA wallet", async function() {
await wallet0.sendTransaction({
to: dsaWallet0.address,
value: ethers.utils.parseEther("10"),
});
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
ethers.utils.parseEther("10")
);
await addLiquidity(
"usdt",
dsaWallet0.address,
ethers.utils.parseEther("100000")
);
}); });
}); });
describe("Main", function () { describe("Main", function () {
it("Should deposit successfully", async function () { it("Should deposit successfully", async function () {
const ethAmount = ethers.utils.parseEther("100"); // 1 ETH const ethAmount = ethers.utils.parseEther("0.1"); // 1 ETH
const daiUnitAmount = ethers.utils.parseUnits("4", 6); // 1 ETH const daiUnitAmount = ethers.utils.parseEther("1"); // 1 ETH
const usdtAmount = Number(ethers.utils.parseEther("400")) / Math.pow(10, 12); // 1 ETH const ethAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
const ethAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const getId = "0"; const getId = "0";
const setId = "0"; const setId = "0";
@ -113,26 +87,16 @@ describe("Quickswap", function() {
{ {
connector: connectorName, connector: connectorName,
method: "deposit", method: "deposit",
args: [ args: [ethAddress, DAI_ADDR, ethAmount, daiUnitAmount, "500000000000000000", getId, setId]
ethAddress, }
DAI_ADDR,
ethAmount,
daiUnitAmount,
"500000000000000000",
getId,
setId,
],
},
]; ];
const tx = await dsaWallet0 const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address);
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.address);
let receipt = await tx.wait(); let receipt = await tx.wait();
}).timeout(10000000000); }).timeout(10000000000);
it("Should withdraw successfully", async function () { it("Should withdraw successfully", async function () {
const ethAmount = ethers.utils.parseEther("0.1"); // 1 ETH const ethAmount = ethers.utils.parseEther("0.001"); // 1 ETH
const ethAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; const ethAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
const getId = "0"; const getId = "0";
@ -142,13 +106,11 @@ describe("Quickswap", function() {
{ {
connector: connectorName, connector: connectorName,
method: "withdraw", method: "withdraw",
args: [ethAddress, DAI_ADDR, ethAmount, 0, 0, getId, setIds], args: [ethAddress, DAI_ADDR, ethAmount, 0, 0, getId, setIds]
}, }
]; ];
const tx = await dsaWallet0 const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address);
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.address);
let receipt = await tx.wait(); let receipt = await tx.wait();
}); });
@ -164,13 +126,11 @@ describe("Quickswap", function() {
{ {
connector: connectorName, connector: connectorName,
method: "buy", method: "buy",
args: [ethAddress, DAI_ADDR, ethAmount, daiUnitAmount, getId, setId], args: [ethAddress, DAI_ADDR, ethAmount, daiUnitAmount, getId, setId]
}, }
]; ];
const tx = await dsaWallet0 const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address);
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.address);
let receipt = await tx.wait(); let receipt = await tx.wait();
}); });
}); });