MCPcopy
hub / github.com/syncthing/syncthing / TestCloseTimeout

Function TestCloseTimeout

lib/protocol/protocol_test.go:236–261  ·  view source on GitHub ↗

TestCloseTimeout checks that calling Close times out and proceeds, if sending the close message does not succeed.

(t *testing.T)

Source from the content-addressed store, hash-verified

234// TestCloseTimeout checks that calling Close times out and proceeds, if sending
235// the close message does not succeed.
236func TestCloseTimeout(t *testing.T) {
237 oldCloseTimeout := CloseTimeout
238 CloseTimeout = 100 * time.Millisecond
239 defer func() {
240 CloseTimeout = oldCloseTimeout
241 }()
242
243 m := newTestModel()
244
245 rw := testutil.NewBlockingRW()
246 c := getRawConnection(NewConnection(c0ID, rw, rw, testutil.NoopCloser{}, m, new(mockedConnectionInfo), CompressionAlways, testKeyGen))
247 c.Start()
248 defer closeAndWait(c, rw)
249
250 done := make(chan struct{})
251 go func() {
252 c.Close(errManual)
253 close(done)
254 }()
255
256 select {
257 case <-done:
258 case <-time.After(5 * CloseTimeout):
259 t.Fatal("timed out before Close returned")
260 }
261}
262
263func TestUnmarshalFDPUv16v17(t *testing.T) {
264 var fdpu bep.FileDownloadProgressUpdate

Callers

nothing calls this directly

Calls 8

NewBlockingRWFunction · 0.92
newTestModelFunction · 0.85
getRawConnectionFunction · 0.85
NewConnectionFunction · 0.85
closeAndWaitFunction · 0.85
FatalMethod · 0.80
StartMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected