This PR started as a dependency upgrade and became an absolute rabbit hole. I'll try to summarize it here as much as possible:
The migration showed some problems in how the tests were run. Some asynchronous functions were not properly accounted for. This was hard to spot if you run tests 1 by 1, but if you check out to the latest version and run hardhat test --parallel, then you can observe that the test suite finishes without waiting for all tests to finish
Here's an example of a problematic code block:
It looks like the test runner doesn't properly handle top-level async functions. As a solution, the wallet retrieval was moved into the setupTests function for each test, and the individual test can access it from the function's return values.
yarn --> npm hardhat-toolbox is an umbrella package with many dependencies that yarn v1 doesn't handle well and requires installing all the peer dependencies individually, which is suboptimal. Given the fact that yarn v1 is not maintained anymore (the last version was released over a year ago), I decided to migrate the project to npm.
solhint-prettier solhint prettier plugin isn't actively maintained and does not support the latest prettier version. There's a newer plugin, prettier-plugin-solidity for formatting solidity code. I moved the responsibility of formatting to that plugin and solhint is now only responsible for linting solidity code for solidity-related stuff (reentrancies, assembly, etc)
What we get as a benefit after the migration:
Better type-safety in the project because the toolbox generates them out of the box with 0 configuration. We can also add these types to the published npm package and let developers use them.
More reliable test suite
Better interoperability with the modern developer tools
NPM does a WAY better job of checking and flagging incompatible transitive dependencies
This PR started as a dependency upgrade and became an absolute rabbit hole. I'll try to summarize it here as much as possible:
hardhat test --parallel
, then you can observe that the test suite finishes without waiting for all tests to finish Here's an example of a problematic code block:It looks like the test runner doesn't properly handle top-level async functions. As a solution, the wallet retrieval was moved into the
setupTests
function for each test, and the individual test can access it from the function's return values.yarn --> npm
hardhat-toolbox is an umbrella package with many dependencies that yarn v1 doesn't handle well and requires installing all the peer dependencies individually, which is suboptimal. Given the fact that yarn v1 is not maintained anymore (the last version was released over a year ago), I decided to migrate the project to npm.solhint-prettier
solhint prettier plugin isn't actively maintained and does not support the latest prettier version. There's a newer plugin,prettier-plugin-solidity
for formatting solidity code. I moved the responsibility of formatting to that plugin and solhint is now only responsible for linting solidity code for solidity-related stuff (reentrancies, assembly, etc)What we get as a benefit after the migration: