Created
April 20, 2024 08:46
-
-
Save Jonsey/719855b662d176eb75eabe55e1512c8c to your computer and use it in GitHub Desktop.
ENS
This file contains hidden or 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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.22; | |
| import "forge-std/console.sol"; | |
| import "forge-std/Test.sol"; | |
| contract XTest is DSTest { | |
| uint256 expires = 1000; | |
| uint256 constant GRACE_PERIOD = 90 days; | |
| function renew(uint256 duration) public returns (uint256){ | |
| unchecked{ | |
| require(expires + GRACE_PERIOD >= block.timestamp, "Multichain: expired"); | |
| require(expires + duration + GRACE_PERIOD > duration + GRACE_PERIOD, "Multichain: invalid duration"); | |
| expires += duration; | |
| } | |
| return expires; | |
| } | |
| function test1() public { | |
| uint256 newExpires = renew(type(uint256).max - 999); | |
| assertGt(newExpires, expires); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment