Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hardhat version and fix unit tests #178

Merged
merged 8 commits into from
Aug 24, 2021
Merged

Update hardhat version and fix unit tests #178

merged 8 commits into from
Aug 24, 2021

Conversation

tomaszslabon
Copy link
Contributor

@tomaszslabon tomaszslabon commented Aug 23, 2021

Due to an error in Hardhat 2.2.0, we decided to update Hardhat version and fix errors in unit and system tests.

The errors in tests were caused by functions like isOpen, takeOffer, earlyClose being called on auctions that self destructed (the previously used version of Hardhat seemed to tolerate such calls).

This PR contains the following changes:

  • updates hardhat requirement from ^2.1.1 to ^2.2.1 (it seems npm installed the newest version - 2.6.1)
  • adds helper function isCodeAt(address) which checks whether an address stores contract code, which seems to be the best way to check if contract self-destructed
  • uses isCodeAt instead of calling isOpen for checking auction self-destruction or relying on reverts

Note: Unfortunately, in two system tests a significant increase of gas usage was observed.
Note: The contracts themselves were not modified by this PR.

@tomaszslabon tomaszslabon marked this pull request as ready for review August 23, 2021 16:33
test/Auction.test.js Outdated Show resolved Hide resolved
test/system/liquidation.test.js Outdated Show resolved Hide resolved
@@ -180,7 +181,7 @@ describeFn("System -- liquidation", () => {
await expect(parseInt(tx.gasLimit)).to.be.lessThan(518000)

const txReceipt = await ethers.provider.getTransactionReceipt(tx.hash)
await expect(parseInt(txReceipt.gasUsed)).to.be.lessThan(255000)
await expect(parseInt(txReceipt.gasUsed)).to.be.lessThan(400000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised by this increase. Can we check on a local geth instance what is the cost? It is possible that the Hardhat does not properly refund.

package.json Outdated Show resolved Hide resolved
Copy link
Member

@pdyraga pdyraga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good to go. The gas usage question can be answered separately.

@pdyraga pdyraga merged commit dc6ee23 into main Aug 24, 2021
@pdyraga pdyraga deleted the update-hardhat branch August 24, 2021 10:42
@pdyraga pdyraga added this to the solidity/v1.0.0 milestone Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants