OpenZeppelin / openzeppelin-test-environment

[Not actively maintained] One-line setup for blazing-fast smart contracts tests
https://docs.openzeppelin.com/test-environment
MIT License
90 stars 39 forks source link

add hardhat compatibility #142

Closed thegostep closed 3 years ago

frangio commented 3 years ago

Hi @thegostep, I've considered this before and I don't think it's a good idea. Test Environment spins up its own Ganache instance, whereas Hardhat provides its own Hardhat Network, which incidentally provides a lot of extra features that Test Environment with Ganache will never support.

The interface for using Hardhat Network is also very similar, it's possible to use any test runner by including require('hardhat') in your test files, which (as long as there's a Hardhat config) will spin up a Hardhat Network instance and provider.

Would love to hear why you would like to see Hardhat compatibility on this project.

thegostep commented 3 years ago

Really just for convenience of migrating from truffle to hardhat - but I think https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/206 is really what I want

frangio commented 3 years ago

For migrating from Truffle to Hardhat you can take a look at what I did in the recent migration of OpenZeppelin Contracts (although it was from Truffle to Buidler).

For the Upgrades Plugin, it's already been migrated and we just need to update the docs before releasing.

pinglamb commented 3 years ago

@frangio I am trying to use hardhat for compiling contracts and openzeppelin-test-environment for testing. But the contract.fromArtifact doesn't work as the artifacts are not in build/contracts but artifacts. Do you think it make sense for contract-loader to be able to find the artifacts compiled by hardhat?

frangio commented 3 years ago

Hi @pinglamb, you can configure the artifacts directory using the configuration file. But note that this is not enough because Hardhat stores artifacts in subdirectories organized by source file. We don't intend to add Hardhat compatibility to this package. I would recommend using Hardhat's built in test functionality.