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
db3871df
Unverified
Commit
db3871df
authored
May 14, 2024
by
Maurelian
Committed by
GitHub
May 14, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ctb: SafeTestTools improvements (#10537)
parent
84c503da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
LivenessGuard.t.sol
packages/contracts-bedrock/test/Safe/LivenessGuard.t.sol
+2
-0
SafeTestTools.sol
packages/contracts-bedrock/test/safe-tools/SafeTestTools.sol
+27
-3
No files found.
packages/contracts-bedrock/test/Safe/LivenessGuard.t.sol
View file @
db3871df
...
...
@@ -245,6 +245,8 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
privateKeys[ownerAddrs[i]] = ownerkeys[i];
}
// Override the saltNonce to ensure prevent a create2 collision.
saltNonce = uint256(keccak256(bytes("LIVENESS GUARD OWNER MANAGEMENT TEST")));
// Create the new safe and register the guard.
SafeInstance memory safeInstance = _setupSafe(ownerkeys, threshold);
livenessGuard = new WrappedGuard(safeInstance.safe);
...
...
packages/contracts-bedrock/test/safe-tools/SafeTestTools.sol
View file @
db3871df
...
...
@@ -499,6 +499,8 @@ contract SafeTestTools {
SafeInstance[] internal instances;
uint256 internal saltNonce = uint256(keccak256(bytes("SAFE TEST")));
/// @dev can be called to reinitialize the singleton, proxyFactory and handler. Useful for forking.
function _initializeSafeTools() internal {
singleton = new GnosisSafe();
...
...
@@ -506,6 +508,12 @@ contract SafeTestTools {
handler = new CompatibilityFallbackHandler();
}
/// @dev Sets up a Safe with the given parameters.
/// @param ownerPKs The public keys of the owners.
/// @param threshold The threshold for the Safe.
/// @param initialBalance The initial balance of the Safe.
/// @param advancedParams The advanced parameters for the Safe initialization.
/// @return The initialized Safe instance.
function _setupSafe(
uint256[] memory ownerPKs,
uint256 threshold,
...
...
@@ -560,6 +568,11 @@ contract SafeTestTools {
return instance0;
}
/// @dev Sets up a Safe with the given parameters.
/// @param ownerPKs The public keys of the owners.
/// @param threshold The threshold for the Safe.
/// @param initialBalance The initial balance of the Safe.
/// @return The initialized Safe instance.
function _setupSafe(
uint256[] memory ownerPKs,
uint256 threshold,
...
...
@@ -575,7 +588,7 @@ contract SafeTestTools {
AdvancedSafeInitParams({
includeFallbackHandler: true,
initData: "",
saltNonce:
0
,
saltNonce:
saltNonce
,
setupModulesCall_to: address(0),
setupModulesCall_data: "",
refundAmount: 0,
...
...
@@ -585,6 +598,10 @@ contract SafeTestTools {
);
}
/// @dev Sets up a Safe with the given parameters.
/// @param ownerPKs The public keys of the owners.
/// @param threshold The threshold for the Safe.
/// @return The initialized Safe instance.
function _setupSafe(uint256[] memory ownerPKs, uint256 threshold) public returns (SafeInstance memory) {
return _setupSafe(
ownerPKs,
...
...
@@ -593,7 +610,7 @@ contract SafeTestTools {
AdvancedSafeInitParams({
includeFallbackHandler: true,
initData: "",
saltNonce:
0
,
saltNonce:
saltNonce
,
setupModulesCall_to: address(0),
setupModulesCall_data: "",
refundAmount: 0,
...
...
@@ -603,6 +620,8 @@ contract SafeTestTools {
);
}
/// @dev Sets up a Safe with default parameters. The SafeInstance will have 3 owners and a threshold of 2.
/// @return The initialized Safe instance.
function _setupSafe() public returns (SafeInstance memory) {
(, uint256[] memory defaultPKs) = SafeTestLib.makeAddrsAndKeys("default", 3);
...
...
@@ -613,7 +632,7 @@ contract SafeTestTools {
AdvancedSafeInitParams({
includeFallbackHandler: true,
initData: "",
saltNonce:
uint256(keccak256(bytes("SAFE TEST")))
,
saltNonce:
saltNonce
,
setupModulesCall_to: address(0),
setupModulesCall_data: "",
refundAmount: 0,
...
...
@@ -623,6 +642,8 @@ contract SafeTestTools {
);
}
/// @dev Returns the first Safe instance.
/// @return The first Safe instance.
function getSafe() public view returns (SafeInstance memory) {
if (instances.length == 0) {
revert("SAFETESTTOOLS: Test Safe has not been deployed, use _setupSafe() calling safe()");
...
...
@@ -630,6 +651,9 @@ contract SafeTestTools {
return instances[0];
}
/// @dev Returns the Safe instance with the given address.
/// @param _safe The address of the Safe instance to return.
/// @return The Safe instance with the given address.
function getSafe(address _safe) public view returns (SafeInstance memory) {
for (uint256 i; i < instances.length; ++i) {
if (address(instances[i].safe) == _safe) return instances[i];
...
...
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