scaffold-eth-typescript-challenges icon indicating copy to clipboard operation
scaffold-eth-typescript-challenges copied to clipboard

Improvements to hh tests - fixtures, split contract_address

Open joescharf opened this issue 3 years ago • 1 comments

Was adding the hardhat tests for challenge 1, but looks like @pontus-dev beat me to it (nice!). However, my port of the challenge-1 tests improves on a few things beyond a direct port of the javascript version, so I'm submitting it in case it proves to be useful:

  1. Create a setup fixture for the tests to take advantage of hardhat-deploy plugin fixture capability
  2. Use the hardhat-deploy plugin deployments.fixture() to deploy or access the contracts (no need to manually deploy the contracts as part of the test case. (i.e lines 33-40 and 105,106 unnecessary)
  3. Split out the local and CONTRACT_ADDRESS tests
  4. Pretty sure there was an error in Should redeploy Staker, stake, not get enough, and withdraw test where the Staking was being called with the default deployer address, but the withdraw was being requested with secondAccount which wouldn't have a positive balance in that scenario.

This is my first PR for this repo, hopefully I'm not taking too many liberties with my refactor of the tests.

joescharf avatar Feb 20 '22 16:02 joescharf

Thanks for the PR. Sorry for the delay on reviewing this. I'm going to take a closer look tonight and try to get this merged.

grothem avatar Mar 24 '22 14:03 grothem