OpenZeppelin / openzeppelin-test-helpers

Assertion library for Ethereum smart contract testing
https://docs.openzeppelin.com/test-helpers
MIT License
416 stars 132 forks source link

Doesn't recognise the latest Hardhat #158

Closed chebykin closed 3 years ago

chebykin commented 3 years ago

The regex doesn't match the current @ethereumjs/vm npm name

@openzeppelin/test-helpers WARN expectRevert: Assertions may yield false negatives!

Revert reason checks are only known to work on Ganache >=2.2.0 and Hardhat, and the current node is HardhatNetwork/2.2.1/@ethereumjs/vm/5.3.2.

If your node does support revert reasons, please let us know: https://github.com/OpenZeppelin/openzeppelin-test-helpers/issues/new
abcoathup commented 3 years ago

Hi @chebykin! I’m sorry that you had this issue.

We have been able to reproduce this issue by following these steps: Using the setup, contract and tests from: https://docs.openzeppelin.com/learn/writing-automated-tests#performing-complex-assertions

npm install --save-dev hardhat
npx hardhat
npm install --save-dev @nomiclabs/hardhat-truffle5 @nomiclabs/hardhat-web3 web3
npm install --save-dev @openzeppelin/test-helpers
$ npx hardhat test

  Contract: Box
    ✓ retrieve returns a value previously stored
    ✓ store emits an event
@openzeppelin/test-helpers WARN expectRevert: Assertions may yield false negatives!

Revert reason checks are only known to work on Ganache >=2.2.0 and Hardhat, and the current node is HardhatNetwork/2.2.1/@ethereumjs/vm/5.3.2.

If your node does support revert reasons, please let us know: https://github.com/OpenZeppelin/openzeppelin-test-helpers/issues/new
    ✓ non owner cannot store a value

  3 passing (599ms)

Thanks so much for reporting it! The project owner will review and triage this issue as soon as they can.

The regex will need to be updated to support @ethereumjs https://github.com/OpenZeppelin/openzeppelin-test-helpers/blob/763b5d139b023cbc74a467b630ec3f31772a76ad/src/expectRevert.js#L36

frangio commented 3 years ago

Can someone please submit the updated regex? I'm not sure what it should look like.

abcoathup commented 3 years ago

Hi @frangio,

The following regex checks for either ethereumjs-vm or @ethereumjs/vm

    const hardhatVersion = /HardhatNetwork\/([\w.-]+)\/(ethereumjs-vm|@ethereumjs\/vm)/.exec(nodeInfo);
frangio commented 3 years ago

Fixed in the latest release.