Skip to content

Commit

Permalink
fix remaining tests that used to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahZinsmeister committed Apr 15, 2020
1 parent 7fa2cca commit 5f71058
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
2 changes: 0 additions & 2 deletions test/UniswapV2Migrator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ describe('UniswapV2Migrator', () => {
const [wallet] = provider.getWallets()
const loadFixture = createFixtureLoader(provider, [wallet])

let WETH: Contract
let WETHPartner: Contract
let WETHPair: Contract
let router: Contract
let migrator: Contract
let WETHExchangeV1: Contract
beforeEach(async function() {
const fixture = await loadFixture(v2Fixture)
WETH = fixture.WETH
WETHPartner = fixture.WETHPartner
WETHPair = fixture.WETHPair
router = fixture.router
Expand Down
48 changes: 21 additions & 27 deletions test/UniswapV2Router01.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,14 @@ describe('UniswapV2Router01', () => {
)
.to.emit(WETHPair, 'Transfer')
.withArgs(wallet.address, WETHPair.address, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
// .to.emit(WETHPair, 'Transfer')
// .withArgs(WETHPair.address, AddressZero, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
// .to.emit(WETHPartner, 'Transfer')
// .withArgs(WETHPair.address, router.address, WETHPartnerAmount)
// .to.emit(WETH, 'Transfer')
// .withArgs(WETHPair.address, router.address, ETHAmount)
// .to.emit(WETHPartner, 'Transfer')
// .withArgs(router.address, wallet.address, WETHPartnerAmount)
.to.emit(WETHPair, 'Transfer')
.withArgs(WETHPair.address, AddressZero, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
.to.emit(WETH, 'Transfer')
.withArgs(WETHPair.address, router.address, ETHAmount.sub(2000))
.to.emit(WETHPartner, 'Transfer')
.withArgs(WETHPair.address, router.address, WETHPartnerAmount.sub(500))
.to.emit(WETHPartner, 'Transfer')
.withArgs(router.address, wallet.address, WETHPartnerAmount.sub(500))
.to.emit(WETHPair, 'Sync')
.withArgs(
WETHPairToken0 === WETHPartner.address ? 500 : 2000,
Expand Down Expand Up @@ -364,9 +363,8 @@ describe('UniswapV2Router01', () => {
)
.to.emit(token0, 'Transfer')
.withArgs(wallet.address, pair.address, expectedSwapAmount)
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
// .to.emit(token1, 'Transfer')
// .withArgs(pair.address, wallet.address, outputAmount)
.to.emit(token1, 'Transfer')
.withArgs(pair.address, wallet.address, outputAmount)
.to.emit(pair, 'Sync')
.withArgs(token0Amount.add(expectedSwapAmount), token1Amount.sub(outputAmount))
.to.emit(pair, 'Swap')
Expand All @@ -392,9 +390,8 @@ describe('UniswapV2Router01', () => {
)
.to.emit(WETH, 'Transfer')
.withArgs(router.address, WETHPair.address, swapAmount)
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
// .to.emit(WETHPartner, 'Transfer')
// .withArgs(WETHPair.address, wallet.address, expectedOutputAmount)
.to.emit(WETHPartner, 'Transfer')
.withArgs(WETHPair.address, wallet.address, expectedOutputAmount)
.to.emit(WETHPair, 'Sync')
.withArgs(
WETHPairToken0 === WETHPartner.address
Expand Down Expand Up @@ -459,9 +456,8 @@ describe('UniswapV2Router01', () => {
)
.to.emit(WETHPartner, 'Transfer')
.withArgs(wallet.address, WETHPair.address, expectedSwapAmount)
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
// .to.emit(WETHPartner, 'Transfer')
// .withArgs(WETHPair.address, router.address, outputAmount)
.to.emit(WETH, 'Transfer')
.withArgs(WETHPair.address, router.address, outputAmount)
.to.emit(WETHPair, 'Sync')
.withArgs(
WETHPairToken0 === WETHPartner.address
Expand All @@ -480,7 +476,7 @@ describe('UniswapV2Router01', () => {
)
})

it.skip('swapExactTokensForETH', async () => {
it('swapExactTokensForETH', async () => {
const WETHPartnerAmount = expandTo18Decimals(5)
const ETHAmount = expandTo18Decimals(10)
await WETHPartner.transfer(WETHPair.address, WETHPartnerAmount)
Expand All @@ -504,17 +500,16 @@ describe('UniswapV2Router01', () => {
)
.to.emit(WETHPartner, 'Transfer')
.withArgs(wallet.address, WETHPair.address, swapAmount)
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
// .to.emit(WETH, 'Transfer')
// .withArgs(WETHPair.address, router.address, expectedOutputAmount)
.to.emit(pair, 'Sync')
.to.emit(WETH, 'Transfer')
.withArgs(WETHPair.address, router.address, expectedOutputAmount)
.to.emit(WETHPair, 'Sync')
.withArgs(
WETHPairToken0 === WETHPartner.address
? WETHPartnerAmount.add(swapAmount)
: ETHAmount.sub(expectedOutputAmount),
WETHPairToken0 === WETHPartner.address ? ETHAmount.sub(expectedOutputAmount) : WETHPartnerAmount.add(swapAmount)
)
.to.emit(pair, 'Swap')
.to.emit(WETHPair, 'Swap')
.withArgs(
router.address,
WETHPairToken0 === WETHPartner.address ? swapAmount : 0,
Expand Down Expand Up @@ -544,9 +539,8 @@ describe('UniswapV2Router01', () => {
)
.to.emit(WETH, 'Transfer')
.withArgs(router.address, WETHPair.address, expectedSwapAmount)
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
// .to.emit(WETHPartner, 'Transfer')
// .withArgs(pair.address, wallet.address, outputAmount)
.to.emit(WETHPartner, 'Transfer')
.withArgs(WETHPair.address, wallet.address, outputAmount)
.to.emit(WETHPair, 'Sync')
.withArgs(
WETHPairToken0 === WETHPartner.address
Expand Down

0 comments on commit 5f71058

Please sign in to comment.