import chai , { expect } from 'chai' ; import { solidity , MockProvider , createFixtureLoader , deployContract } from 'ethereum-waffle' ; import { Contract } from 'ethers' ; import { BigNumber , bigNumberify } from 'ethers/utils' ; import { MaxUint256 } from 'ethers/constants' ; import IUniswapV2Pair from '@uniswap/v2-core/build/IUniswapV2Pair.json' ; import { v2Fixture } from './shared/fixtures' ; import { expandTo18Decimals , getApprovalDigest , MINIMUM_LIQUIDITY } from './shared/utilities' ; import DeflatingERC20 from '../build/DeflatingERC20.json' ; import { ecsign } from 'ethereumjs-util' ; chai . use ( solidity ) ; const overrides = { gasLimit : 9999999 } ; describe ( 'UniswapV2Router02' , ( ) => { const provider = new MockProvider ( { hardfork : 'istanbul' , mnemonic : 'horn horn horn horn horn horn horn horn horn horn horn horn' , gasLimit : 9999999 } ) ; const [ wallet ] = provider . getWallets ( ) ; const loadFixture = createFixtureLoader ( provider , [ wallet ] ) ; let token0 ; let token1 ; let router ; beforeEach ( async function ( ) { const fixture = await loadFixture ( v2Fixture ) ; token0 = fixture . token0 ; token1 = fixture . token1 ; router = fixture . router02 ; } ) ; it ( 'getAmountsOut' , async ( ) => { await token0 . approve ( router . address , MaxUint256 ) ; await token1 . approve ( router . address , MaxUint256 ) ; console . log ( token0 . address , token1 . address , bigNumberify ( 10000 ) , bigNumberify ( 10000 ) , 0 , 0 , wallet . address , MaxUint256 , overrides ) ; await router . addLiquidity ( token0 . address , token1 . address , bigNumberify ( 10000 ) , bigNumberify ( 10000 ) , 0 , 0 , wallet . address , MaxUint256 , overrides ) ; await expect ( router . getAmountsOut ( bigNumberify ( 2 ) , [ token0 . address ] ) ) . to . be . revertedWith ( 'UniswapV2Library: INVALID_PATH' ) ; const path = [ token0 . address , token1 . address ] ; expect ( await router . getAmountsOut ( bigNumberify ( 2 ) , path ) ) . to . deep . eq ( [ bigNumberify ( 2 ) , bigNumberify ( 1 ) ] ) ; } ) ; } ) ;