Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/makerdao/token-tests
Suite of unit and fuzz tests for MakerDAO-style ERC20 tokens
https://github.com/makerdao/token-tests
Last synced: 3 months ago
JSON representation
Suite of unit and fuzz tests for MakerDAO-style ERC20 tokens
- Host: GitHub
- URL: https://github.com/makerdao/token-tests
- Owner: makerdao
- License: agpl-3.0
- Created: 2023-05-18T15:53:06.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-24T21:02:45.000Z (9 months ago)
- Last Synced: 2024-04-25T20:55:46.183Z (9 months ago)
- Language: Solidity
- Size: 83 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# token-tests
Test suite for a standard "Maker-style" ERC20 token. An example of such a standard token can be found in `src/tests/SampleToken.sol`.
## Getting Started
Run `forge install makerdao/token-tests` in your newly setup repository.
There are two possible ways to use `token-tests`
### 1) Letting `token-tests` handle testing for you
This is the recommended way. Inherit your test contract from `token-tests/TokenTests.sol` instead of `std-forge/Test.sol` (`contract YourTokenTest is TokenTests {`). You will then need to set the following inherited variables:
```solidity
function setUp() public {
_token_ = address(new YourToken());
_contractName_ = "YourToken";
_tokenName_ = "Your Token";
_symbol_ = "TKN";
_version_ = "1"; // this can be omitted, in which case a default value of "1" is assumed
_decimals_ = 18; // this can be omitted, in which case a default value of 18 is assumed
}
```That's it. A suite of tests covering Mint/Burn, ERC20 functionalities and Permit will automatically be run for you. If you also want fuzz tests to be run, use `token-tests/TokenFuzzTests.sol` as your base class (which itself inherits from `TokenTests.sol`).
You can use `tests/TokenTests.t.sol` as an example of this first approach.
### 2) Explicitely specifying your tests in your test class
Alternatively, if you want more fine-grained control over your tests, you can inherit your test contract from `token-tests/TokenChecks.sol`. You will then be able to call individual token testing functions (all starting with the prefix `check`) or, alternatively, bulk testing functions such as `checkBulkERC20()`, `checkBulkMintBurn()` or `checkBulkPermit()`.
If you wish to use fuzz testing functions to fuzz test your token, inherit your test contract from `token-tests/FuzzTokenChecks.sol`. You will then be able to call any of the token fuzz testing functions (all in the form `checkXXXFuzz` or `checkBulkXXXFuzz`).