-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |