The goal of this repository is to cater to a test project for learning and experimenting with the following technologies and concepts:
- Foundry
- Solidity Unit Tests: Writing and executing unit tests for Solidity smart contracts.
- Advanced Foundry Testing Tools: Exploring advanced testing tools provided by Foundry, such as fuzzing, FFI (Foreign Function Interface), and invariant testing.
Create a smart contract for a decentralized voting system using Solidity and Foundry. The system should allow for registration of candidates, voting by participants, and tallying of votes. Ensure that your smart contract handles various edge cases and security concerns.
- Foundry Setup and Basics: Learn to set up a Foundry project, compile your Solidity contract, and run basic tests.
- Solidity Unit Tests: Write unit tests for each function in your smart contract. This includes testing the registration of candidates, voting process, vote tallying, and access control.
- Advanced Testing with Foundry:
- Fuzz Testing: Use fuzzing to test your smart contract with a wide range of inputs to uncover potential vulnerabilities and edge cases.
- FFI (Foreign Function Interface): Explore the use of Foundry's Foreign Function Interface to call external code or scripts as part of your testing. This can be used to simulate complex interactions or real-world scenarios.
- Invariant Testing: Implement invariant testing to ensure that certain conditions (invariants) always hold true throughout the execution of your contract, regardless of the state or inputs.
$ forge build
$ forge test --ffi
$ brew install lcov
$ forge coverage --ffi --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage