Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
rccsousa committed Oct 30, 2024
1 parent 7f48386 commit cece395
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/ERC20.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {Test} from "forge-std/Test.sol";
import {WDLToken} from "../src/ERC20.sol";

contract ERC20Test is Test {
WDLToken token;

address user1 = address(0x1);
address user2 = address(0x2);

function setUp() public {
token = new WDLToken(1000);
}

function test_Mint() public {
// Check the initial balance of the deployer
assertEq(token.balanceOf(address(this)), 1000);
}

function test_Transfer() public {
// not enough supply
vm.expectRevert();
token.transfer(user1, 1001);

// transfer some
token.transfer(user1, 100);
assertEq(token.balanceOf(user1), 100);
assertEq(token.balanceOf(address(this)), 900);

// transfer between
vm.prank(user1);
token.approve(address(this), 50);
token.transferFrom(user1, user2, 50);
assertEq(token.balanceOf(user1), 50);
assertEq(token.balanceOf(user2), 50);
}
}

0 comments on commit cece395

Please sign in to comment.