This repository contains broken ERC-20 contract, based on Open Zeppelin implementation. It does not work well and your task is to write unit test, find all mistakes and correct the contract, so it will work as expected. Enjoy!
- Clone this repository locally
- Install all dependencies using yarn
- Run
npx hardat testto insure, that contract is compiling - Create
testdirectory anderc20.tstest file
- Use
loadFixturefromhardhat-network-helpersfor all tests
- Should deploy with proper address
- Should deploy with right name
- Should deploy with right symbol
- Should deploy with right price
- Should be 0 total supply after deploy
- Should increase balance of caller on given amount
- Should increase total supply
- Should emit transfer event with right args
- Should increase contract ethers balance
- Should decrease caller ethers balance
- Should revert if message value is less than price * token amount
- Make tests for several mints for different addresses in one unit test
- Should increase balance of
toaddress - Should decrease balance of caller
- Should not change total supply
- Should emit transfer event with right args
- Should revert if
tois a zero address - Should revert if caller balance is less than amount to transfer
- Make tests for several transfers for different addresses in one unit test
- Should decrease balance of caller on given amount
- Should decrease total supply
- Should emit transfer event with right args
- Should revert if caller balance is less that amount to burn
- Make tests for several burns for different addresses in one unit test
- Should update
_allowancesmapping by settingamount - Should emit approval event with right args
- Should revert if approval given for zero address
- Make tests for several approvals for different addresses in one unit test
- Should update
_allowancesmapping by increasing onamount - Should emit approval event with right args
- Should revert if approval given for zero address
- Make tests for several increasings for different addresses in one unit test
- Should update
_allowancesmapping by decreasing onamount - Should emit approval event with right args
- Should revert if approval given for zero address --
- Should revert if decreased allowance is below zero
- Make tests for several decreasings for different addresses in one unit test
- Should update
_allowancesmapping by decreasing onamount - Should increase balance of
toaddress - Should decrease balance of
fromaddress - Should not change total supply
- Should emit transfer event
- Should revert if
tois a zero address - Should revert if
fromis a zero address -- - Should revert if allowance is not enough
- Should revert if allowance is 0 --
- Should revert if not enough balance on
fromaddress - Make tests for several transfers for different addresses in one unit test
Please write your opinion in smart-contract business logic. Are there any functions that you would add? What are they? Write short description.
- Check that all tasks are completed
- Create NEW repository on GitHub
- Make it public or private with access granted to reviewers
- Push unit-tests and fixed contract to your repository
- Write to your reviewers and wait for feedback