(t *testing.T)
| 518 | } |
| 519 | |
| 520 | func (s) TestServerCredsDispatch(t *testing.T) { |
| 521 | lis, err := net.Listen("tcp", "localhost:0") |
| 522 | if err != nil { |
| 523 | t.Fatal(err) |
| 524 | } |
| 525 | cred := &serverDispatchCred{ |
| 526 | rawConnCh: make(chan net.Conn, 1), |
| 527 | } |
| 528 | s := grpc.NewServer(grpc.Creds(cred)) |
| 529 | go s.Serve(lis) |
| 530 | defer s.Stop() |
| 531 | |
| 532 | cc, err := grpc.NewClient(lis.Addr().String(), grpc.WithTransportCredentials(cred)) |
| 533 | if err != nil { |
| 534 | t.Fatalf("grpc.NewClient(%q) = %v", lis.Addr().String(), err) |
| 535 | } |
| 536 | defer cc.Close() |
| 537 | cc.Connect() |
| 538 | |
| 539 | rawConn := cred.getRawConn() |
| 540 | // Give grpc a chance to see the error and potentially close the connection. |
| 541 | // And check that connection is not closed after that. |
| 542 | time.Sleep(100 * time.Millisecond) |
| 543 | // Check rawConn is not closed. |
| 544 | if n, err := rawConn.Write([]byte{0}); n <= 0 || err != nil { |
| 545 | t.Errorf("Read() = %v, %v; want n>0, <nil>", n, err) |
| 546 | } |
| 547 | } |
nothing calls this directly
no test coverage detected