hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

`test` task and pre-compile issue

Open fvictorio opened this issue 4 years ago • 5 comments

Reproduction steps:

  1. git clone https://github.com/fvictorio/nexusmutual
  2. Install dependencies and run tests twice.
  3. Notice that the error message is different the second time

Another way of doing this is running hh clean && hh test vs hh clean && hh compile && hh test

The reason might be related to this:

task('test', async (_, hre, runSuper) => {
  hre.accounts = await hre.web3.eth.getAccounts();
  const testFiles = _.testFiles.length ? _.testFiles : ['./test/index.js'];
  await runSuper({ testFiles });
});

fvictorio avatar Sep 07 '21 17:09 fvictorio

Output logs for the two tests runs are included next.

First run


Nexus Mutual UNIT TESTS TokenController removeEmptyReason 1) reverts when index is out of bounds

0 passing (357ms) 1 failing

  1. Nexus Mutual UNIT TESTS TokenController removeEmptyReason reverts when index is out of bounds: Error: Transaction reverted without a reason string at <UnrecognizedContract>. (0x5fc8d32690cc91d4c39d9d3abcbd16989f875707) at TruffleContract.removeEmptyReason (node_modules/@nomiclabs/truffle-contract/lib/execute.js:169:26) at Context. (test/unit/TokenController/removeEmptyReason.js:39:27) at processTicksAndRejections (internal/process/task_queues.js:93:5)

Second run


Nexus Mutual UNIT TESTS TokenController removeEmptyReason 1) reverts when index is out of bounds

0 passing (369ms) 1 failing

  1. Nexus Mutual UNIT TESTS TokenController removeEmptyReason reverts when index is out of bounds: Error: VM Exception while processing transaction: invalid opcode at TokenController._removeEmptyReason (contracts/modules/token/TokenController.sol:658) at TokenController.removeEmptyReason (contracts/modules/token/TokenController.sol:636) at TruffleContract.removeEmptyReason (node_modules/@nomiclabs/truffle-contract/lib/execute.js:169:26) at Context. (test/unit/TokenController/removeEmptyReason.js:39:27) at processTicksAndRejections (internal/process/task_queues.js:93:5)

sisco0 avatar Nov 02 '21 01:11 sisco0

@sisco0 you've seem to have fixed something in the reproduction example, but the problem has to be in Hardhat: even if the test is wrong, the fact that the results are inconsistent (in one scenario de test case passes but in the other it doesn't) suggest that there might be a bug on Hardhat's side.

fvictorio avatar Nov 02 '21 12:11 fvictorio

This error is the same one that I mentioned as (1) here, and I've already fixed it. I'll submit a PR tomorrow.

alcuadrado avatar Jan 05 '22 22:01 alcuadrado

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Jul 29 '22 19:07 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Aug 05 '22 19:08 github-actions[bot]

Fixed via #2218

feuGeneA avatar Aug 18 '22 15:08 feuGeneA