NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.16k stars 1.37k forks source link

expect(...).to.be.reverted doesn't work with manual mining and in-process network #1468

Open fvictorio opened 3 years ago

fvictorio commented 3 years ago

Given this contract:

contract Foo {
  function fail() public {
    require(false);
  }
}

and this test:

const { expect } = require("chai");

it("test", async function() {
  const Foo = await ethers.getContractFactory("Foo");
  const foo = await Foo.deploy();

  await network.provider.send("evm_mine");

  const failTx = foo.fail()

  await network.provider.send("evm_mine");

  await expect(failTx).to.be.reverted
});

Running hh test results in a failure with "AssertionError: Expected transaction to be reverted" but if you run it against hh node with hh test --network localhost then the test passes.

I don't know if the problem is in hardhat, ethers or waffle.

tinypell3ts commented 2 years ago

Did this ever get resolved? Tests are passing on localhost but not testnets.

alcuadrado commented 2 years ago

We haven't got to this issue yet, @coeu5a. But based on the description this doesn't seem related to what you mentioned.

AmitMolek commented 2 years ago

Is there any new info about this issue?