Skip to content

Instantly share code, notes, and snippets.

@Jonsey
Created April 20, 2024 08:46
Show Gist options
  • Select an option

  • Save Jonsey/719855b662d176eb75eabe55e1512c8c to your computer and use it in GitHub Desktop.

Select an option

Save Jonsey/719855b662d176eb75eabe55e1512c8c to your computer and use it in GitHub Desktop.
ENS
// 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