From c790d683d3fe22d9dcd5eebcd4a6e2d1f4713b79 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 14 Jan 2022 19:38:35 +0530 Subject: [PATCH] minor changes --- scripts/tests/addLiquidity.ts | 12 ++++++------ .../uniswapV3Router/uniswapV3Router.test.ts | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/scripts/tests/addLiquidity.ts b/scripts/tests/addLiquidity.ts index f29d6374..53a75a48 100644 --- a/scripts/tests/addLiquidity.ts +++ b/scripts/tests/addLiquidity.ts @@ -1,6 +1,6 @@ import { Provider } from "@ethersproject/abstract-provider"; import { Signer } from "@ethersproject/abstract-signer"; -import { ethers } from "hardhat"; +import { ethers, network } from "hardhat"; import { impersonateAccounts } from "./impersonate"; const mineTx = async (tx: any) => { @@ -78,11 +78,11 @@ export async function addLiquidity(tokenName: string, address: any, amt: any) { token.impersonateSigner, ]); - // send 1 eth to cover any tx costs. - await signer.sendTransaction({ - to: impersonatedSigner.address, - value: ethers.utils.parseEther("1"), - }); + // send 2 eth to cover any tx costs. + await network.provider.send("hardhat_setBalance", [ + impersonatedSigner.address, + ethers.utils.parseEther("2").toHexString(), + ]); await token.process(impersonatedSigner, address, amt); } diff --git a/test/mainnet/uniswapV3Router/uniswapV3Router.test.ts b/test/mainnet/uniswapV3Router/uniswapV3Router.test.ts index 052f8998..80c87bf8 100644 --- a/test/mainnet/uniswapV3Router/uniswapV3Router.test.ts +++ b/test/mainnet/uniswapV3Router/uniswapV3Router.test.ts @@ -27,6 +27,10 @@ describe("Auto Router", function () { let instaConnectorsV2: 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 () => { await hre.network.provider.request({ method: "hardhat_reset", @@ -112,9 +116,21 @@ describe("Auto Router", function () { 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 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); }); }); });