-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add CommonConstants test: rename Baae file test: improve createUser function
- Loading branch information
1 parent
b79fd37
commit 1125f3b
Showing
5 changed files
with
105 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity >=0.8.22; | ||
|
||
abstract contract CommonConstants { | ||
uint256 internal constant FEE = 0.001e18; | ||
uint40 internal constant FEB_1_2025 = 1_732_073_600; | ||
uint128 internal constant MAX_UINT128 = type(uint128).max; | ||
uint256 internal constant MAX_UINT256 = type(uint256).max; | ||
uint40 internal constant MAX_UINT40 = type(uint40).max; | ||
uint64 internal constant MAX_UINT64 = type(uint64).max; | ||
uint40 internal constant MAX_UNIX_TIMESTAMP = 2_147_483_647; // 2^31 - 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity >=0.8.22; | ||
|
||
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; | ||
import { CommonBase as StdBase } from "forge-std/src/Base.sol"; | ||
import { StdUtils } from "forge-std/src/StdUtils.sol"; | ||
|
||
abstract contract CommonUtils is StdBase, StdUtils { | ||
/// @dev Bounds a `uint128` number. | ||
function boundUint128(uint128 x, uint128 min, uint128 max) internal pure returns (uint128) { | ||
return uint128(_bound(x, min, max)); | ||
} | ||
|
||
/// @dev Bounds a `uint40` number. | ||
function boundUint40(uint40 x, uint40 min, uint40 max) internal pure returns (uint40) { | ||
return uint40(_bound(x, min, max)); | ||
} | ||
|
||
/// @dev Bounds a `uint64` number. | ||
function boundUint64(uint64 x, uint64 min, uint64 max) internal pure returns (uint64) { | ||
return uint64(_bound(x, min, max)); | ||
} | ||
|
||
/// @dev Bounds a `uint8` number. | ||
function boundUint8(uint8 x, uint8 min, uint8 max) internal pure returns (uint8) { | ||
return uint8(_bound(x, min, max)); | ||
} | ||
|
||
/// @dev Retrieves the current block timestamp as an `uint40`. | ||
function getBlockTimestamp() internal view returns (uint40) { | ||
return uint40(block.timestamp); | ||
} | ||
|
||
/// @dev Checks if the Foundry profile is "test-optimized". | ||
function isTestOptimizedProfile() internal view returns (bool) { | ||
string memory profile = vm.envOr({ name: "FOUNDRY_PROFILE", defaultValue: string("default") }); | ||
return Strings.equal(profile, "test-optimized"); | ||
} | ||
|
||
/// @dev Stops the active prank and sets a new one. | ||
function resetPrank(address msgSender) internal { | ||
vm.stopPrank(); | ||
vm.startPrank(msgSender); | ||
} | ||
} |