mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
updated tests
This commit is contained in:
parent
6da743e61f
commit
724307243d
|
@ -58,7 +58,7 @@ describe("ZeroEx", function() {
|
||||||
|
|
||||||
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.getAddress());
|
dsaWallet0 = await buildDSAv2(await wallet0.getAddress());
|
||||||
expect(!!dsaWallet0.address).to.be.true;
|
expect(!!dsaWallet0.address).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ describe("ZeroEx", function() {
|
||||||
];
|
];
|
||||||
const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
.connect(wallet0)
|
.connect(wallet0)
|
||||||
.cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), await wallet1.getAddress());
|
||||||
const receipt = await tx.wait();
|
const receipt = await tx.wait();
|
||||||
|
|
||||||
const daiToken = await ethers.getContractAt(
|
const daiToken = await ethers.getContractAt(
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnable
|
||||||
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 { addresses } from "../../../scripts/tests/mainnet/addresses";
|
import { addresses } from "../../../scripts/tests/polygon/addresses";
|
||||||
import { abis } from "../../../scripts/constant/abis";
|
import { abis } from "../../../scripts/constant/abis";
|
||||||
import { ConnectV2ZeroExPolygon, ConnectV2ZeroExPolygon__factory } from "../../../typechain";
|
import { ConnectV2ZeroExPolygon, ConnectV2ZeroExPolygon__factory } from "../../../typechain";
|
||||||
import er20abi from "../../../scripts/constant/abi/basics/erc20.json";
|
import er20abi from "../../../scripts/constant/abi/basics/erc20.json";
|
||||||
|
@ -19,22 +19,23 @@ describe("ZeroEx", function() {
|
||||||
let dsaWallet0: Contract;
|
let dsaWallet0: Contract;
|
||||||
let wallet0: Signer, wallet1: Signer;
|
let wallet0: Signer, wallet1: Signer;
|
||||||
let masterSigner: Signer;
|
let masterSigner: Signer;
|
||||||
let instaConnectorsV2: any;
|
let instaConnectorsV2: Contract;
|
||||||
let connector: any;
|
let connector: Contract;
|
||||||
|
|
||||||
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,
|
},
|
||||||
// },
|
},
|
||||||
// },
|
],
|
||||||
// ],
|
});
|
||||||
// });
|
[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,
|
||||||
|
@ -52,12 +53,12 @@ describe("ZeroEx", function() {
|
||||||
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.getAddress()).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.getAddress());
|
dsaWallet0 = await buildDSAv2(await wallet0.getAddress());
|
||||||
expect(!!dsaWallet0.address).to.be.true;
|
expect(!!dsaWallet0.address).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,7 +79,6 @@ describe("ZeroEx", function() {
|
||||||
let buyTokenAmount: any;
|
let buyTokenAmount: any;
|
||||||
async function getArg() {
|
async function getArg() {
|
||||||
// const slippage = 0.5;
|
// const slippage = 0.5;
|
||||||
|
|
||||||
/* matic -> dai */
|
/* matic -> dai */
|
||||||
const sellTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; // matic, decimals 18
|
const sellTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; // matic, decimals 18
|
||||||
const sellTokenDecimals = 18;
|
const sellTokenDecimals = 18;
|
||||||
|
@ -90,8 +90,6 @@ describe("ZeroEx", function() {
|
||||||
.times(new BigNumber(10).pow(sellTokenDecimals))
|
.times(new BigNumber(10).pow(sellTokenDecimals))
|
||||||
.toFixed(0);
|
.toFixed(0);
|
||||||
|
|
||||||
const fromAddress = dsaWallet0.address;
|
|
||||||
|
|
||||||
let url = `https://polygon.api.0x.org/swap/v1/quote`;
|
let url = `https://polygon.api.0x.org/swap/v1/quote`;
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
|
@ -122,7 +120,6 @@ describe("ZeroEx", function() {
|
||||||
};
|
};
|
||||||
let unitAmt = caculateUnitAmt();
|
let unitAmt = caculateUnitAmt();
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
buyTokenAddress,
|
buyTokenAddress,
|
||||||
sellTokenAddress,
|
sellTokenAddress,
|
||||||
|
@ -143,16 +140,15 @@ describe("ZeroEx", function() {
|
||||||
];
|
];
|
||||||
const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
.connect(wallet0)
|
.connect(wallet0)
|
||||||
.cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), await wallet1.getAddress());
|
||||||
const receipt = await tx.wait();
|
const receipt = await tx.wait();
|
||||||
|
|
||||||
|
const daiToken = await ethers.getContractAt(
|
||||||
const idai = await ethers.getContractAt(
|
|
||||||
er20abi,
|
er20abi,
|
||||||
"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063" // dai address
|
"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063" // dai address
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(await idai.balanceOf(dsaWallet0.address)).to.be.gte(
|
expect(await daiToken.balanceOf(dsaWallet0.address)).to.be.gte(
|
||||||
buyTokenAmount
|
buyTokenAmount
|
||||||
);
|
);
|
||||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user