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

feat(RewardsStreamerMP.t.sol): Make tests use calc functions and test… #83

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

3esmit
Copy link
Contributor

@3esmit 3esmit commented Dec 2, 2024

… those functions

Description

Fixes #81

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Added natspec comments?
  • Ran pnpm adorno?
  • Ran pnpm verify?

@3esmit
Copy link
Contributor Author

3esmit commented Dec 2, 2024

Currently this only affects functions related to MP, but all functions that are using magic numbers should have their own calculation function, which is tested by itself.

Also, not all MPs are yet changed to use the calculation functions, so this is a WIP and I expect to finish this week.

@0x-r4bbit
Copy link
Collaborator

@3esmit this one needs some pnpm adorno love I believe :)

@@ -760,7 +839,7 @@ contract StakeTest is RewardsStreamerMPTest {
);

uint256 currentTime = vm.getBlockTimestamp();
uint256 timeToMaxMP = _calculateTimeToMPLimit(stakeAmount);
uint256 timeToMaxMP = _calculateTimeToMP(stakeAmount, totalMaxMP - totalMP);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason this is changed? I think reading "calculate time to max MP" is more intuitive than what this change is doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because calculateTimeToMP is more generic, and can be reused for other tests. While TimeToMPLimit would hardcode this function to always calculate time to max mp.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should at least rename this. "time to MP" doesn't make sense. I no longer understand what the function is doing without looking at its source.

return timeInSeconds;
}

function _calculateTimeToMP(uint256 amount, uint256 target) internal view returns (uint256) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably rename this. "calculate time to MP" doesn't make a lot of sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to _calculateTimeToAccureMP

@0x-r4bbit
Copy link
Collaborator

@3esmit FYI there's also #92 which touches the test functions as well. Might make sense to rebase on top of that. Also happy to update #92 if this one here lands first.

@3esmit 3esmit force-pushed the fix/tests branch 3 times, most recently from 781c3ea to 3f1c79f Compare December 6, 2024 13:18
Copy link
Collaborator

@0x-r4bbit 0x-r4bbit left a comment

Choose a reason for hiding this comment

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

Great changes!
Some minor comments to address. Then this can be merged!

// wait for 1 year
uint256 currentTime = vm.getBlockTimestamp();
vm.warp(currentTime + (365 days));

vm.warp(currentTime + (warpLength));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thnk warplength is not necessary here. It doesn't add any value.

… those functions

chore(linter): added solhint-disable-next-line max-line-length to circumvent bug in linter

chore(RewardsStreamerMP.t.sol): rename _calculateTimeToMP -> _calculateTimeToAccureMP
@0x-r4bbit 0x-r4bbit merged commit eff15a8 into main Dec 9, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Tests should stop using hardcoded values
2 participants