(t *testing.T)
| 188 | } |
| 189 | |
| 190 | func TestClusterConfigFirst(t *testing.T) { |
| 191 | m := newTestModel() |
| 192 | |
| 193 | rw := testutil.NewBlockingRW() |
| 194 | c := getRawConnection(NewConnection(c0ID, rw, &testutil.NoopRW{}, testutil.NoopCloser{}, m, new(mockedConnectionInfo), CompressionAlways, testKeyGen)) |
| 195 | c.Start() |
| 196 | defer closeAndWait(c, rw) |
| 197 | |
| 198 | select { |
| 199 | case c.outbox <- asyncMessage{&bep.Ping{}, nil}: |
| 200 | t.Fatal("able to send ping before cluster config") |
| 201 | case <-time.After(100 * time.Millisecond): |
| 202 | // Allow some time for c.writerLoop to set up after c.Start |
| 203 | } |
| 204 | |
| 205 | c.ClusterConfig(&ClusterConfig{}, nil) |
| 206 | |
| 207 | done := make(chan struct{}) |
| 208 | if ok := c.send(context.Background(), &bep.Ping{}, done); !ok { |
| 209 | t.Fatal("send ping after cluster config returned false") |
| 210 | } |
| 211 | select { |
| 212 | case <-done: |
| 213 | case <-time.After(time.Second): |
| 214 | t.Fatal("timed out before ping was sent") |
| 215 | } |
| 216 | |
| 217 | done = make(chan struct{}) |
| 218 | go func() { |
| 219 | c.internalClose(errManual) |
| 220 | close(done) |
| 221 | }() |
| 222 | |
| 223 | select { |
| 224 | case <-done: |
| 225 | case <-time.After(5 * time.Second): |
| 226 | t.Fatal("Close didn't return before timeout") |
| 227 | } |
| 228 | |
| 229 | if err := m.closedError(); err != errManual { |
| 230 | t.Fatal("Connection should be closed") |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | // TestCloseTimeout checks that calling Close times out and proceeds, if sending |
| 235 | // the close message does not succeed. |
nothing calls this directly
no test coverage detected