Commit 854db439 authored by Maurelian's avatar Maurelian

feat(ctb): LivenessGuard record current owners in constructor

parent a51e82f3
...@@ -45,6 +45,12 @@ contract LivenessGuard is ISemver, BaseGuard { ...@@ -45,6 +45,12 @@ contract LivenessGuard is ISemver, BaseGuard {
/// @param _safe The safe account for which this contract will be the guard. /// @param _safe The safe account for which this contract will be the guard.
constructor(Safe _safe) { constructor(Safe _safe) {
SAFE = _safe; SAFE = _safe;
address[] memory owners = _safe.getOwners();
for (uint256 i = 0; i < owners.length; i++) {
address owner = owners[i];
lastLive[owner] = block.timestamp;
emit OwnerRecorded(0x0, owner);
}
} }
/// @notice Internal function to ensure that only the Safe can call certain functions. /// @notice Internal function to ensure that only the Safe can call certain functions.
......
...@@ -15,17 +15,29 @@ contract LivenessGuard_TestInit is Test, SafeTestTools { ...@@ -15,17 +15,29 @@ contract LivenessGuard_TestInit is Test, SafeTestTools {
event OwnerRecorded(bytes32 indexed txHash, address signer); event OwnerRecorded(bytes32 indexed txHash, address signer);
uint256 initTime = 10;
LivenessGuard livenessGuard; LivenessGuard livenessGuard;
SafeInstance safeInstance; SafeInstance safeInstance;
/// @dev Sets up the test environment /// @dev Sets up the test environment
function setUp() public { function setUp() public {
vm.warp(initTime);
safeInstance = _setupSafe(); safeInstance = _setupSafe();
livenessGuard = new LivenessGuard(safeInstance.safe); livenessGuard = new LivenessGuard(safeInstance.safe);
safeInstance.setGuard(address(livenessGuard)); safeInstance.setGuard(address(livenessGuard));
} }
} }
contract LivenessGuard_Constructor_Test is LivenessGuard_TestInit {
function test_constructor_works() external {
address[] memory owners = safeInstance.owners;
livenessGuard = new LivenessGuard(safeInstance.safe);
for (uint256 i = 0; i < owners.length; i++) {
assertEq(livenessGuard.lastLive(owners[i]), initTime);
}
}
}
contract LivenessGuard_Getters_Test is LivenessGuard_TestInit { contract LivenessGuard_Getters_Test is LivenessGuard_TestInit {
/// @dev Tests that the getters return the correct values /// @dev Tests that the getters return the correct values
function test_getters_works() external { function test_getters_works() external {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment