(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestConnectedModeBasicFlow(t *testing.T) { |
| 68 | tw := &testWriter{} |
| 69 | sm := MakeStreamManager() |
| 70 | |
| 71 | reader := strings.NewReader("hello") |
| 72 | err := sm.AttachReader(reader) |
| 73 | if err != nil { |
| 74 | t.Fatalf("AttachReader failed: %v", err) |
| 75 | } |
| 76 | |
| 77 | _, err = sm.ClientConnected("1", tw, CwndSize, 0) |
| 78 | if err != nil { |
| 79 | t.Fatalf("ClientConnected failed: %v", err) |
| 80 | } |
| 81 | |
| 82 | time.Sleep(100 * time.Millisecond) |
| 83 | |
| 84 | packets := tw.GetPackets() |
| 85 | if len(packets) == 0 { |
| 86 | t.Fatal("Expected packets after ClientConnected") |
| 87 | } |
| 88 | |
| 89 | // Verify we got the data |
| 90 | allData := "" |
| 91 | for _, pkt := range packets { |
| 92 | if pkt.Data64 != "" { |
| 93 | allData += decodeData(pkt.Data64) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | if allData != "hello" { |
| 98 | t.Errorf("Expected 'hello', got '%s'", allData) |
| 99 | } |
| 100 | |
| 101 | // Send ACK |
| 102 | sm.RecvAck(wshrpc.CommandStreamAckData{Id: "1", Seq: 5, RWnd: CwndSize}) |
| 103 | |
| 104 | time.Sleep(50 * time.Millisecond) |
| 105 | |
| 106 | // Check for EOF packet |
| 107 | packets = tw.GetPackets() |
| 108 | hasEof := false |
| 109 | for _, pkt := range packets { |
| 110 | if pkt.Eof { |
| 111 | hasEof = true |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | if !hasEof { |
| 116 | t.Error("Expected EOF packet after ACKing all data") |
| 117 | } |
| 118 | |
| 119 | sm.Close() |
| 120 | } |
| 121 | |
| 122 | func TestDisconnectedToConnectedTransition(t *testing.T) { |
| 123 | tw := &testWriter{} |
nothing calls this directly
no test coverage detected