Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Integrating localFunctionsTestnet and Hardhat's loadFixture Utility #196

Open
tomasp1189 opened this issue Nov 29, 2023 · 1 comment

Comments

@tomasp1189
Copy link

Description:
Hello, and thank you for providing this excellent boilerplate for working with Chainlink Functions.

I am currently developing a Smart Contract and utilizing your provided localFunctionsTestnet for testing. However, I've encountered an issue related to testing environments. Specifically, the need to manually run localFunctionsTestnet prevents me from taking full advantage of Hardhat's loadFixture utility, which is instrumental for snapshotting test states.

Problem:
The localFunctionsTestnet, as part of the functions-toolkit, uses Ganache under the hood. This setup conflicts with Hardhat's default behavior, particularly with the loadFixture utility, which relies on Hardhat's in-memory network for snapshotting and reverting state between tests. The result is an inability to efficiently manage test state, leading to more complex and time-consuming test setups.

Expected Behavior:
Ideally, I would like to seamlessly integrate the localFunctionsTestnet with Hardhat's testing environment, enabling me to use loadFixture for efficient test state management. This integration would greatly enhance the development workflow and testing efficiency.

Steps to Reproduce:

  1. Set up a Smart Contract project using the Chainlink Functions boilerplate.
  2. Implement unit tests using Hardhat's testing framework.
  3. Attempt to use Hardhat's loadFixture utility while localFunctionsTestnet is running.

Possible Solutions:
I'm unsure of the best way to resolve this issue but have considered a few options:

  1. Adapting localFunctionsTestnet for Compatibility: Modify localFunctionsTestnet to work seamlessly with Hardhat's in-memory network, allowing us to use loadFixture effectively.
  2. Guidance on Managing Test States: Provide instructions or best practices for handling test states when using localFunctionsTestnet alongside Hardhat.
  3. Script to Replicate localFunctionsTestnet Setup in Hardhat: Develop a script to configure Hardhat's test environment similar to localFunctionsTestnet, ensuring consistency across testing platforms.

Thank you for your attention to this issue. Any guidance or updates to improve this integration would be greatly appreciated!

@luislucena16
Copy link

hey @tomasp1189 could you attach a snapshot of the code you are using? as well as the specs to run it, it would be much easier/quicker to help you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants