(t *testing.T, cc *grpc.ClientConn, nodeID string)
| 100 | } |
| 101 | |
| 102 | func 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 | |
| 121 | func (m *nodeMock) handle(method string, fn func(reqID string, body []byte) (ok bool, respBody []byte, errStr string)) { |
| 122 | m.mu.Lock() |
no test coverage detected