-
Notifications
You must be signed in to change notification settings - Fork 115
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
[OTE-779] Check affiliate tiers are strictly increasing before updating tiers #2220
Conversation
WalkthroughThe changes involve significant updates to the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional comments not posted (1)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- protocol/x/affiliates/keeper/keeper.go (1 hunks)
- protocol/x/affiliates/keeper/keeper_test.go (4 hunks)
Additional comments not posted (2)
protocol/x/affiliates/keeper/keeper.go (1)
221-238
: Comprehensive update toUpdateAffiliateTiers
function.The modifications to the
UpdateAffiliateTiers
function enhance its robustness by introducing error handling for marshaling and validation to ensure that tier requirements are strictly increasing. These changes are crucial for maintaining the integrity of the affiliate tier structure and provide clear error feedback, which is essential for debugging and maintenance.
- Error Handling: The function now properly handles marshaling errors by wrapping them with a contextual error message, which aids in troubleshooting.
- Validation Logic: The validation ensures that each tier's requirements do not decrease, which is vital for the system's operational integrity.
Overall, these changes significantly improve the function's reliability and adherence to business rules.
protocol/x/affiliates/keeper/keeper_test.go (1)
302-349
: Enhanced testing forUpdateAffiliateTiers
.The
TestUpdateAffiliateTiers
function has been significantly improved to include comprehensive test cases that validate both valid and invalid configurations of affiliate tiers. This enhancement is crucial for ensuring the robustness of the tier update functionality.
- Test Coverage: The test cases effectively cover scenarios where tier requirements are either correctly increasing or incorrectly set, which helps in ensuring that the business logic is adhered to strictly.
- Assertions: The use of
require.NoError
for expected successful updates andrequire.ErrorIs
for expected failures due to invalid configurations ensures that the tests are both precise and informative.These changes greatly enhance the reliability of the tests and by extension, the affiliate tier update functionality.
// TODO(OTE-779): Check strictly increasing volume and | ||
// staking requirements hold in UpdateAffiliateTiers | ||
store.Set([]byte(types.AffiliateTiersKey), k.cdc.MustMarshal(&affiliateTiers)) | ||
affiliateTiersBytes, err := k.cdc.Marshal(&affiliateTiers) |
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.
Nit: use k.cdc.MustMarshal
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- protocol/x/affiliates/keeper/keeper.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- protocol/x/affiliates/keeper/keeper.go
6b88537
to
388ee23
Compare
Changelist
Checks volume and staking requirements are strictly increasing in affiliate tiers
Test Plan
Added unit test
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit
New Features
Bug Fixes
UpdateAffiliateTiers
method to capture and assert errors during tier updates.Tests