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

Struct fakeHub

internal/serverapi/fakehub_test.go:22–24  ·  view source on GitHub ↗

fakeHub 是单测用的 hub 适配器:把 nodes.Client 的 RPC 方法名映射到 内联 handler,返回预置 JSON 响应。模拟节点行为而无需启动真实节点。 用法: hub := &fakeHub{ handlers: map[string]func(body any) (json.RawMessage, error){ "Usage": func(any) (json.RawMessage, error) { return json.RawMessage(`{"running":true}`), nil }, "

Source from the content-addressed store, hash-verified

20// }
21// client := nodes.NewClientWithHub("n1", hub)
22type fakeHub struct {
23 handlers map[string]func(body any) (json.RawMessage, error)
24}
25
26func (f *fakeHub) Call(_ context.Context, _ string, method string, body any) (json.RawMessage, error) {
27 if h, ok := f.handlers[method]; ok {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected