Description
Describe the feature
What is the reasoning behind requiring an interface to be passed to revertedWithCustomError
? The error name string itself should be enough to run the assertion.
In my case, the contract I'm testing takes a custom error selector as a parameter and reverts with that error using assembly. The errors do not exist in the contract ABI, so I have to pass in a fake interface to the matcher.
const customError = 'TestError';
const placeholder = {
interface: new ethers.Interface([`error ${ customError }()`]),
};
const selector = placeholder.interface.getError(customError)?.selector!;
await expect(
contract.revertWithCustomErrorSelector(selector),
).to.be.revertedWithCustomError(placeholder, customError);
If this process could be encapsulated within the matcher code, the matcher could be used like this:
await expect(...).to.be.revertedWithCustomError(customError);
// or
await expect(...).to.be.revertedWithCustomError(selector);
Maybe the withArgs
extension needs the full interface to process its arguments. In that case, maybe require the full error signature?
await expect(...).to.be.revertedWithCustomError('TestError(uint256)`);
Search terms
revertedWithCustomError
Similar to #5818, but more specifically related to errors that do not exist on the contract being tested.
Metadata
Metadata
Assignees
Type
Projects
Status