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

Function startHub

internal/nodeagent/integration_test.go:67–79  ·  view source on GitHub ↗

startHub 用 bufconn 起一个 nodehub.Hub,PeerExtractor 总是返回 "n1"。

(t *testing.T, ph nodehub.PushHandler)

Source from the content-addressed store, hash-verified

65
66// startHub 用 bufconn 起一个 nodehub.Hub,PeerExtractor 总是返回 "n1"。
67func startHub(t *testing.T, ph nodehub.PushHandler) (*nodehub.Hub, func(context.Context, string) (net.Conn, error), func()) {
68 t.Helper()
69 lis := bufconn.Listen(1 << 20)
70 srv := grpc.NewServer()
71 hub := nodehub.New(nodehub.Options{
72 PushHandler: ph,
73 PeerExtractor: func(_ context.Context) (string, error) { return "n1", nil },
74 })
75 nodev1.RegisterNodeAgentServer(srv, hub)
76 go func() { _ = srv.Serve(lis) }()
77 dialer := func(ctx context.Context, _ string) (net.Conn, error) { return lis.DialContext(ctx) }
78 return hub, dialer, func() { srv.Stop() }
79}
80
81// TestIntegration_HelloAndCall 验证 hello 含 config_hash + hub.Call → dispatcher 路由。
82func TestIntegration_HelloAndCall(t *testing.T) {

Calls 4

NewFunction · 0.92
RegisterNodeAgentServerFunction · 0.92
StopMethod · 0.65
ServeMethod · 0.45

Tested by

no test coverage detected