Skip to content

Commit

Permalink
add todo
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo committed May 7, 2024
1 parent 7904449 commit 2f26203
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion listener/internal/api/validation/GetActiveValidators.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func GetActiveValidators(requestsDecoded []types.SignatureRequestDecoded, beacon
}

// serialize the request body to JSON
// see https://ethereum.github.io/beacon-APIs/#/Beacon/postStateValidators
jsonData, err := json.Marshal(struct {
Ids []string `json:"ids"`
Statuses []string `json:"statuses"`
Expand All @@ -48,7 +49,8 @@ func GetActiveValidators(requestsDecoded []types.SignatureRequestDecoded, beacon
}

// configure HTTP client with timeout
client := &http.Client{Timeout: 10 * time.Second}
// TODO: test timeout
client := &http.Client{Timeout: 50 * time.Second}
url := fmt.Sprintf("%s/eth/v1/beacon/states/head/validators", url)
resp, err := client.Post(url, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
Expand All @@ -70,6 +72,7 @@ func GetActiveValidators(requestsDecoded []types.SignatureRequestDecoded, beacon
}

// assuming the server returns a list of active validators in the format expected
// TODO: get data type an unmarshall to that type
if err := json.Unmarshal(responseData, &activeValidators); err != nil {
fmt.Printf("error unmarshaling response data: %v\n", err)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func TestGetActiveValidators(t *testing.T) {
// Setup the input data
beaconNodeUrls := map[string]string{
"holesky": "https://holesky.infura.io/v3/e6c920580178424bbdf6dde266bfb5bd",
"holesky": "https://test.53650f79ab75c6ff.dyndns.dappnode.io/",
}

requestsDecoded := []types.SignatureRequestDecoded{
Expand Down

0 comments on commit 2f26203

Please sign in to comment.