Skip to content

Commit

Permalink
missed zero checks
Browse files Browse the repository at this point in the history
  • Loading branch information
bulbozaur committed Nov 22, 2024
1 parent d8d00fe commit 2bc92c4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contracts/TimelockedGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions test/unit/TimelockedGovernance.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 2bc92c4

Please sign in to comment.