Tests for state transitions in various scenarios with a single address.
(t *testing.T)
| 79 | |
| 80 | // Tests for state transitions in various scenarios with a single address. |
| 81 | func (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 |
nothing calls this directly
no test coverage detected