Skip to content

Commit

Permalink
Change the test to verify the actual gas used instead of the buggy es…
Browse files Browse the repository at this point in the history
…timated gas used
  • Loading branch information
moodysalem committed Apr 15, 2020
1 parent 6fa21c2 commit d60d466
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"scripts": {
"lint": "yarn prettier ./test/*.ts --check",
"lint:fix": "yarn prettier ./test/*.ts --write",
"clean": "rimraf ./build/",
"precompile": "yarn clean",
"compile": "waffle .waffle.json",
Expand Down
5 changes: 3 additions & 2 deletions test/UniswapV2Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ describe('UniswapV2Factory', () => {
})

it('createPair:gas', async () => {
const gasCost = await factory.estimate.createPair(...TEST_ADDRESSES)
expect(gasCost).to.eq(2512920)
const tx = await factory.createPair(...TEST_ADDRESSES)
const receipt = await tx.wait()
expect(receipt.gasUsed).to.eq(2512920)
})

it('setFeeTo', async () => {
Expand Down
5 changes: 3 additions & 2 deletions test/UniswapV2Pair.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ describe('UniswapV2Pair', () => {
const expectedOutputAmount = bigNumberify('453305446940074565')
await token1.transfer(pair.address, swapAmount)
await mineBlock(provider, (await provider.getBlock('latest')).timestamp + 1)
const gasCost = await pair.estimate.swap(expectedOutputAmount, 0, wallet.address, '0x', overrides)
expect(gasCost).to.eq(79136)
const tx = await pair.swap(expectedOutputAmount, 0, wallet.address, '0x', overrides)
const receipt = await tx.wait()
expect(receipt.gasUsed).to.eq(73462)
})

it('burn', async () => {
Expand Down

0 comments on commit d60d466

Please sign in to comment.