diff --git a/contracts/TimelockedGovernance.sol b/contracts/TimelockedGovernance.sol index 6cd4ff6..d4df017 100644 --- a/contracts/TimelockedGovernance.sol +++ b/contracts/TimelockedGovernance.sol @@ -10,6 +10,8 @@ import {ExternalCall} from "./libraries/ExternalCalls.sol"; /// @dev A contract that serves as the interface for submitting and scheduling the execution of governance proposals. contract TimelockedGovernance is IGovernance { error CallerIsNotGovernance(address caller); + error InvalidGovernance(address governance); + error InvalidTimelock(address timelock); address public immutable GOVERNANCE; ITimelock public immutable TIMELOCK; @@ -18,6 +20,12 @@ contract TimelockedGovernance is IGovernance { /// @param governance The address of the governance contract. /// @param timelock The address of the timelock contract. constructor(address governance, ITimelock timelock) { + if (governance == address(0)) { + revert InvalidGovernance(governance); + } + if (address(timelock) == address(0)) { + revert InvalidTimelock(address(timelock)); + } GOVERNANCE = governance; TIMELOCK = timelock; } diff --git a/test/unit/TimelockedGovernance.t.sol b/test/unit/TimelockedGovernance.t.sol index a7ad7c7..b711881 100644 --- a/test/unit/TimelockedGovernance.t.sol +++ b/test/unit/TimelockedGovernance.t.sol @@ -22,12 +22,24 @@ contract TimelockedGovernanceUnitTests is UnitTest { } function testFuzz_constructor(address governance, ITimelock timelock) external { + vm.assume(governance != address(0)); + vm.assume(address(timelock) != address(0)); TimelockedGovernance instance = new TimelockedGovernance(governance, timelock); assertEq(instance.GOVERNANCE(), governance); assertEq(address(instance.TIMELOCK()), address(timelock)); } + function test_constructor_RevertOn_invalid_governance() external { + vm.expectRevert(abi.encodeWithSelector(TimelockedGovernance.InvalidGovernance.selector, [address(0)])); + new TimelockedGovernance(address(0), _timelock); + } + + function test_constructor_RevertOn_invalid_timelock() external { + vm.expectRevert(abi.encodeWithSelector(TimelockedGovernance.InvalidTimelock.selector, [address(0)])); + new TimelockedGovernance(_governance, ITimelock(address(0))); + } + function test_submit_proposal() external { assertEq(_timelock.getSubmittedProposals().length, 0);