Closed robercano closed 1 year ago
Thanks, we will double down on this.
My guess is that Hardhat has updated the way they emit the revert message in localhost and ethereum-waffle is not able to parse it anymore. When unit testing using internal Hardhat, the unit tests work correctly, which tells me it is only a problem when running the local instance of Hardhat.
That sounds like it. We do unit tests against different versions of in-memory Hardhat, but looks like we're gonna have to expand those tests with localhost Hardhat.
@robercano Could you share your exact process of starting the localhost instance of Hardhat? Might come in handy for debugging. (like through npx
, or differently?)
Great! Thanks for the prompt reply.
We are currently using nx
so the actual command line is:
yarn nx run contracts:hardhat-localnode
which in turn executes:
hardhat node --hostname 0.0.0.0
Let me know if you need more context.
Hi @robercano, can you please send some example test where the problem occurs? Because I've reproduced all your steps and I cannot reproduce the error.
I've tried all morning to prepare a repo but I cannot make it fail. I've used the same package.json
and yarn.lock
as in the original repo, but it works properly in the reproduction repo, so I'm not sure what to say. I guess it works and we just have a bad package. I've noticed that the ethers
package package.json
is different in the 2 repos for the same exact version of ethers
, so maybe we cached something wrong. I've tried to remove the cache, update the packages and allow to update the checksums, and more things, but cannot reproduce it in a new repo. In our repo it still fails. I guess you can ignore this until we figure out what's going on! Thanks a lot a sorry for the noise.
Please let me know how things are going and if there is indeed something wrong we will reopen the issue.
Describe the bug When unit testing in a local hardhat node accessible through localhost endpoint with ethereum-waffle 4.0.7, the
to.be.revertedWith
matcher fails with the following reason:Following the code to
revertString.js
it seems thatgetHardhatErrorString
is not able to parse the revert message. Instead thegetGanacheErrorString
is used and an object is returned:Changing the following line in
revertString.js
:to
(notice the double
.data.data
at the end) seems to do the trick.My guess is that Hardhat has updated the way they emit the revert message in localhost and ethereum-waffle is not able to parse it anymore. When unit testing using internal Hardhat, the unit tests work correctly, which tells me it is only a problem when running the local instance of Hardhat.
To Reproduce
revertedWith
matcher to catch a revertSoftware versions
ethereum-waffle
4.0.7@nomiclabs/hardhat-waffle
2.0.3@nomiclabs/hardhat-ethers
2.1.1hardhat
2.12.2