Skip to content

[PROD-2020] Improve OH tests #35

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

Merged
merged 5 commits into from
Oct 5, 2022
Merged

[PROD-2020] Improve OH tests #35

merged 5 commits into from
Oct 5, 2022

Conversation

mauricedesaxe
Copy link
Contributor

@mauricedesaxe mauricedesaxe commented Sep 29, 2022

Why?

To ensure the quality and working state of the OffsetHelper while also making tests more understandable and easier to work on when needed.

How?

Note: The diff may seem big (or at least it does to me), but most of it is very similar refactorings that just repeat multiple times.

I first did a few small refactorings like:

  • renaming the test file to have the .test.ts extension
  • removing unused imports
  • fixed the ts-ignores that existed
  • removed the problematic .not.be.reverted (why is it problematic? see the issue description here)
  • extracted parseEther("1.0")s into a constant

Then I went on to bigger work:

Improving autoOffset, autoRedeem and autoRetire related tests

I grouped each of these, as relevant to their tested method, in their own commit because they were quite similar. I took each test (where it made sense) and I:

  • extracted the token cost in a constant within the scope of the test (for readability & where applicable)
  • create chain state checks that verify whether token balances and BCT/NCT supply have changed accordingly
  • I used proper messages in expect so when tests fail you know where it failed
  • I structured tests and commented on each section so it is as easy to understand as possible

Follow-up

I feel like the current improvements already take this a long way, but there are other things that I want to do. The problem is that this is already a lengthy PR and I don't want to make it even harder to review.

Some of the things I want to do in a follow-up PR:

  • research & implement a good way to check the state of tco2 supply in OH tests
  • add test failure messages in deposit(), withdraw() and particularly swap() tests
  • extract the wrapping of matic in the should retire using a WMATIC swap and NCT redemption test to beforeAll scope

- removed unused imports
- fixed ts-ignores
- removed problematic `.not.be.reverted`
- extracted parseEther("1.0") to a constant
- extract token cost where it made sense
- pre/post token balance check
- pre/post BCT/NCT supply check
- token balance checks for user and contract
- NCT/BCT supply checks
- token balance checks for user and contract
- NCT/BCT supply checks
@mauricedesaxe mauricedesaxe marked this pull request as ready for review September 29, 2022 19:31
@mauricedesaxe mauricedesaxe merged commit 0affee8 into ToucanProtocol:main Oct 5, 2022
@mauricedesaxe mauricedesaxe deleted the prod-2020-improve-oh-tests branch October 5, 2022 12:35
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

Successfully merging this pull request may close these issues.

2 participants