-
Notifications
You must be signed in to change notification settings - Fork 613
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
[VS Incentives] refactor/test: move group gauge creation to CreateGauge; address spam concerns #6536
Conversation
s.Require().NoError(err) | ||
externalGauge, err := s.App.IncentivesKeeper.GetGaugeByID(s.Ctx, externalGaugeid) | ||
s.Require().NoError(err) | ||
externalGauge := s.createGaugeNoRestrictions(tc.isPerpertual, tc.gaugeCoins, tc.distrTo, tc.startTime, tc.numEpochsPaidOver, defaultCLPool) |
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.
Note: it was required to modify the test and create this helper due to stricter validation in CreateGauge
. The goal is to setup an invalid gauge state so that Distribute()
function below fails. With the old logic, it was impossible to hit edge cases while keeping stricter validation
const ( | ||
zeroPoolId = uint64(0) | ||
balancerPoolId = uint64(1) | ||
concentratedPoolId = uint64(2) | ||
invalidPool = uint64(3) | ||
// 3 are created for balancer pool and 1 for CL. | ||
// As a result, the next gauge id should be 5. | ||
defaultExpectedGaugeId = uint64(5) | ||
|
||
defaultIsPerpetualParam = false | ||
|
||
defaultNumEpochPaidOver = uint64(10) | ||
) | ||
|
||
var ( | ||
defaultCoins = sdk.NewCoins( | ||
sdk.NewCoin("uosmo", osmomath.NewInt(100000)), | ||
sdk.NewCoin("atom", osmomath.NewInt(99999)), | ||
) | ||
|
||
defaultTime = time.Unix(0, 0) | ||
) |
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.
Note: moved up to share across tests and reduce duplication
if numEpochPaidOver == 0 { | ||
return 0, types.ErrZeroNumEpochsPaidOver | ||
} |
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.
Note: perpetual gauges are signified by numEpochPaidOver
of 0
…ge; address spam concerns
d25ea9f
to
4c795aa
Compare
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.
Nice 👍
func (s KeeperTestSuite) validateNoGaugeIDInSlice(slice []types.Gauge, gaugeID uint64) { | ||
gaugeMatch := osmoutils.Filter(func(gauge types.Gauge) bool { | ||
return gauge.Id == gaugeID | ||
}, slice) | ||
// No gauge matched ID. | ||
s.Require().Empty(gaugeMatch) | ||
|
||
} |
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.
Can ignore but this feels like we could maybe abstract this helper as a whole to osmoutils
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.
Probably not osmoutils
because this depends on apptesting.Suite
. I will move this to apptesting
though, good idea!
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.
Will address in next PR
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
…ge; address spam concerns (#6536) * [Volume Splitting] feat: implement initGaugeInfo helper * comments * refactor/test: CreateGroup takes pool IDs; new tests * lint * [VS Incentives]: feat: group creation fee * comment updates * fixes issues * [VS Incentives] refactor/test: move group gauge creation to CreateGauge; address spam concerns * Update x/incentives/keeper/gauge_test.go Co-authored-by: Adam Tucker <[email protected]> * Update x/incentives/keeper/gauge_test.go Co-authored-by: Adam Tucker <[email protected]> --------- Co-authored-by: Adam Tucker <[email protected]>
Closes: #6513, #6491
What is the purpose of the change
This PR focuses low-level and repetitive group gauge creation logic in
CreateGroup
and, instead, moves that underCreateGauge
.This also addresses the spam concern in #6491 since
CreateGauge
already handles that.This PR also added stricter checks for the input validation to
CreateGauge
Testing and Verifying
Documentation and Release Note
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)