Skip to content

Instantly share code, notes, and snippets.

@satanworker
Created May 13, 2022 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satanworker/5f6d74ea9e0223c5e4e84a19f1246d3d to your computer and use it in GitHub Desktop.
Save satanworker/5f6d74ea9e0223c5e4e84a19f1246d3d to your computer and use it in GitHub Desktop.
Foundry dealing custom ERC20
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.10;
import "../../lib/ds-test/src/test.sol";
import "../../lib/forge-std/src/Vm.sol";
import "../../lib/forge-std/src/Test.sol";
interface ERC20 {
function totalSupply() external view returns (uint);
function balanceOf(address tokenOwner) external view returns (uint balance);
function allowance(address tokenOwner, address spender) external view returns (uint remaining);
function transfer(address to, uint tokens) external returns (bool success);
function approve(address spender, uint tokens) external returns (bool success);
function transferFrom(address from, address to, uint tokens) external returns (bool success);
function symbol() external view returns (string memory);
function name() external view returns (string memory);
function decimals() external view returns (uint8);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract ContractTest is DSTest, Test {
ERC20 private WETH = ERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address emptyWallet = address(3);
function setUp() public {}
function testExample() public {
assertTrue(true);
}
function testEmptyWallet() public {
require(WETH.balanceOf(emptyWallet) == 0);
}
function testDeal() public {
deal(address(WETH), emptyWallet, 1000 ether);
require(WETH.balanceOf(emptyWallet) > 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment