MCPcopy
hub / github.com/grpc/grpc-go / TestStateTransitions_SingleAddress

Method TestStateTransitions_SingleAddress

test/clientconn_state_transition_test.go:81–174  ·  view source on GitHub ↗

Tests for state transitions in various scenarios with a single address.

(t *testing.T)

Source from the content-addressed store, hash-verified

79
80// Tests for state transitions in various scenarios with a single address.
81func (s) TestStateTransitions_SingleAddress(t *testing.T) {
82 for _, test := range []struct {
83 desc string
84 wantStates []connectivity.State
85 server func(net.Listener) net.Conn
86 }{
87 {
88 desc: "ServerSendsPreface",
89 wantStates: []connectivity.State{
90 connectivity.Connecting,
91 connectivity.Ready,
92 },
93 server: func(lis net.Listener) net.Conn {
94 conn, err := lis.Accept()
95 if err != nil {
96 t.Error(err)
97 return nil
98 }
99
100 go keepReading(conn)
101
102 framer := http2.NewFramer(conn, conn)
103 if err := framer.WriteSettings(http2.Setting{}); err != nil {
104 t.Errorf("Error while writing settings frame. %v", err)
105 return nil
106 }
107
108 return conn
109 },
110 },
111 {
112 desc: "ConnectionClosesBeforeServerPreface",
113 wantStates: []connectivity.State{
114 connectivity.Connecting,
115 connectivity.TransientFailure,
116 },
117 server: func(lis net.Listener) net.Conn {
118 conn, err := lis.Accept()
119 if err != nil {
120 t.Error(err)
121 return nil
122 }
123
124 conn.Close()
125 return nil
126 },
127 },
128 {
129 desc: "ConnectionClosesBeforeClientPreface",
130 wantStates: []connectivity.State{
131 connectivity.Connecting,
132 connectivity.TransientFailure,
133 },
134 server: func(lis net.Listener) net.Conn {
135 conn, err := lis.Accept()
136 if err != nil {
137 t.Error(err)
138 return nil

Callers

nothing calls this directly

Calls 6

keepReadingFunction · 0.70
ErrorMethod · 0.65
ErrorfMethod · 0.65
CloseMethod · 0.65
AcceptMethod · 0.45

Tested by

no test coverage detected