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: set max program window lenghts to 200 #11670

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commands/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
ErrMustBeLessThan150 = errors.New("must be less than 150")
ErrMustBeAtMost1M = errors.New("must be at most 1000000")
ErrMustBeAtMost100 = errors.New("must be at most 100")
ErrMustBeAtMost200 = errors.New("must be at most 200")
ErrMustBeAtMost2048 = errors.New("must be at most 2048")
ErrMustBeWithinRange7 = errors.New("must be between -7 and 7")
ErrIsNotValid = errors.New("is not a valid value")
Expand Down
12 changes: 6 additions & 6 deletions commands/proposal_submission.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ func checkReferralProgramChanges(changes *vegapb.ReferralProgramChanges, enactme
}
if changes.WindowLength == 0 {
errs.AddForProperty("update_referral_program.changes.window_length", ErrIsRequired)
} else if changes.WindowLength > 100 {
errs.AddForProperty("update_referral_program.changes.window_length", ErrMustBeAtMost100)
} else if changes.WindowLength > 200 {
errs.AddForProperty("update_referral_program.changes.window_length", ErrMustBeAtMost200)
}

tiers := map[string]struct{}{}
Expand Down Expand Up @@ -449,8 +449,8 @@ func checkVolumeRebateProgramChanges(changes *vegapb.VolumeRebateProgramChanges,
}
if changes.WindowLength == 0 {
errs.AddForProperty("update_volume_rebate_program.changes.window_length", ErrIsRequired)
} else if changes.WindowLength > 100 {
errs.AddForProperty("update_volume_rebate_program.changes.window_length", ErrMustBeAtMost100)
} else if changes.WindowLength > 200 {
errs.AddForProperty("update_volume_rebate_program.changes.window_length", ErrMustBeAtMost200)
}
for i, tier := range changes.BenefitTiers {
errs.Merge(checkVolumeRebateBenefitTier(i, tier))
Expand Down Expand Up @@ -497,8 +497,8 @@ func checkVolumeDiscountProgramChanges(changes *vegapb.VolumeDiscountProgramChan
}
if changes.WindowLength == 0 {
errs.AddForProperty("update_volume_discount_program.changes.window_length", ErrIsRequired)
} else if changes.WindowLength > 100 {
errs.AddForProperty("update_volume_discount_program.changes.window_length", ErrMustBeAtMost100)
} else if changes.WindowLength > 200 {
errs.AddForProperty("update_volume_discount_program.changes.window_length", ErrMustBeAtMost200)
}
for i, tier := range changes.BenefitTiers {
errs.Merge(checkVolumeBenefitTier(i, tier))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ func testSubmissionForReferralProgramUpdateWithWindowLengthOverLimitFails(t *tes
Change: &types.ProposalTerms_UpdateReferralProgram{
UpdateReferralProgram: &types.UpdateReferralProgram{
Changes: &types.ReferralProgramChanges{
WindowLength: 101,
WindowLength: 201,
},
},
},
},
})

assert.Contains(t, err.Get("proposal_submission.terms.change.update_referral_program.changes.window_length"), commands.ErrMustBeAtMost100)
assert.Contains(t, err.Get("proposal_submission.terms.change.update_referral_program.changes.window_length"), commands.ErrMustBeAtMost200)
}

func testSubmissionForReferralProgramUpdateWithoutTierMinimumRunningNotionalTakerVolumeFails(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ func testSubmissionForVolumeDiscountProgramUpdateWithWindowLengthOverLimitFails(
Change: &types.ProposalTerms_UpdateVolumeDiscountProgram{
UpdateVolumeDiscountProgram: &types.UpdateVolumeDiscountProgram{
Changes: &types.VolumeDiscountProgramChanges{
WindowLength: 101,
WindowLength: 201,
},
},
},
},
})

assert.Contains(t, err.Get("proposal_submission.terms.change.update_volume_discount_program.changes.window_length"), commands.ErrMustBeAtMost100)
assert.Contains(t, err.Get("proposal_submission.terms.change.update_volume_discount_program.changes.window_length"), commands.ErrMustBeAtMost200)
}

func testSubmissionForVolumeDiscountProgramUpdateWithoutTierMinimumRunningNotionalTakerVolumeFails(t *testing.T) {
Expand Down
Loading