Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yhassanzadeh13 committed May 27, 2022
1 parent 8b64966 commit c00510e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (b *backoff) updateAndGet(id peer.ID) (time.Duration, error) {
duration: time.Duration(0),
attempts: 0,
}
case h.attempts > b.maxAttempts:
case h.attempts >= b.maxAttempts:
return 0, fmt.Errorf("peer %s has reached its maximum backoff attempts", id)

case h.duration < MinBackoffDelay:
Expand Down
4 changes: 2 additions & 2 deletions backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func TestBackoff_Update(t *testing.T) {
}

// trying once more beyond the threshold, hence expecting exceeding threshold
if _, err := b.updateAndGet(id1); err != nil {
t.Fatalf("invalid exceeding threshold status: %s", err)
if _, err := b.updateAndGet(id1); err == nil {
t.Fatalf("expected an error for going beyond threshold but got a nil: %s", err)
}

got, err := b.updateAndGet(id2)
Expand Down

0 comments on commit c00510e

Please sign in to comment.