MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / startMockServer

Function startMockServer

internal/nodeagent/agent_test.go:118–130  ·  view source on GitHub ↗

startMockServer 在 bufconn 上启动 mock,返回 hub + dialer + server stop。

(t *testing.T)

Source from the content-addressed store, hash-verified

116
117// startMockServer 在 bufconn 上启动 mock,返回 hub + dialer + server stop。
118func startMockServer(t *testing.T) (*mockHub, func(context.Context, string) (net.Conn, error), func()) {
119 t.Helper()
120 lis := bufconn.Listen(bufSize)
121 srv := grpc.NewServer()
122 hub := newMockHub()
123 nodev1.RegisterNodeAgentServer(srv, hub)
124 go func() { _ = srv.Serve(lis) }()
125 dialer := func(ctx context.Context, _ string) (net.Conn, error) {
126 return lis.DialContext(ctx)
127 }
128 stop := func() { srv.Stop() }
129 return hub, dialer, stop
130}
131
132// helloProvider 返回一个固定的 hello body。
133func helloProvider() (json.RawMessage, error) {

Callers 7

TestAgent_HelloOnConnectFunction · 0.85
TestAgent_CancelInflightFunction · 0.85
TestAgent_ReconnectFunction · 0.85
TestAgent_CtxCancelFunction · 0.85
TestAgent_UsagePushAckFunction · 0.85

Calls 4

RegisterNodeAgentServerFunction · 0.92
newMockHubFunction · 0.85
StopMethod · 0.65
ServeMethod · 0.45

Tested by

no test coverage detected