@@ -1519,6 +1519,112 @@ contract FraxiversarryTest is Test, IFraxiversarryErrors, IFraxiversarryEvents {
15191519 fraxiversarry.tokenURI (tokenId);
15201520 }
15211521
1522+ // ----------------------------------------------------------
1523+ // Minting cutoff block tests
1524+ // ----------------------------------------------------------
1525+
1526+ function testConstructorSetsMintingCutoffBlockRelativeToDeployBlock () public {
1527+ // Redeploy locally to assert constructor math precisely
1528+ MockLzEndpoint localEndpoint = new MockLzEndpoint ();
1529+
1530+ uint256 deployBlock = block .number ;
1531+ Fraxiversarry local = new Fraxiversarry (owner, address (localEndpoint));
1532+
1533+ uint256 expectedDelta = (35 days / 2 seconds);
1534+ assertEq (local.mintingCutoffBlock (), deployBlock + expectedDelta);
1535+ }
1536+
1537+ function testPaidMintAllowedAtCutoffBlock () public {
1538+ // Set cutoff to current block so mint is still allowed
1539+ vm.prank (owner);
1540+ fraxiversarry.updateMintingCutoffBlock (block .number );
1541+
1542+ _approveWithFee (alice, wfrax);
1543+
1544+ vm.prank (alice);
1545+ uint256 tokenId = fraxiversarry.paidMint (address (wfrax));
1546+
1547+ assertEq (fraxiversarry.ownerOf (tokenId), alice);
1548+ assertEq (uint256 (fraxiversarry.tokenTypes (tokenId)), uint256 (Fraxiversarry.TokenType.BASE));
1549+ }
1550+
1551+ function testPaidMintRevertsAfterCutoffBlock () public {
1552+ uint256 cutoff = block .number ;
1553+ vm.prank (owner);
1554+ fraxiversarry.updateMintingCutoffBlock (cutoff);
1555+
1556+ // Move to cutoff + 1
1557+ vm.roll (cutoff + 1 );
1558+
1559+ _approveWithFee (alice, wfrax);
1560+
1561+ vm.prank (alice);
1562+ vm.expectRevert (MintingPeriodOver.selector );
1563+ fraxiversarry.paidMint (address (wfrax));
1564+ }
1565+
1566+ function testGiftMintAllowedAtCutoffBlock () public {
1567+ vm.prank (owner);
1568+ fraxiversarry.updateMintingCutoffBlock (block .number );
1569+
1570+ (,, uint256 giftMintingPrice ) = fraxiversarry.getGiftMintingPriceWithFee ();
1571+ vm.prank (alice);
1572+ wfrax.approve (address (fraxiversarry), giftMintingPrice);
1573+
1574+ vm.prank (alice);
1575+ uint256 tokenId = fraxiversarry.giftMint (bob);
1576+
1577+ assertEq (fraxiversarry.ownerOf (tokenId), bob);
1578+ assertEq (uint256 (fraxiversarry.tokenTypes (tokenId)), uint256 (Fraxiversarry.TokenType.GIFT));
1579+ }
1580+
1581+ function testGiftMintRevertsAfterCutoffBlock () public {
1582+ uint256 cutoff = block .number ;
1583+ vm.prank (owner);
1584+ fraxiversarry.updateMintingCutoffBlock (cutoff);
1585+
1586+ vm.roll (cutoff + 1 );
1587+
1588+ (,, uint256 giftMintingPrice ) = fraxiversarry.getGiftMintingPriceWithFee ();
1589+ vm.prank (alice);
1590+ wfrax.approve (address (fraxiversarry), giftMintingPrice);
1591+
1592+ vm.prank (alice);
1593+ vm.expectRevert (MintingPeriodOver.selector );
1594+ fraxiversarry.giftMint (bob);
1595+ }
1596+
1597+ function testUpdateMintingCutoffBlockOnlyOwner () public {
1598+ vm.prank (alice);
1599+ vm.expectRevert (); // Ownable: caller is not the owner
1600+ fraxiversarry.updateMintingCutoffBlock (block .number + 100 );
1601+ }
1602+
1603+ function testUpdateMintingCutoffBlockEmitsEvent () public {
1604+ uint256 previous = fraxiversarry.mintingCutoffBlock ();
1605+ uint256 next = previous + 123 ;
1606+
1607+ vm.recordLogs ();
1608+ vm.prank (owner);
1609+ fraxiversarry.updateMintingCutoffBlock (next);
1610+ Vm.Log[] memory logs = vm.getRecordedLogs ();
1611+
1612+ bytes32 expectedSig = keccak256 ("MintingCutoffBlockUpdated(uint256,uint256) " );
1613+ bool found;
1614+
1615+ for (uint256 i; i < logs.length ; ++ i) {
1616+ if (logs[i].topics[0 ] == expectedSig) {
1617+ found = true ;
1618+ (uint256 loggedPrev , uint256 loggedNext ) = abi.decode (logs[i].data, (uint256 , uint256 ));
1619+ assertEq (loggedPrev, previous);
1620+ assertEq (loggedNext, next);
1621+ }
1622+ }
1623+
1624+ assertTrue (found, "MintingCutoffBlockUpdated event not found " );
1625+ assertEq (fraxiversarry.mintingCutoffBlock (), next);
1626+ }
1627+
15221628 // ----------------------------------------------------------
15231629 // ONFT view helpers (token() / approvalRequired())
15241630 // ----------------------------------------------------------
0 commit comments