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

Fix address conflicts in FinthetixStakingContract tests #5

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

sayandcode
Copy link
Owner

What?

In our tests we now make sure that the randomly generated addresses don't conflict with the address of the staking contract and associated tokens. We also make sure that if there are multiple addresses being used inside the test, that those don't overlap as well.

Why?

This bug in the tests were making the fuzz tests fail occasionally. They fail rarely since there's only a small chance that the randomly generated addresses overlap.

How?

We added a test helper function _assumeAddressDoesntConflictWithFinthetix, which makes sure the address passed in doesn't conflict with the Finthetix reserved addresses

…ests

In our tests we now make sure that the randomly generated addresses don't
conflict with the address of the staking contract and associated tokens.
We also make sure that if there are multiple addresses being used inside
the test, that those don't overlap as well.

This bug in the tests were making the fuzz tests fail occasionally, since
there's only a small chance that the randomly generated addresses overlap
For some of the tests we don't fuzz for random addresses, but rather use
static addresses to impersonate a user. However, we never considered the
fact that these addresses could conflict with the `Finthetix` addresses
as well. So in order to make sure this is not the case, we explicitly
check this in the `setup()` function.

The addresses of the `Finthetix` contracts depend on some random seed.
So we can trust that for a given condition of the codebase, the addresses
will be consistent. Hence we are okay with explicitly failing these tests
in case there is a conflict, since in such a condition we can manually
alter these burner addresses (effectively changing the seed)
@sayandcode sayandcode merged commit 40b0214 into main Mar 7, 2024
1 check passed
@sayandcode sayandcode deleted the fix/contract-test-address-conflict branch March 29, 2024 10:28
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.

1 participant