tests: minor fixes

This commit is contained in:
bhavik 2021-12-30 12:15:18 +05:30
parent aa5d3c3f30
commit a48ab3c0b3

View File

@ -11,13 +11,15 @@ import {
import { encodeSpells } from "../../../scripts/tests/encodeSpells"; import { encodeSpells } from "../../../scripts/tests/encodeSpells";
import BigNumber from "bignumber.js"; import BigNumber from "bignumber.js";
import axios from "axios"; import axios from "axios";
// import { Signer } from "ethers";
const { waffle, ethers } = hre; const { waffle, ethers } = hre;
const { provider, deployContract } = waffle; const { provider, deployContract } = waffle;
import type { Signer, Contract } from "ethers";
describe("Paraswap", function() { describe("Paraswap", function() {
const connectorName = "paraswap-test"; const connectorName = "paraswap-test";
let dsaWallet0: any; let dsaWallet0: any;
let masterSigner: any; let masterSigner: Signer;
let instaConnectorsV2: any; let instaConnectorsV2: Contract;
let connector: any; let connector: any;
const wallets = provider.getWallets(); const wallets = provider.getWallets();
const [wallet0, wallet1] = wallets; const [wallet0, wallet1] = wallets;
@ -29,7 +31,6 @@ describe("Paraswap", function() {
forking: { forking: {
// @ts-ignore // @ts-ignore
jsonRpcUrl: hre.config.networks.hardhat.forking.url, jsonRpcUrl: hre.config.networks.hardhat.forking.url,
}, },
}, },
], ],
@ -50,7 +51,7 @@ describe("Paraswap", 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.address).to.be.true; expect(!!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() {
@ -93,9 +94,9 @@ describe("Paraswap", function() {
network: 137, network: 137,
}; };
const priceRoute = await axios const priceRoute = (await axios
.get(url, { params: params }) .get(url, { params: params })).data.priceRoute
.then((data) => data.data.priceRoute);
let buyTokenAmount = priceRoute.destAmount; let buyTokenAmount = priceRoute.destAmount;
let minAmount = new BigNumber(priceRoute.destAmount) let minAmount = new BigNumber(priceRoute.destAmount)
@ -113,10 +114,8 @@ describe("Paraswap", function() {
userAddress: fromAddress, userAddress: fromAddress,
}; };
let url2 = "https://apiv5.paraswap.io/transactions/137?ignoreChecks=true"; let url2 = "https://apiv5.paraswap.io/transactions/137?ignoreChecks=true";
const calldata = await axios const calldata = (await axios
.post(url2, txConfig) .post(url2, txConfig)).data.data
.then((data) => data.data.data);
// console.log(calldata);
function caculateUnitAmt( function caculateUnitAmt(
buyAmount: any, buyAmount: any,