Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behaviour in recent library upgrade. #825

Open
hickscorp opened this issue Mar 6, 2023 · 1 comment
Open

Inconsistent behaviour in recent library upgrade. #825

hickscorp opened this issue Mar 6, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@hickscorp
Copy link

hickscorp commented Mar 6, 2023

We recently upgraded our dependencies like follows:

    "@nomiclabs/hardhat-ethers": "^2.2.1",
    "@nomiclabs/hardhat-waffle": "^2.0.0",
    "@typechain/hardhat": "^6.1.4",

to

    "@nomiclabs/hardhat-ethers": "^2.2.2",
    "@nomiclabs/hardhat-waffle": "^2.0.5",
    "@typechain/hardhat": "^6.1.5",

We use custom errors extensively in our Solidity code. For example:

...
revert ICustomErrors.RequiresMarketplaceActiveMembership(params.governor);
...

Before, we were able to match this nicely in our tests, such as:

await expect(subject).to.be
  .revertedWith(`RequiresMarketplaceActiveMembership("${governor.address}")`);

This was particularly useful as some methods might revert with the same custom error (in this example RequiresMarketplaceActiveMembership but with different parameters, based on what went wrong), and we were able to be very thorough in our tests, making them very resilient and not just "coverage for the sake of it".

It seems that someone thought it could be a good idea to strip anything in parentheses of revert messages, so now we can only match such as:

await expect(subject).to.be
  .revertedWith('RequiresMarketplaceActiveMembership');
@hickscorp hickscorp added the bug Something isn't working label Mar 6, 2023
@yivlad
Copy link
Collaborator

yivlad commented Jul 27, 2023

If you're using hardhat you can check parameters using withArgs matcher.

await expect(matchers.doRevertWithOne())
.to.be.revertedWith('One')
.withArgs(
BigNumber.from('0'), // Check BigNumber instance as well.
'message',
'0x00cfbbaf7ddb3a1476767101c12a0162e241fbad2a0162e2410cfbbaf7162123'
);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants