MCPcopy Create free account
hub / github.com/erpc/erpc / TestHttpServer_HandleHealthCheck

Function TestHttpServer_HandleHealthCheck

erpc/http_server_test.go:3713–4525  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3711}
3712
3713func TestHttpServer_HandleHealthCheck(t *testing.T) {
3714 testCtx, testCtxCancel := context.WithCancel(context.Background())
3715 defer testCtxCancel()
3716
3717 logger := &log.Logger
3718 vr := thirdparty.NewVendorsRegistry()
3719 pr, err := thirdparty.NewProvidersRegistry(logger, vr, []*common.ProviderConfig{}, nil)
3720 require.NoError(t, err)
3721 ssr, err := data.NewSharedStateRegistry(testCtx, logger, &common.SharedStateConfig{
3722 ClusterKey: "test",
3723 Connector: &common.ConnectorConfig{
3724 Driver: common.DriverMemory,
3725 Memory: &common.MemoryConnectorConfig{
3726 MaxItems: 100_000, MaxTotalSize: "1GB",
3727 },
3728 },
3729 })
3730 require.NoError(t, err)
3731 mtk := health.NewTracker(logger, "test", 1*time.Second)
3732 up1 := &common.UpstreamConfig{
3733 Id: "test-upstream",
3734 Type: common.UpstreamTypeEvm,
3735 Endpoint: "http://rpc1.localhost",
3736 Evm: &common.EvmUpstreamConfig{
3737 ChainId: 123,
3738 },
3739 }
3740
3741 tests := []struct {
3742 name string
3743 setupServer func(ctx context.Context) *HttpServer
3744 projectId string
3745 architecture string
3746 chainId string
3747 request *http.Request
3748 wantStatus int
3749 wantBody string
3750 wantCacheHit bool
3751 }{
3752 {
3753 name: "Basic healthcheck",
3754 setupServer: func(ctx context.Context) *HttpServer {
3755 pp := &PreparedProject{
3756 Config: &common.ProjectConfig{Id: "test", Upstreams: []*common.UpstreamConfig{up1}},
3757 upstreamsRegistry: upstream.NewUpstreamsRegistry(ctx, logger, "", []*common.UpstreamConfig{up1}, ssr, nil, vr, pr, nil, mtk, nil),
3758 }
3759 pp.upstreamsRegistry.Bootstrap(ctx)
3760 pp.networksRegistry = NewNetworksRegistry(pp, ctx, pp.upstreamsRegistry, mtk, nil, nil, nil, logger)
3761 return &HttpServer{
3762 logger: logger,
3763 erpc: &ERPC{
3764 projectsRegistry: &ProjectsRegistry{
3765 preparedProjects: map[string]*PreparedProject{
3766 "test": pp,
3767 },
3768 },
3769 },
3770 healthCheckCfg: &common.HealthCheckConfig{

Callers

nothing calls this directly

Calls 15

CordonMethod · 0.95
NewSharedStateRegistryFunction · 0.92
NewTrackerFunction · 0.92
NewUpstreamsRegistryFunction · 0.92
ResetGockFunction · 0.92
SafeReadBodyFunction · 0.92
NewAuthRegistryFunction · 0.92
NewNetworksRegistryFunction · 0.85
GetAllUpstreamsMethod · 0.80
StoreMethod · 0.80

Tested by

no test coverage detected