-
Notifications
You must be signed in to change notification settings - Fork 0
/
beacon_api_verify.go
46 lines (40 loc) · 1.23 KB
/
beacon_api_verify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package beaconapi_evaluators
import (
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/policies"
e2etypes "github.com/prysmaticlabs/prysm/v4/testing/endtoend/types"
"google.golang.org/grpc"
)
// BeaconAPIMultiClientVerifyIntegrity tests our API Middleware responses to other beacon nodes such as lighthouse.
var BeaconAPIMultiClientVerifyIntegrity = e2etypes.Evaluator{
Name: "beacon_api_multi-client_verify_integrity_epoch_%d",
Policy: policies.AfterNthEpoch(0),
Evaluation: beaconAPIVerify,
}
const (
v1MiddlewarePathTemplate = "http://localhost:%d/eth/v1"
v2MiddlewarePathTemplate = "http://localhost:%d/eth/v2"
)
type apiComparisonFunc func(beaconNodeIdx int, conn *grpc.ClientConn) error
func beaconAPIVerify(_ *e2etypes.EvaluationContext, conns ...*grpc.ClientConn) error {
beacon := []apiComparisonFunc{
withCompareBeaconAPIs,
}
for beaconNodeIdx, conn := range conns {
if err := runAPIComparisonFunctions(
beaconNodeIdx,
conn,
beacon...,
); err != nil {
return err
}
}
return nil
}
func runAPIComparisonFunctions(beaconNodeIdx int, conn *grpc.ClientConn, fs ...apiComparisonFunc) error {
for _, f := range fs {
if err := f(beaconNodeIdx, conn); err != nil {
return err
}
}
return nil
}