Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
f2cf018e
Unverified
Commit
f2cf018e
authored
Oct 27, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(ctb): Extract module tests vm.warp into _warpPastLivenesInterval
parent
a2b4bae0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
LivenessModule.t.sol
packages/contracts-bedrock/test/LivenessModule.t.sol
+12
-7
No files found.
packages/contracts-bedrock/test/LivenessModule.t.sol
View file @
f2cf018e
...
@@ -35,6 +35,11 @@ contract LivenessModule_TestInit is Test, SafeTestTools {
...
@@ -35,6 +35,11 @@ contract LivenessModule_TestInit is Test, SafeTestTools {
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
}
}
/// @dev Set the current time to after the liveness interval
function _warpPastLivenessInterval() internal {
vm.warp(initTime + livenessInterval + 1);
}
/// @dev Sets up the test environment
/// @dev Sets up the test environment
function setUp() public {
function setUp() public {
// Set the block timestamp to the initTime, so that signatures recorded in the first block
// Set the block timestamp to the initTime, so that signatures recorded in the first block
...
@@ -166,7 +171,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -166,7 +171,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 + 1
);
_warpPastLivenessInterval(
);
vm.expectRevert("LivenessModule: failed to remove owner");
vm.expectRevert("LivenessModule: failed to remove owner");
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
}
}
...
@@ -184,7 +189,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -184,7 +189,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 + 1
);
_warpPastLivenessInterval(
);
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);
}
}
...
@@ -200,7 +205,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -200,7 +205,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
}
}
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
vm.warp(block.timestamp + livenessInterval + 1
);
_warpPastLivenessInterval(
);
vm.expectRevert("LivenessModule: must transfer ownership to fallback owner");
vm.expectRevert("LivenessModule: must transfer ownership to fallback owner");
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
}
}
...
@@ -216,7 +221,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -216,7 +221,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
livenessGuard = new LivenessGuard(safeInstance.safe);
livenessGuard = new LivenessGuard(safeInstance.safe);
safeInstance.setGuard(address(livenessGuard));
safeInstance.setGuard(address(livenessGuard));
vm.warp(block.timestamp + livenessInterval + 1
);
_warpPastLivenessInterval(
);
vm.expectRevert("LivenessModule: guard has been changed");
vm.expectRevert("LivenessModule: guard has been changed");
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
}
}
...
@@ -230,7 +235,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -230,7 +235,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
address(safeInstance.safe), abi.encodeCall(OwnerManager.getThreshold, ()), abi.encode(wrongThreshold)
address(safeInstance.safe), abi.encodeCall(OwnerManager.getThreshold, ()), abi.encode(wrongThreshold)
);
);
vm.warp(block.timestamp + livenessInterval + 1
);
_warpPastLivenessInterval(
);
vm.expectRevert("LivenessModule: Safe must have a threshold of 75% of the number of owners");
vm.expectRevert("LivenessModule: Safe must have a threshold of 75% of the number of owners");
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
}
}
...
@@ -244,7 +249,7 @@ contract LivenessModule_RemoveOwners_Test is LivenessModule_TestInit {
...
@@ -244,7 +249,7 @@ contract LivenessModule_RemoveOwners_Test is LivenessModule_TestInit {
uint256 ownersBefore = safeInstance.owners.length;
uint256 ownersBefore = safeInstance.owners.length;
address ownerToRemove = safeInstance.owners[0];
address ownerToRemove = safeInstance.owners[0];
vm.warp(block.timestamp + livenessInterval + 1
);
_warpPastLivenessInterval(
);
_removeAnOwner(ownerToRemove, safeInstance.owners);
_removeAnOwner(ownerToRemove, safeInstance.owners);
assertFalse(safeInstance.safe.isOwner(ownerToRemove));
assertFalse(safeInstance.safe.isOwner(ownerToRemove));
...
@@ -261,7 +266,7 @@ contract LivenessModule_RemoveOwners_Test is LivenessModule_TestInit {
...
@@ -261,7 +266,7 @@ contract LivenessModule_RemoveOwners_Test is LivenessModule_TestInit {
}
}
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
vm.warp(block.timestamp + livenessInterval + 1
);
_warpPastLivenessInterval(
);
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
assertEq(safeInstance.safe.getOwners().length, 1);
assertEq(safeInstance.safe.getOwners().length, 1);
assertEq(safeInstance.safe.getOwners()[0], fallbackOwner);
assertEq(safeInstance.safe.getOwners()[0], fallbackOwner);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment