Open vea-vecturne opened 3 months ago
Hello @vea-vecturne, thank you for opening the ticket!
I've delved into the Fixtures feature of the Wafflejs framework and have crafted a POC to explore its functionalities. You can access the POC project here. It's a straightforward Hardhat project utilizing the Wafflejs testing framework to experiment with fixtures.
Upon my research, it looks like the capability to enable users to create predefined testing scenarios and snapshots of the blockchain's state via fixtures is only available on the default local test network
provided by development frameworks (GETH, Ganache, Hardhat, etc.). The mentioned POC project above is configured with two networks, Hedera and Sepolia Ethereum testnet, and regardless of the targeted networks, fixtures will only operate on the local test network. This assertion is validated through the unit tests of the POC, located under the /test/PiggyBank.spec.ts file.
In the Testing With Fixture
test suite, I employed the 'fixture' feature from 'Waffle' to deploy a contract. Despite setting the defaultNetwork
in the hardhat.config.js file to either hedera
or sepolia
, the transaction was executed as expected against the local test network. Specifically, line 51 and line 52 validate the chainId
returned from the deployTransaction
and getChainId()
transactions, ensuring alignment with the LOCAL_TESTNET_CHAIN_ID
(1337 as convention).
Having said that, I believe fixtures are a feature somewhat integrated at the framework level rather than the network level. However, it would be interested to learn about your thoughts and insights on this matter!
Problem
A significant pain point for projects transitioning to or working with Hedera, especially those from other EVM networks, is the current lack of support for fixtures. This feature is critical for efficient development workflows, particularly when using testing frameworks like Waffle, which utilize snapshots to speed up the testing process. Without this capability, projects like SaucerSwap and other evm projects are forced to redeploy contracts for every test suite, leading to considerable delays and frustration.
Solution
Implementing snapshot functionality in Hedera would make the platform more frictionless in testing- increasing EVM compatibility by offering a familiar experience in testing as other EVM chains. It would allow developers to create fixtures for testing scenarios that are executed once and then preserved, significantly accelerating development time and improving efficiency. This feature would not only benefit current projects like SaucerSwap but also make Hedera a more appealing choice for future projects considering EVM compatibility.
Alternatives
Currently, the workaround involves the time-consuming redeployment of contracts for each test suite. While functional, this process is not efficient and represents a significant barrier to development and testing speed.
Additional Context: Waffle's fixture feature is a prime example of how fixtures can be utilized to enhance testing workflows. By creating fixtures that deploy contracts and set up specific testing scenarios once, and then taking snapshots of the state, Waffle enables tests to run much faster since the setup needs to occur only once. For more information on how Waffle implements this feature, please see Waffle's documentation on fixtures.
https://ethereum-waffle.readthedocs.io/en/latest/fixtures.html