-
Notifications
You must be signed in to change notification settings - Fork 193
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(inflation): small fixes and tests #1765
Conversation
WalkthroughThe codebase has been updated to improve clarity and testing. A comment has been added in the inflation calculation code to explain the conversion to a specific unit, referencing the token curve. Testing has been expanded to cover scenarios where inflation is not enabled, ensuring proper behavior in such cases. Additionally, a typographical error has been fixed in a test function name, and the project's terminology has been standardized to consistently refer to the "inflation" module. Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (3)
- x/inflation/types/inflation_calculation.go (1 hunks)
- x/inflation/types/inflation_calculation_test.go (3 hunks)
- x/inflation/types/params.go (1 hunks)
Files skipped from review due to trivial changes (2)
- x/inflation/types/inflation_calculation.go
- x/inflation/types/params.go
Additional comments: 4
x/inflation/types/inflation_calculation_test.go (4)
32-33: The comments added in lines 32-33 provide clarity on the test's intention to run for 10 years despite only the first 8 years having inflation with default parameters. This is a good practice as it explains the rationale behind the test loop's range.
45-47: The updated assertions in lines 45 and 47 use the corrected
withinRange
function to check if the calculated yearly inflation is within the expected range or equals zero. This is a logical correction and ensures that the tests are checking the right conditions.54-76: The new test function
TestCalculateEpochMintProvisionInflationNotEnabled
from lines 54-76 correctly setsInflationEnabled
tofalse
and asserts that the total inflation remains zero throughout the 10-year period. This test is important for validating the behavior of the system when inflation is not enabled.89-92: The
withinRange
function in lines 89-92 has been updated to correct the function name and to set a default tolerance. The logic to check if the actual value is within the expected range seems correct. However, it's important to ensure that the tolerance level is appropriate for all use cases wherewithinRange
is used.Verification successful
The search for "tolerance" within the
inflation_calculation_test.go
file has returned the comment and the function definition forwithinRange
. The comment explicitly states that the tolerance is a percentage set to 0.01% by default. There are no indications of different tolerance requirements for thewithinRange
function within the provided context. The tolerance level is documented and appears to be consistently applied in the test cases wherewithinRange
is used.Based on the information provided, the tolerance level set in the
withinRange
function is consistent with the test cases' expectations, and there are no suggestions for different tolerance requirements in the comments or documentation.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the tolerance level set in withinRange function is consistent with all test cases expectations. rg --type go "withinRange"Length of output: 524
Script:
#!/bin/bash # Search for any comments or documentation within the test file that might suggest a different tolerance requirement for withinRange. rg --type go -C 3 "tolerance" x/inflation/types/inflation_calculation_test.goLength of output: 655
Purpose / Abstract
Went through the code to look for bugs, could just find typos and added a bit of comments to add more context.
Summary by CodeRabbit