[flash-swap] Increase test coverage by testing both token orderings
PaulRBerg opened this issue · 0 comments
PaulRBerg commented
@scorpion9979's #39 made the HifiFlashSwapUniswapV2
contract more general purpose, but it came at a cost of reducing test coverage.
Prior to the PR, we had a GodModeUniswapV2Pair contract that we were deploying via waffle.deployContract
. Now we're using the original UniswapV2Pair
contracts and we're deploying them via UniswapV2Factory
. This makes it hard to know the order of the two pool tokens in advance (read about how ordering works here).
Two potential solutions, ordered by how good they would be:
- Use the hardhat_setCode JSON-RPC method to deploy the tokens at known addresses.
- Run a
while
loop and make newGodModeErc20
deployments until a new token ordering is found.
The 1st solution would be ideal, but hardhat_setCode
has bugs: NomicFoundation/hardhat#1883. The 2nd is not nice because it involves non-determinism.