Skip to content

Refactor the Entire Test Suite (Or Move to Foundry) #105

@Zer0dot

Description

@Zer0dot

The repository uses Hardhat as a development environment as it fit our needs perfectly and has a plethora of plugins. Unfortunately, we've run into some issues as we've reached 500+ tests.

Firstly, the test suite takes quite a while to run. This can significantly reduce productivity and increase development time-- even when running a quick-test which does not wipe and re-compile if it isn't needed, the setup time can be quite long.

Secondly, and this is largely my mistake in hindsight, the tests we've built lack in consistency. For instance, some tests create a profile in a beforeEach() hook, others do it individually on a per-test as-needed basis, etc. This makes working on tests a bit of a drag because extra effort needs to be done to validate the specific testing environment. This isn't enough of a problem on its own, but with the next point it can lead to some confusion.

Lastly, the tests lack in clarity. This again is largely my mistake, but because I opted for particularly verbose direct-to-contract calling in most cases, we're left with large difficult-to-read code blocks. As an example, look at the amount of times profile creation happens in the tests!

In order to improve the codebase's overall readability, I recommend either a large-scale refactor of test functions using helper functions (e.g: have helper functions like createProfile() with default values that can be overriden and call those instead of directly calling the contracts explicitly) or migrating the test suite over to Foundry.

Migrating to Foundry has the very likely benefit of speeding up tests significantly, in addition to the increased readability of tests written in solidity. This is a solution I'm pretty excited about, although it's very much a longer-term endeavor.

I'd love some input from integrators and everyone building atop the Lens Protocol, what do you think, folks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions