@@ -3,6 +3,8 @@ pragma solidity ^0.8.24;
33
44import "forge-std/Test.sol " ;
55import "../contracts/GenericERC20.sol " ;
6+ import { Pausable } from "@openzeppelin/contracts/utils/Pausable.sol " ;
7+ import { IERC20Errors } from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol " ;
68
79contract GenericERC20Test is Test {
810 GenericERC20 token;
@@ -15,7 +17,7 @@ contract GenericERC20Test is Test {
1517 token = new GenericERC20 ("GenericToken " , "GT " );
1618 }
1719
18- function testInitialMint () public {
20+ function testInitialMint () public view {
1921 uint256 ownerBalance = token.balanceOf (owner);
2022 assertEq (ownerBalance, 100_000 * 10 ** token.decimals ());
2123 }
@@ -35,9 +37,10 @@ contract GenericERC20Test is Test {
3537 assertFalse (token.paused ());
3638 }
3739
38- function testFailMintWhenPaused () public {
40+ function test_RevertOnMintWhenPaused () public {
3941 token.pause ();
4042 uint256 mintAmount = 1000 * 10 ** token.decimals ();
43+ vm.expectRevert (abi.encodeWithSelector (Pausable.EnforcedPause.selector ));
4144 token.mint (owner, mintAmount); // This should fail
4245 }
4346
@@ -48,9 +51,13 @@ contract GenericERC20Test is Test {
4851 assertEq (newOwnerBalance, 99_000 * 10 ** token.decimals ());
4952 }
5053
51- function testFailBurnMoreThanBalance () public {
54+ function test_RevertOnBurnMoreThanBalance () public {
5255 uint256 burnAmount = 200_000 * 10 ** token.decimals ();
53- vm.expectRevert ("ERC20: burn amount exceeds balance " );
56+ vm.expectRevert (
57+ abi.encodeWithSelector (
58+ IERC20Errors .ERC20InsufficientBalance .selector , owner, 100_000 * 10 ** token.decimals (), burnAmount
59+ )
60+ );
5461 token.burn (burnAmount); // This should fail
5562 }
5663}
0 commit comments