I am trying to test TimelockController contract from Openzeppelin using their test.
The timelockController imports Address.sol, which has a custom Error called FailedCall. Now for my case, I have created my own TimelockController just by inheriting this OZ TimelockController.
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; contract PushTimelockController is TimelockControllerUpgradeable { function initialize( uint256 minDelay, address[] memory proposers, address[] memory executors, address admin ) public initializer { __TimelockController_init(minDelay, proposers, executors, admin); } } The problem now is while expecting some functions to revert with custom error FailedCall using this syntax:
await expect( this.mock .connect(this.executor) .executeBatch( operation.targets, operation.values, operation.payloads, operation.predecessor, operation.salt, ), ).to.be.revertedWithCustomError(this.mock, 'FailedCall'); }) where this.mock is the PushTimelockController, hardhat is unable to locate the custom error, throwing this error:
Error: The given contract doesn't have a custom error named 'FailedCall' This might be because my PushTimelockController is inheriting TimelockController which is using Address.sol, and hardhat is unable to read the custom errors defined in Address.sol.
What can be a workaround? Do I need to get a contract instance of Address.sol just for the errors or is there any other way?