65 lines
1.8 KiB
Solidity
65 lines
1.8 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.19;
|
|
|
|
import {Test} from "forge-std/Test.sol";
|
|
import {CompliantWrappedToken} from "../../contracts/tokens/CompliantWrappedToken.sol";
|
|
|
|
contract CompliantWrappedTokenTest is Test {
|
|
CompliantWrappedToken public token;
|
|
address public admin;
|
|
address public bridge;
|
|
address public user1;
|
|
|
|
bytes32 constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
|
bytes32 constant BURNER_ROLE = keccak256("BURNER_ROLE");
|
|
|
|
function setUp() public {
|
|
admin = address(this);
|
|
bridge = address(0xb);
|
|
user1 = address(0x1);
|
|
token = new CompliantWrappedToken("Wrapped cUSDT", "cWUSDT", 6, admin);
|
|
token.grantRole(MINTER_ROLE, bridge);
|
|
token.grantRole(BURNER_ROLE, bridge);
|
|
}
|
|
|
|
function testDecimals() public view {
|
|
assertEq(token.decimals(), 6);
|
|
}
|
|
|
|
function testMint() public {
|
|
vm.prank(bridge);
|
|
token.mint(user1, 1000e6);
|
|
assertEq(token.balanceOf(user1), 1000e6);
|
|
}
|
|
|
|
function testMintRevertsNonMinter() public {
|
|
vm.prank(user1);
|
|
vm.expectRevert();
|
|
token.mint(user1, 1000e6);
|
|
}
|
|
|
|
function testBurn() public {
|
|
vm.prank(bridge);
|
|
token.mint(user1, 1000e6);
|
|
vm.prank(bridge);
|
|
token.burn(user1, 400e6);
|
|
assertEq(token.balanceOf(user1), 600e6);
|
|
}
|
|
|
|
function testBurnFrom() public {
|
|
vm.prank(bridge);
|
|
token.mint(user1, 1000e6);
|
|
vm.prank(bridge);
|
|
token.burnFrom(user1, 400e6);
|
|
assertEq(token.balanceOf(user1), 600e6);
|
|
}
|
|
|
|
function testBurnFromRevertsNonBurner() public {
|
|
vm.prank(bridge);
|
|
token.mint(user1, 1000e6);
|
|
vm.prank(user1);
|
|
vm.expectRevert();
|
|
token.burnFrom(user1, 400e6);
|
|
}
|
|
}
|