Change the test to verify the actual gas used instead of the buggy estimated gas used

This commit is contained in:
moody salem
2020-04-15 08:25:33 -04:00
parent 6fa21c246d
commit d60d466c83
3 changed files with 7 additions and 4 deletions

View File

@ -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",

View File

@ -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 () => {

View File

@ -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 () => {