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
a3d3ae3e
Unverified
Commit
a3d3ae3e
authored
Oct 30, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
module console.log cleanup
parent
515de0eb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
58 deletions
+36
-58
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+10
-10
LivenessGuard.t.sol
packages/contracts-bedrock/test/LivenessGuard.t.sol
+7
-7
LivenessModule.t.sol
packages/contracts-bedrock/test/LivenessModule.t.sol
+13
-26
SafeSigners.t.sol
packages/contracts-bedrock/test/SafeSigners.t.sol
+2
-2
SafeTestTools.sol
packages/contracts-bedrock/test/safe-tools/SafeTestTools.sol
+4
-13
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
a3d3ae3e
...
@@ -311,8 +311,8 @@ LivenessGuard_CheckTx_TestFails:test_checkTransaction_callerIsNotSafe_revert() (
...
@@ -311,8 +311,8 @@ LivenessGuard_CheckTx_TestFails:test_checkTransaction_callerIsNotSafe_revert() (
LivenessGuard_Constructor_Test:test_constructor_works() (gas: 1198965)
LivenessGuard_Constructor_Test:test_constructor_works() (gas: 1198965)
LivenessGuard_Getters_Test:test_getters_works() (gas: 10662)
LivenessGuard_Getters_Test:test_getters_works() (gas: 10662)
LivenessGuard_OwnerManagement_Test:test_addOwner_succeeds() (gas: 274366)
LivenessGuard_OwnerManagement_Test:test_addOwner_succeeds() (gas: 274366)
LivenessGuard_OwnerManagement_Test:test_removeOwner_succeeds() (gas: 24
6263
)
LivenessGuard_OwnerManagement_Test:test_removeOwner_succeeds() (gas: 24
3684
)
LivenessGuard_OwnerManagement_Test:test_swapOwner_succeeds() (gas: 28
4880
)
LivenessGuard_OwnerManagement_Test:test_swapOwner_succeeds() (gas: 28
2299
)
LivenessGuard_ShowLiveness_Test:test_showLiveness_succeeds() (gas: 28831)
LivenessGuard_ShowLiveness_Test:test_showLiveness_succeeds() (gas: 28831)
LivenessGuard_ShowLiveness_TestFail:test_showLiveness_callIsNotSafeOwner_reverts() (gas: 18770)
LivenessGuard_ShowLiveness_TestFail:test_showLiveness_callIsNotSafeOwner_reverts() (gas: 18770)
LivenessModule_CanRemove_Test:test_canRemove_works() (gas: 33026)
LivenessModule_CanRemove_Test:test_canRemove_works() (gas: 33026)
...
@@ -321,16 +321,16 @@ LivenessModule_Constructor_TestFail:test_constructor_minOwnersGreaterThanOwners_
...
@@ -321,16 +321,16 @@ LivenessModule_Constructor_TestFail:test_constructor_minOwnersGreaterThanOwners_
LivenessModule_Constructor_TestFail:test_constructor_wrongThreshold_reverts() (gas: 92925)
LivenessModule_Constructor_TestFail:test_constructor_wrongThreshold_reverts() (gas: 92925)
LivenessModule_Get75PercentThreshold_Test:test_get75PercentThreshold_Works() (gas: 26339)
LivenessModule_Get75PercentThreshold_Test:test_get75PercentThreshold_Works() (gas: 26339)
LivenessModule_Getters_Test:test_getters_works() (gas: 14853)
LivenessModule_Getters_Test:test_getters_works() (gas: 14853)
LivenessModule_RemoveOwners_Test:test_removeOwners_allOwners_succeeds() (gas: 13
26177
)
LivenessModule_RemoveOwners_Test:test_removeOwners_allOwners_succeeds() (gas: 13
16393
)
LivenessModule_RemoveOwners_Test:test_removeOwners_oneOwner_succeeds() (gas: 13
3975
)
LivenessModule_RemoveOwners_Test:test_removeOwners_oneOwner_succeeds() (gas: 13
0750
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_belowEmptiedButNotShutDown_reverts() (gas: 12
78643
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_belowEmptiedButNotShutDown_reverts() (gas: 12
69598
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_belowMinButNotEmptied_reverts() (gas: 12
81685
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_belowMinButNotEmptied_reverts() (gas: 12
73409
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_differentArrayLengths_reverts() (gas: 10502)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_differentArrayLengths_reverts() (gas: 10502)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_guardChanged_reverts() (gas: 283
9358
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_guardChanged_reverts() (gas: 283
6129
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_invalidThreshold_reverts() (gas: 69358)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_invalidThreshold_reverts() (gas: 69358)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_ownerHasShownLivenessRecently_reverts() (gas:
80971
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_ownerHasShownLivenessRecently_reverts() (gas:
77749
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_ownerHasSignedRecently_reverts() (gas: 61
7629
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_ownerHasSignedRecently_reverts() (gas: 61
5047
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_swapToFallbackOwner_reverts() (gas: 12
88036
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_swapToFallbackOwner_reverts() (gas: 12
78252
)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_wrongPreviousOwner_reverts() (gas: 73954)
LivenessModule_RemoveOwners_TestFail:test_removeOwners_wrongPreviousOwner_reverts() (gas: 73954)
MIPS_Test:test_add_succeeds() (gas: 122932)
MIPS_Test:test_add_succeeds() (gas: 122932)
MIPS_Test:test_addiSign_succeeds() (gas: 122923)
MIPS_Test:test_addiSign_succeeds() (gas: 122923)
...
...
packages/contracts-bedrock/test/LivenessGuard.t.sol
View file @
a3d3ae3e
...
@@ -47,7 +47,7 @@ contract LivenessGuard_Constructor_Test is LivenessGuard_TestInit {
...
@@ -47,7 +47,7 @@ contract LivenessGuard_Constructor_Test is LivenessGuard_TestInit {
function test_constructor_works() external {
function test_constructor_works() external {
address[] memory owners = safeInstance.owners;
address[] memory owners = safeInstance.owners;
livenessGuard = new WrappedGuard(safeInstance.safe);
livenessGuard = new WrappedGuard(safeInstance.safe);
for (uint256 i
= 0
; i < owners.length; i++) {
for (uint256 i; i < owners.length; i++) {
assertEq(livenessGuard.lastLive(owners[i]), initTime);
assertEq(livenessGuard.lastLive(owners[i]), initTime);
}
}
}
}
...
@@ -242,7 +242,7 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
...
@@ -242,7 +242,7 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
(address[] memory ownerAddrs, uint256[] memory ownerkeys) =
(address[] memory ownerAddrs, uint256[] memory ownerkeys) =
SafeTestLib.makeAddrsAndKeys("safeTest", initialOwners);
SafeTestLib.makeAddrsAndKeys("safeTest", initialOwners);
// record the private keys for later use
// record the private keys for later use
for (uint256 i
= 0
; i < ownerAddrs.length; i++) {
for (uint256 i; i < ownerAddrs.length; i++) {
privateKeys[ownerAddrs[i]] = ownerkeys[i];
privateKeys[ownerAddrs[i]] = ownerkeys[i];
}
}
...
@@ -251,7 +251,7 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
...
@@ -251,7 +251,7 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
livenessGuard = new WrappedGuard(safeInstance.safe);
livenessGuard = new WrappedGuard(safeInstance.safe);
safeInstance.setGuard(address(livenessGuard));
safeInstance.setGuard(address(livenessGuard));
for (uint256 i
= 0
; i < changes.length; i++) {
for (uint256 i; i < changes.length; i++) {
vm.warp(block.timestamp + changes[i].timeDelta);
vm.warp(block.timestamp + changes[i].timeDelta);
OwnerChange memory change = changes[i];
OwnerChange memory change = changes[i];
address[] memory currentOwners = safeInstance.safe.getOwners();
address[] memory currentOwners = safeInstance.safe.getOwners();
...
@@ -312,16 +312,16 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
...
@@ -312,16 +312,16 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
// Looks up the private key for each owner
// Looks up the private key for each owner
uint256[] memory unsortedOwnerPKs = new uint256[](instance.owners.length);
uint256[] memory unsortedOwnerPKs = new uint256[](instance.owners.length);
for (uint256
j = 0; j < instance.owners.length; j
++) {
for (uint256
i; i < instance.owners.length; i
++) {
unsortedOwnerPKs[
j] = privateKeys[instance.owners[j
]];
unsortedOwnerPKs[
i] = privateKeys[instance.owners[i
]];
}
}
// Sort the keys by address and store them in the SafeInstance
// Sort the keys by address and store them in the SafeInstance
instance.ownerPKs = SafeTestLib.sortPKsByComputedAddress(unsortedOwnerPKs);
instance.ownerPKs = SafeTestLib.sortPKsByComputedAddress(unsortedOwnerPKs);
// Overwrite the SafeInstances owners array with the computed addresses from the ownerPKs array
// Overwrite the SafeInstances owners array with the computed addresses from the ownerPKs array
for (uint256
k; k < instance.owners.length; k
++) {
for (uint256
i; i < instance.owners.length; i
++) {
instance.owners[
k] = SafeTestLib.getAddr(instance.ownerPKs[k
]);
instance.owners[
i] = SafeTestLib.getAddr(instance.ownerPKs[i
]);
}
}
}
}
}
}
packages/contracts-bedrock/test/LivenessModule.t.sol
View file @
a3d3ae3e
...
@@ -199,7 +199,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -199,7 +199,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
uint256 numOwners = safeInstance.owners.length;
uint256 numOwners = safeInstance.owners.length;
address[] memory ownersToRemove = new address[](numOwners);
address[] memory ownersToRemove = new address[](numOwners);
for (uint256 i
= 0
; i < numOwners; i++) {
for (uint256 i; i < numOwners; i++) {
ownersToRemove[i] = safeInstance.owners[i];
ownersToRemove[i] = safeInstance.owners[i];
}
}
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
...
@@ -218,7 +218,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -218,7 +218,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
uint256 numOwners = safeInstance.owners.length - 2;
uint256 numOwners = safeInstance.owners.length - 2;
address[] memory ownersToRemove = new address[](numOwners);
address[] memory ownersToRemove = new address[](numOwners);
for (uint256 i
= 0
; i < numOwners; i++) {
for (uint256 i; i < numOwners; i++) {
ownersToRemove[i] = safeInstance.owners[i];
ownersToRemove[i] = safeInstance.owners[i];
}
}
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
...
@@ -236,7 +236,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -236,7 +236,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
uint256 numOwners = safeInstance.owners.length - 1;
uint256 numOwners = safeInstance.owners.length - 1;
address[] memory ownersToRemove = new address[](numOwners);
address[] memory ownersToRemove = new address[](numOwners);
for (uint256 i
= 0
; i < numOwners; i++) {
for (uint256 i; i < numOwners; i++) {
ownersToRemove[i] = safeInstance.owners[i];
ownersToRemove[i] = safeInstance.owners[i];
}
}
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
...
@@ -297,7 +297,7 @@ contract LivenessModule_RemoveOwners_Test is LivenessModule_TestInit {
...
@@ -297,7 +297,7 @@ contract LivenessModule_RemoveOwners_Test is LivenessModule_TestInit {
uint256 numOwners = safeInstance.owners.length;
uint256 numOwners = safeInstance.owners.length;
address[] memory ownersToRemove = new address[](numOwners);
address[] memory ownersToRemove = new address[](numOwners);
for (uint256 i
= 0
; i < numOwners; i++) {
for (uint256 i; i < numOwners; i++) {
ownersToRemove[i] = safeInstance.owners[i];
ownersToRemove[i] = safeInstance.owners[i];
}
}
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
address[] memory prevOwners = safeInstance.getPrevOwners(ownersToRemove);
...
@@ -348,15 +348,12 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
...
@@ -348,15 +348,12 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
//
//
// _numOwners must be at least 4, so that _minOwners can be set to at least 3 by the following bound() call.
// _numOwners must be at least 4, so that _minOwners can be set to at least 3 by the following bound() call.
// Limiting the owner set to 20 helps to keep the runtime of the test reasonable.
// Limiting the owner set to 20 helps to keep the runtime of the test reasonable.
console.log("bounding numOwners");
numOwners_ = bound(_numOwners, 4, 20);
numOwners_ = bound(_numOwners, 4, 20);
// _minOwners must be at least 3, otherwise we don't have any range below _minOwners in which to test all of the
// _minOwners must be at least 3, otherwise we don't have any range below _minOwners in which to test all of the
// ShutDownBehavior options.
// ShutDownBehavior options.
console.log("bounding minOwners");
minOwners_ = bound(_minOwners, 3, numOwners_ - 1);
minOwners_ = bound(_minOwners, 3, numOwners_ - 1);
// Ensure that _numLiveOwners is less than _numOwners so that we can remove at least one owner.
// Ensure that _numLiveOwners is less than _numOwners so that we can remove at least one owner.
console.log("bounding numLiveOwners");
numLiveOwners_ = bound(_numLiveOwners, 0, numOwners_ - 1);
numLiveOwners_ = bound(_numLiveOwners, 0, numOwners_ - 1);
// The above bounds are a bit tricky, so we assert that the resulting parameters enable us to test all possible
// The above bounds are a bit tricky, so we assert that the resulting parameters enable us to test all possible
...
@@ -402,20 +399,19 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
...
@@ -402,20 +399,19 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
// Create an array of live owners, and call showLiveness for each of them
// Create an array of live owners, and call showLiveness for each of them
address[] memory liveOwners = new address[](numLiveOwners);
address[] memory liveOwners = new address[](numLiveOwners);
for (uint256 i
= 0
; i < numLiveOwners; i++) {
for (uint256 i; i < numLiveOwners; i++) {
liveOwners[i] = safeInstance.owners[i];
liveOwners[i] = safeInstance.owners[i];
vm.prank(safeInstance.owners[i]);
vm.prank(safeInstance.owners[i]);
livenessGuard.showLiveness();
livenessGuard.showLiveness();
}
}
address[] memory nonLiveOwners = new address[](numOwners - numLiveOwners);
address[] memory nonLiveOwners = new address[](numOwners - numLiveOwners);
for (uint256 i
= 0
; i < numOwners - numLiveOwners; i++) {
for (uint256 i; i < numOwners - numLiveOwners; i++) {
nonLiveOwners[i] = safeInstance.owners[i + numLiveOwners];
nonLiveOwners[i] = safeInstance.owners[i + numLiveOwners];
}
}
address[] memory prevOwners;
address[] memory prevOwners;
if (numLiveOwners >= minOwners) {
if (numLiveOwners >= minOwners) {
console.log("No shutdown");
// The safe will remain above the minimum number of owners, so we can remove only those owners which are not
// The safe will remain above the minimum number of owners, so we can remove only those owners which are not
// live.
// live.
prevOwners = safeInstance.getPrevOwners(nonLiveOwners);
prevOwners = safeInstance.getPrevOwners(nonLiveOwners);
...
@@ -424,10 +420,10 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
...
@@ -424,10 +420,10 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
// Validate the resulting state of the Safe
// Validate the resulting state of the Safe
assertEq(safeInstance.safe.getOwners().length, numLiveOwners);
assertEq(safeInstance.safe.getOwners().length, numLiveOwners);
assertEq(safeInstance.safe.getThreshold(), get75PercentThreshold(numLiveOwners));
assertEq(safeInstance.safe.getThreshold(), get75PercentThreshold(numLiveOwners));
for (uint256 i
= 0
; i < numLiveOwners; i++) {
for (uint256 i; i < numLiveOwners; i++) {
assertTrue(safeInstance.safe.isOwner(liveOwners[i]));
assertTrue(safeInstance.safe.isOwner(liveOwners[i]));
}
}
for (uint256 i
= 0
; i < nonLiveOwners.length; i++) {
for (uint256 i; i < nonLiveOwners.length; i++) {
assertFalse(safeInstance.safe.isOwner(nonLiveOwners[i]));
assertFalse(safeInstance.safe.isOwner(nonLiveOwners[i]));
}
}
} else {
} else {
...
@@ -439,14 +435,10 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
...
@@ -439,14 +435,10 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
// The safe is below the minimum number of owners.
// The safe is below the minimum number of owners.
// The ShutDownBehavior enum determines how we handle this case.
// The ShutDownBehavior enum determines how we handle this case.
if (shutDownBehavior == ShutDownBehavior.Correct) {
if (shutDownBehavior == ShutDownBehavior.Correct) {
console.log("Correct Shutdown");
// We remove all owners, and transfer ownership to the shutDown owner.
// We remove all owners, and transfer ownership to the shutDown owner.
// but we need to do remove the non-live owners first, so we reverse the owners array, since
// but we need to do remove the non-live owners first, so we reverse the owners array, since
// the first owners in the array were the ones to call showLiveness.
// the first owners in the array were the ones to call showLiveness.
// ownersToRemove = new address[](numOwners);
for (uint256 i; i < numOwners; i++) {
for (uint256 i = 0; i < numOwners; i++) {
// ownersToRemove[numOwners - i - 1] = safeInstance.owners[i];
// ownersToRemove[i] = safeInstance.owners[numOwners - i - 1];
ownersToRemove.push(safeInstance.owners[numOwners - i - 1]);
ownersToRemove.push(safeInstance.owners[numOwners - i - 1]);
}
}
prevOwners = safeInstance.getPrevOwners(ownersToRemove);
prevOwners = safeInstance.getPrevOwners(ownersToRemove);
...
@@ -461,14 +453,11 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
...
@@ -461,14 +453,11 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
// trigger that behavior. We initialize that value here then set it in the if statements below.
// trigger that behavior. We initialize that value here then set it in the if statements below.
uint256 numOwnersToRemoveinShutDown;
uint256 numOwnersToRemoveinShutDown;
if (shutDownBehavior == ShutDownBehavior.DoesNotRemoveAllOwners) {
if (shutDownBehavior == ShutDownBehavior.DoesNotRemoveAllOwners) {
console.log("Shutdown DoesNotRemoveAllOwners");
// In the DoesNotRemoveAllOwners case, we should have more than 1 of the pre-existing owners
// In the DoesNotRemoveAllOwners case, we should have more than 1 of the pre-existing owners
// remaining
// remaining
console.log("bounding numOwnersToRemoveinShutDown");
numOwnersToRemoveinShutDown =
numOwnersToRemoveinShutDown =
bound(_numOwnersToRemoveinShutDown, numOwners - minOwners + 1, numOwners - 2);
bound(_numOwnersToRemoveinShutDown, numOwners - minOwners + 1, numOwners - 2);
uint256 i = 0;
for (uint256 i; i < numOwnersToRemoveinShutDown; i++) {
for (i; i < numOwnersToRemoveinShutDown; i++) {
// Add non-live owners to remove first
// Add non-live owners to remove first
if (i < nonLiveOwners.length) {
if (i < nonLiveOwners.length) {
ownersToRemove.push(nonLiveOwners[i]);
ownersToRemove.push(nonLiveOwners[i]);
...
@@ -483,11 +472,9 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
...
@@ -483,11 +472,9 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
);
);
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
} else if (shutDownBehavior == ShutDownBehavior.DoesNotTransferToFallbackOwner) {
} else if (shutDownBehavior == ShutDownBehavior.DoesNotTransferToFallbackOwner) {
console.log("Shutdown DoesNotTransferToFallbackOwner");
// In the DoesNotRemoveAllOwners case, we should have exactly 1 pre-existing owners remaining
// In the DoesNotRemoveAllOwners case, we should have exactly 1 pre-existing owners remaining
numOwnersToRemoveinShutDown = numOwners - 1;
numOwnersToRemoveinShutDown = numOwners - 1;
uint256 i = 0;
for (uint256 i; i < numOwnersToRemoveinShutDown; i++) {
for (i; i < numOwnersToRemoveinShutDown; i++) {
// Add non-live owners to remove first
// Add non-live owners to remove first
if (i < nonLiveOwners.length) {
if (i < nonLiveOwners.length) {
ownersToRemove.push(nonLiveOwners[i]);
ownersToRemove.push(nonLiveOwners[i]);
...
@@ -503,8 +490,8 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
...
@@ -503,8 +490,8 @@ contract LivenessModule_RemoveOwnersFuzz_Test is LivenessModule_TestInit {
// For both of the incorrect behaviors, verify no change to the Safe state
// For both of the incorrect behaviors, verify no change to the Safe state
assertEq(safeInstance.safe.getOwners().length, numOwners);
assertEq(safeInstance.safe.getOwners().length, numOwners);
assertEq(safeInstance.safe.getThreshold(), get75PercentThreshold(numOwners));
assertEq(safeInstance.safe.getThreshold(), get75PercentThreshold(numOwners));
for (uint256
j = 0; j < numOwners; j
++) {
for (uint256
i; i < numOwners; i
++) {
assertTrue(safeInstance.safe.isOwner(safeInstance.owners[
j
]));
assertTrue(safeInstance.safe.isOwner(safeInstance.owners[
i
]));
}
}
}
}
}
}
...
...
packages/contracts-bedrock/test/SafeSigners.t.sol
View file @
a3d3ae3e
...
@@ -40,7 +40,7 @@ contract SafeSigners_Test is Test, SafeTestTools {
...
@@ -40,7 +40,7 @@ contract SafeSigners_Test is Test, SafeTestTools {
uint256 numSigs = bound(_numSigs, 1, 25);
uint256 numSigs = bound(_numSigs, 1, 25);
(, uint256[] memory keys) = SafeTestLib.makeAddrsAndKeys("getSigsTest", numSigs);
(, uint256[] memory keys) = SafeTestLib.makeAddrsAndKeys("getSigsTest", numSigs);
for (uint256 i
= 0
; i < keys.length; i++) {
for (uint256 i; i < keys.length; i++) {
if (sigType(keys[i]) == SigTypes.Contract) {
if (sigType(keys[i]) == SigTypes.Contract) {
keys[i] =
keys[i] =
SafeTestLib.encodeSmartContractWalletAsPK(SafeTestLib.decodeSmartContractWalletAsAddress(keys[i]));
SafeTestLib.encodeSmartContractWalletAsPK(SafeTestLib.decodeSmartContractWalletAsAddress(keys[i]));
...
@@ -91,7 +91,7 @@ contract SafeSigners_Test is Test, SafeTestTools {
...
@@ -91,7 +91,7 @@ contract SafeSigners_Test is Test, SafeTestTools {
// the validation checks that the Safe contract performs on the value of s on contract
// the validation checks that the Safe contract performs on the value of s on contract
// signatures. The Safe contract checks that s correctly points to additional data appended
// signatures. The Safe contract checks that s correctly points to additional data appended
// after the signatures, and that the length of the data is within bounds.
// after the signatures, and that the length of the data is within bounds.
for (uint256 i
= 0
; i < contractSigs; i++) {
for (uint256 i; i < contractSigs; i++) {
signatures = bytes.concat(signatures, abi.encode(32, 1));
signatures = bytes.concat(signatures, abi.encode(32, 1));
}
}
...
...
packages/contracts-bedrock/test/safe-tools/SafeTestTools.sol
View file @
a3d3ae3e
...
@@ -212,17 +212,10 @@ library SafeTestLib {
...
@@ -212,17 +212,10 @@ library SafeTestLib {
address[] memory _ownersList
address[] memory _ownersList
)
)
internal
internal
view
pure
returns (
returns (address prevOwner_)
// pure
address prevOwner_
)
{
{
// console.log("getPrevOwnerFromList");
for (uint256 i; i < _ownersList.length; i++) {
for (uint256 i = 0; i < _ownersList.length; i++) {
// console.log(i);
// console.log(_owner);
// console.log("_ownersList[i]:", _ownersList[i]);
if (_ownersList[i] != _owner) continue;
if (_ownersList[i] != _owner) continue;
if (i == 0) {
if (i == 0) {
prevOwner_ = SENTINEL_OWNERS;
prevOwner_ = SENTINEL_OWNERS;
...
@@ -230,8 +223,6 @@ library SafeTestLib {
...
@@ -230,8 +223,6 @@ library SafeTestLib {
}
}
prevOwner_ = _ownersList[i - 1];
prevOwner_ = _ownersList[i - 1];
}
}
console.log("prevOwner_:", prevOwner_);
}
}
/// @dev Given an array of owners to remove, this function will return an array of the previous owners
/// @dev Given an array of owners to remove, this function will return an array of the previous owners
...
@@ -250,7 +241,7 @@ library SafeTestLib {
...
@@ -250,7 +241,7 @@ library SafeTestLib {
OwnerSimulator ownerSimulator = new OwnerSimulator(instance.owners, 1);
OwnerSimulator ownerSimulator = new OwnerSimulator(instance.owners, 1);
prevOwners_ = new address[](_ownersToRemove.length);
prevOwners_ = new address[](_ownersToRemove.length);
address[] memory currentOwners;
address[] memory currentOwners;
for (uint256 i
= 0
; i < _ownersToRemove.length; i++) {
for (uint256 i; i < _ownersToRemove.length; i++) {
currentOwners = ownerSimulator.getOwners();
currentOwners = ownerSimulator.getOwners();
prevOwners_[i] = SafeTestLib.getPrevOwnerFromList(_ownersToRemove[i], currentOwners);
prevOwners_[i] = SafeTestLib.getPrevOwnerFromList(_ownersToRemove[i], currentOwners);
...
...
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