minor changes

This commit is contained in:
Thrilok Kumar 2022-01-14 19:38:35 +05:30
parent b74ae7b1ef
commit c790d683d3
2 changed files with 23 additions and 7 deletions

View File

@ -1,6 +1,6 @@
import { Provider } from "@ethersproject/abstract-provider"; import { Provider } from "@ethersproject/abstract-provider";
import { Signer } from "@ethersproject/abstract-signer"; import { Signer } from "@ethersproject/abstract-signer";
import { ethers } from "hardhat"; import { ethers, network } from "hardhat";
import { impersonateAccounts } from "./impersonate"; import { impersonateAccounts } from "./impersonate";
const mineTx = async (tx: any) => { const mineTx = async (tx: any) => {
@ -78,11 +78,11 @@ export async function addLiquidity(tokenName: string, address: any, amt: any) {
token.impersonateSigner, token.impersonateSigner,
]); ]);
// send 1 eth to cover any tx costs. // send 2 eth to cover any tx costs.
await signer.sendTransaction({ await network.provider.send("hardhat_setBalance", [
to: impersonatedSigner.address, impersonatedSigner.address,
value: ethers.utils.parseEther("1"), ethers.utils.parseEther("2").toHexString(),
}); ]);
await token.process(impersonatedSigner, address, amt); await token.process(impersonatedSigner, address, amt);
} }

View File

@ -27,6 +27,10 @@ describe("Auto Router", function () {
let instaConnectorsV2: Contract; let instaConnectorsV2: Contract;
let connector: Contract; let connector: Contract;
// @ts-ignore
const provider = new ethers.providers.JsonRpcProvider(hre.config.networks.hardhat.forking.url);
const router = new AlphaRouter({ chainId: 1, provider });
before(async () => { before(async () => {
await hre.network.provider.request({ await hre.network.provider.request({
method: "hardhat_reset", method: "hardhat_reset",
@ -112,9 +116,21 @@ describe("Auto Router", function () {
args: [buyTokenAddress, sellTokenAddress, srcAmount, unitAmt, calldata, 0] args: [buyTokenAddress, sellTokenAddress, srcAmount, unitAmt, calldata, 0]
} }
]; ];
const buyTokenContract = await ethers.getContractAt(
er20abi,
buyTokenAddress,
);
const initialBuyTokenBalance = await buyTokenContract.balanceOf(dsaWallet0.address)
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), await wallet1.getAddress()); const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), await wallet1.getAddress());
const receipt = await tx.wait(); const receipt = await tx.wait();
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("9"));
const finalBuyTokenBalance = await buyTokenContract.balanceOf(dsaWallet0.address)
expect(finalBuyTokenBalance).to.be.gt(initialBuyTokenBalance);
}); });
}); });
}); });