MCPcopy
hub / github.com/wavetermdev/waveterm / TestTerminalEventOrdering

Function TestTerminalEventOrdering

pkg/jobmanager/streammanager_test.go:263–329  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

261}
262
263func TestTerminalEventOrdering(t *testing.T) {
264 tw := &testWriter{}
265 sm := MakeStreamManager()
266
267 reader := strings.NewReader("data")
268 err := sm.AttachReader(reader)
269 if err != nil {
270 t.Fatalf("AttachReader failed: %v", err)
271 }
272
273 _, err = sm.ClientConnected("1", tw, CwndSize, 0)
274 if err != nil {
275 t.Fatalf("ClientConnected failed: %v", err)
276 }
277
278 time.Sleep(100 * time.Millisecond)
279
280 packets := tw.GetPackets()
281 if len(packets) == 0 {
282 t.Fatal("Expected data packets")
283 }
284
285 hasData := false
286 hasEof := false
287 eofSeq := int64(-1)
288
289 for _, pkt := range packets {
290 if pkt.Data64 != "" {
291 hasData = true
292 }
293 if pkt.Eof {
294 hasEof = true
295 eofSeq = pkt.Seq
296 }
297 }
298
299 if !hasData {
300 t.Error("Expected data packet")
301 }
302
303 if hasEof {
304 t.Error("Should not have EOF before ACK")
305 }
306
307 sm.RecvAck(wshrpc.CommandStreamAckData{Id: "1", Seq: 4, RWnd: CwndSize})
308
309 time.Sleep(50 * time.Millisecond)
310
311 packets = tw.GetPackets()
312 hasEof = false
313 for _, pkt := range packets {
314 if pkt.Eof {
315 hasEof = true
316 eofSeq = pkt.Seq
317 }
318 }
319
320 if !hasEof {

Callers

nothing calls this directly

Calls 7

GetPacketsMethod · 0.95
MakeStreamManagerFunction · 0.85
AttachReaderMethod · 0.80
ClientConnectedMethod · 0.80
RecvAckMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected