mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
RPC: healthz should return an error when the node is syncing (#7890)
* RPC: healthz should return an error when the node is syncing * fix test * fix test Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"sync"
|
||||
@@ -337,6 +338,9 @@ func (s *Service) Stop() error {
|
||||
|
||||
// Status returns nil or credentialError
|
||||
func (s *Service) Status() error {
|
||||
if s.syncService.Syncing() {
|
||||
return errors.New("syncing")
|
||||
}
|
||||
if s.credentialError != nil {
|
||||
return s.credentialError
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestLifecycle_OK(t *testing.T) {
|
||||
|
||||
func TestStatus_CredentialError(t *testing.T) {
|
||||
credentialErr := errors.New("credentialError")
|
||||
s := &Service{credentialError: credentialErr}
|
||||
s := &Service{credentialError: credentialErr, syncService: &mockSync.Sync{IsSyncing: false}}
|
||||
|
||||
assert.ErrorContains(t, s.credentialError.Error(), s.Status())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user