Skip to content

Commit

Permalink
Replace hardcoded upper boundaries with maxResetReleaseTimerDays
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Matthyser committed Jun 18, 2024
1 parent 6b05bff commit b8d2c6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion node/pkg/adminrpc/adminserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ func (s *nodePrivilegedService) ChainGovernorResetReleaseTimer(ctx context.Conte
}

if req.NumDays < 1 || req.NumDays > maxResetReleaseTimerDays {
return nil, fmt.Errorf("the specified number of days falls outside the range of 1 to 7")
return nil, fmt.Errorf("the specified number of days falls outside the range of 1 to %d", maxResetReleaseTimerDays)
}

resp, err := s.governor.ResetReleaseTimer(req.VaaId, req.NumDays)
Expand Down
11 changes: 8 additions & 3 deletions node/pkg/adminrpc/adminserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,24 @@ func TestChainGovernorResetReleaseTimer(t *testing.T) {
},
"NumDaysEqualsUpperBoundary": {
vaaId: "valid",
numDays: 7,
numDays: maxResetReleaseTimerDays,
expectedResult: success,
},
"NumDaysExceedsUpperBoundary": {
vaaId: "valid",
numDays: 8,
numDays: maxResetReleaseTimerDays + 1,
expectedResult: boundsCheckFailure,
},
"EmptyVaaIdAndNumDaysExceedsUpperBoundary": {
vaaId: "",
numDays: 1000,
numDays: maxResetReleaseTimerDays + 1,
expectedResult: vaaIdLengthFailure,
},
"NumDaysSignificantlyExceedsUpperBoundary": {
vaaId: "valid",
numDays: maxResetReleaseTimerDays + 1000,
expectedResult: boundsCheckFailure,
},
}

ctx := context.Background()
Expand Down

0 comments on commit b8d2c6e

Please sign in to comment.