MCPcopy
hub / github.com/syncthing/syncthing / TestRequestZeroSize

Function TestRequestZeroSize

lib/protocol/protocol_test.go:595–621  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

593}
594
595func TestRequestZeroSize(t *testing.T) {
596 // A zero-sized request should be accepted, since current versions of
597 // Syncthing send these. See https://github.com/syncthing/syncthing/issues/10709.
598 m := newTestModel()
599 rw := testutil.NewBlockingRW()
600 c := getRawConnection(NewConnection(c0ID, rw, &testutil.NoopRW{}, testutil.NoopCloser{}, m, new(mockedConnectionInfo), CompressionAlways, testKeyGen))
601 c.Start()
602 defer closeAndWait(c, rw)
603
604 c.inbox <- &bep.ClusterConfig{}
605 c.inbox <- &bep.Request{
606 Id: 1,
607 Name: "valid",
608 Size: 0,
609 }
610
611 select {
612 case res := <-c.outbox:
613 if msg, ok := res.msg.(*bep.Response); !ok || msg.Id != 1 {
614 t.Errorf("bad response %#v", msg)
615 }
616 case <-c.dispatcherLoopStopped:
617 t.Fatal("dispatcher loop terminated, expected zero-sized request to be accepted")
618 case <-time.After(time.Second):
619 t.Fatal("timed out waiting for response")
620 }
621}
622
623func TestRequestInvalidFilename(t *testing.T) {
624 m := newTestModel()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected