This repo contains files used required for the creation of a tokenised vault Please dont use these in any Production env as they are solely for learning purposes
Im going to focus on the unit testing aspect of the project i had decided to introduce folders within the unit testing directory
- Unit
- Integration
- Invariant
- Fork
This was inspired by a talk i watched during ETHCC these folders allow for separation of strategies of how we can test the contracts developed and each test the contract in different ways. Note: Since we developing a Tokenized vault which requires another contract i have put the tests under Unit For setting up Testing i decided to use Inheritance reason being we want to setup base logic for all tests such that all other test can use the logic instead of duplicating by defining it in their own contracts.
Before creating a unit test we first defined a non-technical tree which follows the Branching Tree Technique (BTT) file that defines how we want to to the contract functions by defining possible execution paths you can find an example of such a tree file under the unit test folder
Before reading the unit tests one can easily get an idea of what we testing for within the contract
To ling the tree file to the actual unit test we used modifiers to translate the english to solidity.
To setup the project please ensure you have installed
- Node Version Manager (https://github.com/nvm-sh/nvm)
- node with npm (using NVM)
- Foundry (https://book.getfoundry.sh/getting-started/installation)
- Hardhat (https://hardhat.org/hardhat-runner/docs/getting-started#installation)
yarn
or npm i
For the foundry contract theres no need to install again since the repo will included in the lib/ folder but if you wish to install other dependencies please see here: https://book.getfoundry.sh/projects/dependencies
To build the contracts please run
forge build
There are several folders within the testing folder we just focused on concreting testing other types of testing like fuzz and integration are not included
To test the contracts please run
forge test
For deployment we have employed the Universal Upgradeable Proxy Standard (UUPS) standard by hardhat and openzepplin (https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades)
There are scripts that aid in the deployment of the Vault and Token one for local host running on port 8546 and one for deploy to mumbai testnet
All deployment scripts denoted with ::local refer to local deployment All deployment scripts denoted with ::polygon refer to Polygon testnet deployment
To run a deployment you can run
yarn deploy:local:vault:and::token
or npm run deploy:local:vault:and::token
Which deploys a vault with a token