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

Function startNodeMock

internal/nodehub/hub_test.go:102–119  ·  view source on GitHub ↗
(t *testing.T, cc *grpc.ClientConn, nodeID string)

Source from the content-addressed store, hash-verified

100}
101
102func startNodeMock(t *testing.T, cc *grpc.ClientConn, nodeID string) *nodeMock {
103 t.Helper()
104 client := nodev1.NewNodeAgentClient(cc)
105 ctx := metadata.AppendToOutgoingContext(context.Background(), "x-node-id", nodeID)
106 stream, err := client.Session(ctx)
107 if err != nil {
108 t.Fatalf("Session start: %v", err)
109 }
110 m := &nodeMock{
111 stream: stream,
112 cancelIDs: make(chan string, 16),
113 acks: make(chan []byte, 16),
114 handlers: make(map[string]func(string, []byte) (bool, []byte, string)),
115 done: make(chan struct{}),
116 }
117 go m.recvLoop()
118 return m
119}
120
121func (m *nodeMock) handle(method string, fn func(reqID string, body []byte) (ok bool, respBody []byte, errStr string)) {
122 m.mu.Lock()

Calls 3

SessionMethod · 0.95
recvLoopMethod · 0.95
NewNodeAgentClientFunction · 0.92

Tested by

no test coverage detected