MCPcopy
hub / github.com/syncthing/syncthing / TestClusterConfigAfterClose

Function TestClusterConfigAfterClose

lib/protocol/protocol_test.go:502–523  ·  view source on GitHub ↗

TestClusterConfigAfterClose checks that ClusterConfig does not deadlock when ClusterConfig is called on a closed connection.

(t *testing.T)

Source from the content-addressed store, hash-verified

500// TestClusterConfigAfterClose checks that ClusterConfig does not deadlock when
501// ClusterConfig is called on a closed connection.
502func TestClusterConfigAfterClose(t *testing.T) {
503 m := newTestModel()
504
505 rw := testutil.NewBlockingRW()
506 c := getRawConnection(NewConnection(c0ID, rw, rw, testutil.NoopCloser{}, m, new(mockedConnectionInfo), CompressionAlways, testKeyGen))
507 c.Start()
508 defer closeAndWait(c, rw)
509
510 c.internalClose(errManual)
511
512 done := make(chan struct{})
513 go func() {
514 c.ClusterConfig(&ClusterConfig{}, nil)
515 close(done)
516 }()
517
518 select {
519 case <-done:
520 case <-time.After(time.Second):
521 t.Fatal("timed out before Cluster Config returned")
522 }
523}
524
525func TestDispatcherToCloseDeadlock(t *testing.T) {
526 // Verify that we don't deadlock when calling Close() from within one of

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected