This tutorial walks you through performing tests in the mocked mode provided by the fhEVM Hardhat template.
Before proceeding, ensure you have:
A configured Hardhat project using the fhEVM Hardhat template. (See the previous section)
Basic knowledge of Solidity and Hardhat testing. (See the Hardhat testing documentation)
fhEVM provides a mocked mode in Hardhat that allows for:
Faster testing on a local Hardhat network.
The ability to analyze code coverage.
A simulated version of encrypted types (they are not truly encrypted).
Access to Hardhat features such as snapshots (evm_snapshot
), time manipulation (evm_increaseTime
), and debugging (console.log
).
To learn more about the fhEVM mocked mode, refer to the README in the fhEVM Hardhat template repository.
To run tests in mocked mode, open a terminal in your project's root directory and execute:
This command runs all tests locally in mocked mode. You should see the test results in your console.
For most development and demonstration scenarios, mocked mode is sufficient. However, for production-ready development and a real testing environment, you need to run your tests on a real network where the coprocessor is deployed for example Sepolia. Refer to the next section on how to deploy your contract on Sepolia test network.