MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestFastPath

Function TestFastPath

control/controlbase/conn_test.go:82–113  ·  view source on GitHub ↗

TestFastPath exercises the Read codepath that can receive multiple Noise frames at once and decode each in turn without making another syscall.

(t *testing.T)

Source from the content-addressed store, hash-verified

80// Noise frames at once and decode each in turn without making another
81// syscall.
82func TestFastPath(t *testing.T) {
83 s1, s2 := memnet.NewConn("noise", 128000)
84 b := &bufferedWriteConn{s1, bufio.NewWriterSize(s1, 10000), false}
85 client, server := pairWithConns(t, b, s2)
86
87 b.manualFlush = true
88
89 sb := sinkReads(server)
90
91 const packets = 10
92 s := "test"
93 for range packets {
94 // Many separate writes, to force separate Noise frames that
95 // all get buffered up and then all sent as a single slice to
96 // the server.
97 if _, err := io.WriteString(client, s); err != nil {
98 t.Fatalf("client write1 failed: %v", err)
99 }
100 }
101 if err := b.w.Flush(); err != nil {
102 t.Fatalf("client flush failed: %v", err)
103 }
104 client.Close()
105
106 want := strings.Repeat(s, packets)
107 if got := sb.String(len(want)); got != want {
108 t.Fatalf("wrong content received: got %q, want %q", got, want)
109 }
110 if err := sb.Error(); err != io.EOF {
111 t.Fatalf("client close wasn't seen by server")
112 }
113}
114
115// Writes things larger than a single Noise frame, to check the
116// chunking on the encoder and decoder.

Callers

nothing calls this directly

Calls 9

NewConnFunction · 0.92
pairWithConnsFunction · 0.85
sinkReadsFunction · 0.85
WriteStringMethod · 0.80
FatalfMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.65
FlushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…