Commit a51e82f3 authored by Maurelian's avatar Maurelian

feat(ctb): Add constructor check on threshold

parent 7fe44b99
...@@ -54,8 +54,11 @@ contract LivenessModule is ISemver { ...@@ -54,8 +54,11 @@ contract LivenessModule is ISemver {
LIVENESS_INTERVAL = _livenessInterval; LIVENESS_INTERVAL = _livenessInterval;
FALLBACK_OWNER = _fallbackOwner; FALLBACK_OWNER = _fallbackOwner;
MIN_OWNERS = _minOwners; MIN_OWNERS = _minOwners;
address[] memory owners = _safe.getOwners();
require(_minOwners < owners.length, "LivenessModule: minOwners must be less than the number of owners");
require( require(
_minOwners < _safe.getOwners().length, "LivenessModule: minOwners must be less than the number of owners" _safe.getThreshold() == get75PercentThreshold(owners.length),
"LivenessModule: Safe must have a threshold of 75% of the number of owners"
); );
} }
...@@ -161,7 +164,7 @@ contract LivenessModule is ISemver { ...@@ -161,7 +164,7 @@ contract LivenessModule is ISemver {
uint256 threshold = SAFE.getThreshold(); uint256 threshold = SAFE.getThreshold();
require( require(
threshold == get75PercentThreshold(numOwners), threshold == get75PercentThreshold(numOwners),
"LivenessModule: threshold must be 75% of the number of owners" "LivenessModule: Safe must have a threshold of 75% of the number of owners"
); );
// Check that the guard has not been changed // Check that the guard has not been changed
......
...@@ -219,7 +219,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit { ...@@ -219,7 +219,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
ownersToRemove[0] = safeInstance.owners[0]; ownersToRemove[0] = safeInstance.owners[0];
prevOwners[0] = ownersToRemove[0]; // incorrect. prevOwners[0] = ownersToRemove[0]; // incorrect.
vm.warp(block.timestamp + livenessInterval); vm.warp(block.timestamp + livenessInterval + 1);
vm.expectRevert("LivenessModule: failed to remove owner"); vm.expectRevert("LivenessModule: failed to remove owner");
livenessModule.removeOwners(prevOwners, ownersToRemove); livenessModule.removeOwners(prevOwners, ownersToRemove);
} }
...@@ -237,7 +237,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit { ...@@ -237,7 +237,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
// Incorrectly set the final owner to address(0) // Incorrectly set the final owner to address(0)
ownersToRemove[ownersToRemove.length - 1] = address(0); ownersToRemove[ownersToRemove.length - 1] = address(0);
vm.warp(block.timestamp + livenessInterval); vm.warp(block.timestamp + livenessInterval + 1);
vm.expectRevert("LivenessModule: failed to swap to fallback owner"); vm.expectRevert("LivenessModule: failed to swap to fallback owner");
livenessModule.removeOwners(prevOwners, ownersToRemove); livenessModule.removeOwners(prevOwners, ownersToRemove);
} }
...@@ -253,7 +253,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit { ...@@ -253,7 +253,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
} }
address[] memory prevOwners = _getPrevOwners(ownersToRemove); address[] memory prevOwners = _getPrevOwners(ownersToRemove);
vm.warp(block.timestamp + livenessInterval); vm.warp(block.timestamp + livenessInterval + 1);
vm.expectRevert( vm.expectRevert(
"LivenessModule: Safe must have the minimum number of owners or be owned solely by the fallback owner" "LivenessModule: Safe must have the minimum number of owners or be owned solely by the fallback owner"
); );
......
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