(t *testing.T)
| 3711 | } |
| 3712 | |
| 3713 | func 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{ |
nothing calls this directly
no test coverage detected