// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Test} from "forge-std/Test.sol";
import {CompliantBTC} from "../../contracts/tokens/CompliantBTC.sol";

contract CompliantMonetaryUnitTokenTest is Test {
    CompliantBTC public token;
    address public owner;
    address public admin;
    address public user1;

    function setUp() public {
        owner = address(this);
        admin = address(this);
        user1 = address(0xB0B);
        token = new CompliantBTC(owner, admin, 21_000_000 * 10**8);
    }

    function testDecimals() public view {
        assertEq(token.decimals(), 8);
    }

    function testUnitCode() public view {
        assertEq(token.unitCode(), "BTC");
        assertTrue(token.isMonetaryUnit());
    }

    function testInitialSupplyUsesSatoshiPrecision() public view {
        assertEq(token.totalSupply(), 21_000_000 * 10**8);
        assertEq(token.balanceOf(owner), 21_000_000 * 10**8);
    }

    function testTransferUsesEightDecimals() public {
        uint256 amount = 12_500_000;
        token.transfer(user1, amount);
        assertEq(token.balanceOf(user1), amount);
        assertEq(token.balanceOf(owner), 21_000_000 * 10**8 - amount);
    }

    function testPauseBlocksTransfers() public {
        token.pause();
        assertTrue(token.paused());
        vm.expectRevert();
        token.transfer(user1, 100_000_000);
    }

    function testMintAndBurnUseSatoshiPrecision() public {
        token.mint(user1, 250_000_000);
        assertEq(token.balanceOf(user1), 250_000_000);
        token.burn(100_000_000);
        assertEq(token.balanceOf(owner), 21_000_000 * 10**8 - 100_000_000);
    }
}
