MCPcopy
hub / github.com/cbeuw/Cloak / TestRecvDataFromRemote_Closing_InOrder

Function TestRecvDataFromRemote_Closing_InOrder

internal/multiplex/session_test.go:209–344  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func TestRecvDataFromRemote_Closing_InOrder(t *testing.T) {
210 testPayload := make([]byte, testPayloadLen)
211 rand.Read(testPayload)
212 obfsBuf := make([]byte, obfsBufLen)
213
214 var sessionKey [32]byte
215 rand.Read(sessionKey[:])
216
217 seshConfig := seshConfigs["ordered"]
218 seshConfig.Obfuscator, _ = MakeObfuscator(EncryptionMethodPlain, sessionKey)
219 sesh := MakeSession(0, seshConfig)
220
221 f1 := &Frame{
222 1,
223 0,
224 closingNothing,
225 testPayload,
226 }
227 // create stream 1
228 n, _ := sesh.obfuscate(f1, obfsBuf, 0)
229 err := sesh.recvDataFromRemote(obfsBuf[:n])
230 if err != nil {
231 t.Fatalf("receiving normal frame for stream 1: %v", err)
232 }
233 sesh.streamsM.Lock()
234 _, ok := sesh.streams[f1.StreamID]
235 sesh.streamsM.Unlock()
236 if !ok {
237 t.Fatal("failed to fetch stream 1 after receiving it")
238 }
239 if sesh.streamCount() != 1 {
240 t.Error("stream count isn't 1")
241 }
242
243 // create stream 2
244 f2 := &Frame{
245 2,
246 0,
247 closingNothing,
248 testPayload,
249 }
250 n, _ = sesh.obfuscate(f2, obfsBuf, 0)
251 err = sesh.recvDataFromRemote(obfsBuf[:n])
252 if err != nil {
253 t.Fatalf("receiving normal frame for stream 2: %v", err)
254 }
255 sesh.streamsM.Lock()
256 s2M, ok := sesh.streams[f2.StreamID]
257 sesh.streamsM.Unlock()
258 if s2M == nil || !ok {
259 t.Fatal("failed to fetch stream 2 after receiving it")
260 }
261 if sesh.streamCount() != 2 {
262 t.Error("stream count isn't 2")
263 }
264
265 // close stream 1
266 f1CloseStream := &Frame{

Callers

nothing calls this directly

Calls 10

MakeObfuscatorFunction · 0.85
obfuscateMethod · 0.80
recvDataFromRemoteMethod · 0.80
streamCountMethod · 0.80
isClosedMethod · 0.80
IsClosedMethod · 0.80
MakeSessionFunction · 0.70
WriteMethod · 0.65
ReadMethod · 0.45
AcceptMethod · 0.45

Tested by

no test coverage detected