(t *testing.T)
| 182 | } |
| 183 | |
| 184 | func TestFlowControl(t *testing.T) { |
| 185 | cwndSize := 1024 |
| 186 | tw := &testWriter{} |
| 187 | sm := MakeStreamManagerWithSizes(cwndSize, 8*1024) |
| 188 | |
| 189 | largeData := strings.Repeat("x", cwndSize+500) |
| 190 | reader := strings.NewReader(largeData) |
| 191 | |
| 192 | err := sm.AttachReader(reader) |
| 193 | if err != nil { |
| 194 | t.Fatalf("AttachReader failed: %v", err) |
| 195 | } |
| 196 | |
| 197 | _, err = sm.ClientConnected("1", tw, cwndSize, 0) |
| 198 | if err != nil { |
| 199 | t.Fatalf("ClientConnected failed: %v", err) |
| 200 | } |
| 201 | |
| 202 | time.Sleep(100 * time.Millisecond) |
| 203 | |
| 204 | packets := tw.GetPackets() |
| 205 | totalData := 0 |
| 206 | for _, pkt := range packets { |
| 207 | if pkt.Data64 != "" { |
| 208 | decoded, _ := base64.StdEncoding.DecodeString(pkt.Data64) |
| 209 | totalData += len(decoded) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | if totalData > cwndSize { |
| 214 | t.Errorf("Sent %d bytes without ACK, exceeds cwnd size %d", totalData, cwndSize) |
| 215 | } |
| 216 | |
| 217 | sm.RecvAck(wshrpc.CommandStreamAckData{Id: "1", Seq: int64(totalData), RWnd: int64(cwndSize)}) |
| 218 | |
| 219 | time.Sleep(100 * time.Millisecond) |
| 220 | |
| 221 | sm.Close() |
| 222 | } |
| 223 | |
| 224 | func TestSequenceNumbering(t *testing.T) { |
| 225 | tw := &testWriter{} |
nothing calls this directly
no test coverage detected