Skip to content

Instantly share code, notes, and snippets.

Last active September 8, 2022 04:56
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "../src/token.sol";
contract tokenTest is Test {
SDUFECoin private token;
using stdStorage for StdStorage;
address internal constant receiver = address(1);
function setUp() public {
token = new SDUFECoin("SDUFECoinTest", "SDCT", 8);
function testFailNoMintPricePaid() public {
function testSwapPaid() public {
token.mintTo{value: 0.01 ether}(address(1));
function testFailMaxsupply() public {
token.mintTo{value: 0.015 ether}(address(1));
function testFailMinPrice() public {
token.mintTo{value: 0.000000001 ether}(address(1));
function testFailMaxsupplyUseCheat() public {
uint256 slot = stdstore
bytes32 loc = bytes32(slot);
bytes32 mockedTotalSupply = bytes32(abi.encode(1_000_000));, loc, mockedTotalSupply);
token.mintTo{value: 0.00000001 ether}(address(1));
function testWithdrawalWorksAsOwner() public {
address payable payee = payable(address(0x1337));
uint256 priorPayeeBalance = payee.balance;
token.mintTo{value: 0.0001 ether}(address(receiver));
assertEq(address(token).balance, 0.0001 ether);
uint256 tokenBalance = address(token).balance;
assertEq(payee.balance, priorPayeeBalance + tokenBalance);
function testWithdrawalFailsAsNotOwner() public {
token.mintTo{value: token.MINT_PRICE()}(address(receiver));
assertEq(address(token).balance, token.MINT_PRICE());
vm.expectRevert("Ownable: caller is not the owner");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment