{"repo":"wonderland-archive/smock-foundry","free":true,"listed":false,"github":"https://github.com/wonderland-archive/smock-foundry","clone":"git clone https://github.com/wonderland-archive/smock-foundry.git","description":"💨 Smock-style mocks for Foundry projects","language":"TypeScript","stars":31,"topics":["foundry","mock","smock","solidity"],"license":"MIT","category":"blockchain-web3","readme_excerpt":"Smock Foundry A plugin for foundry that automatically generates Solidity mocks for every contract in your project. Features - Get rid of your folder of \"mock\" contracts and just use foundry . - Keep your tests simple with straightforward mock functions. - Mock up external calls and internal variables in a beautiful and orderly fashion. Installation You can install the plugin via yarn: Basic Usage Creating mocks To generate the mock contracts all you have to do is run: The smock-foundry command accepts the following options: Option Default Notes ----------- -------------- ---------------------------------------------------------- contracts — The path to the solidity contracts to mock root . The path to the root of the project mocks ./test/smock The path to the generated mock contracts ignore [] A list of directories to ignore, e.g. --ignore libraries Be sure to gitignore the generated smock directory. Using mocks Let's say you have a Greeter contract in your project at contracts/Greeter.sol : After running the generator, you will have a mock contract located at ${mocks}/contracts/MockGreeter.sol : The next step would be importing the mock contract in your unit tests, deploying it and allowing it to use the cheatcodes, specifically vm.mockCall . Then enjoy the wonders of mocking: Gotchas - Please, note that if you want to mock internal functions, you must make them virtual . The tool will not generate mocks for internal functions that are not virtual. - Cannot set private varia","default_branch":null,"files":null,"tree":[],"storefront":"/r/wonderland-archive","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/wonderland-archive/smock-foundry/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}