Skip to content
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

Improve 🍴 Fork Tests #503

Merged
merged 109 commits into from
Aug 27, 2024
Merged

Improve 🍴 Fork Tests #503

merged 109 commits into from
Aug 27, 2024

Conversation

bowd
Copy link
Contributor

@bowd bowd commented Aug 24, 2024

Description

Another branch PR on THE BIG ONE. This is a long-overdue cleanup and improvement of our fork tests structure. These tests are important and we will want to maintain and grow them, but the structure they were in made this very hard. They were also terribly brittle and fleaky.

The new structure I'm proposing aims to tackle two main issues:

  • Fork tests were executing assertions for all exchanges in a single test making it hard to debug and follow.
  • Helpers and utility functions weren't structured and were hard to debug and maintain.

Note for reviewers:
99% of the code inside of the functions is just copied from the old structure so I wouldn't do a full review of everything, I would focus on the structure itself. I did make some small tweaks to improve flakiness, for example skipping some of the tests when the limits prevent them, which I think is a fair thing to do, as long as the tests run periodically.

Other changes

I added a CI job for running fork-tests daily on develop.

Tested

Yeah, they are, after all, tests.

Related issues

N/A

Backwards compatibility

N/A

Documentation

N/A

@bowd bowd requested review from nvtaveras and philbow61 August 26, 2024 13:52
bowd added a commit that referenced this pull request Aug 26, 2024
## Description

As I told some of you at dinner, I've had a bad case of insomnia over
the last week. This PR resulted from a couple of late night coding
sessions and the incessant need to make things nicer in our repos.

It's a big PR but 𝚫code is negative so 🤷 .

What happens in this mondo-PR: 

1. All `celo` contracts are removed form the repo and replaced with the
`@celo/contracts` NPM package. With a small caveat.
2. All `interfaces` are made to work with `0.8` and cover more of the
contract functions.
3. All `tests` contracts are updated to `0.8` and use `deployCode`
helpers to deploy lower-version contracts, and the use the interfaces to
interact with them.
4. ~We make use of this foundry-rs/foundry#8668
to improve compile time.~
5. Update `solhint` and `prettier` to a recent version and fix/ignore
all issues.
6. Fix solc compiler warnings.
7. Fix/ignore slither > informational warnings.
8. Slight Refactor of ForkTests to make them better to work with.
9. Restructuring of the tests folder.

#### `@celo/contracts`

The only caveat of using the `@celo/contracts` package is that
`UsingRegistry.sol` in there needs to import things from `mento-core`
and I didn't manage to get it working ok with remappings, so I kept a
copy of `UsingRegistry.sol` in `contracts/common`. It's only used in
`swap/Reserve.sol` and when we remove it from there we can completely
kill `common`.

#### The foundry WIP PR

A better solution was found here #502, which removes the need for
`via-ir` completely.

~The reason it takes so long to compile our code is because we need
`via-ir` for `Airgrab.sol` and `StableTokenV2.sol`, and `via-ir` is
super slow. But with the compiler restrictions implemented in
foundry-rs/foundry#8668 we can have multiple
compiler profile settings for subgraphs of the source-graph, which
compile in parallel with different settings.~

~You can easily install that version of foundry locally, (you have to
have rust installed tho):~
```
foundryup -P 8668
```

~With this version of foundry and the settings in `foundry.toml`, if
you're not working in a part of the source graph that contains
`Airgrab.sol` or `StableTokenV2.sol`, compilation will happen without
`via-ir` and will be super snappy. However if you do touch that source
graph it will still take noticeably long. Right now on my machine full
clean compilation takes 80seconds. It used to take >3minutes.~

#### ForkTest Refactoring

Our fork tests can get a bit heavy because they're running test
assertions for all the exchanges in a single test call. I've refactor it
a bit and split out exchange assertions into their own tests contracts
that need to be manually created when new exchanges are deployed.
There's a chain-level assertion on the number of exchanges that helps us
catch this and keep them up to date.

This work was continued here #503 for a much cleaner solution.

### Other changes

> _Describe any minor or "drive-by" changes here._

no minor changes here, no :))

### Tested

Tested? Tested!

### Related issues

Fixes the issues in my head.

### Backwards compatibility

What even is that?

### Documentation

Holy Bible

---------

Co-authored-by: Bayological <6872903+bayological@users.noreply.github.com>
Co-authored-by: chapati <philip.paetz@me.com>
Co-authored-by: philbow61 <80156619+philbow61@users.noreply.github.com>
Base automatically changed from feat/remove-need-for-via-ir to develop August 27, 2024 11:56
Copy link
Contributor

@philbow61 philbow61 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM I really like the new structures 👍

test/fork/ExchangeForkTest.sol Show resolved Hide resolved
test/fork/ExchangeForkTest.sol Outdated Show resolved Hide resolved
test/fork/BaseForkTest.sol Outdated Show resolved Hide resolved
.github/workflows/fork-tests.yaml Show resolved Hide resolved
@bowd bowd merged commit 24a2e68 into develop Aug 27, 2024
5 checks passed
@bowd bowd deleted the feat/improve-fork-tests branch August 27, 2024 16:40
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.

4 participants