Skip to content

Commit 67806a0

Browse files
committed
feat(validate): add support for 206 status code for beacon node validation
The beacon node validation now accepts 206 status code as a valid response. This is because a beacon node that is syncing will return a 206 status code.
1 parent 1722c86 commit 67806a0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

internal/validate/beacon.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package validate
33
import (
44
"fmt"
55
"net/http"
6+
"slices"
67
"strings"
78
"time"
89
)
@@ -49,7 +50,12 @@ func ValidateBeaconNodeAddress(addresses string) error {
4950

5051
defer resp.Body.Close()
5152

52-
if resp.StatusCode != http.StatusOK {
53+
// Acceptable status codes are 200 and 206.
54+
// 200 is the status code for a healthy beacon node.
55+
// 206 is the status code for a beacon node that is syncing.
56+
acceptableStatusCodes := []int{http.StatusOK, http.StatusPartialContent}
57+
58+
if !slices.Contains(acceptableStatusCodes, resp.StatusCode) {
5359
lastErr = fmt.Errorf("beacon node %s returned status %d", address, resp.StatusCode)
5460

5561
continue

internal/validate/beacon_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestValidateBeaconNodeAddress(t *testing.T) {
3333
w.WriteHeader(http.StatusOK)
3434
})),
3535
httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
36-
w.WriteHeader(http.StatusOK)
36+
w.WriteHeader(http.StatusPartialContent)
3737
})),
3838
},
3939
wantErr: false,

0 commit comments

Comments
 (0)