test(p2p): feed chunks concurrently in the reassembly test

The test fed all 715 chunks before the first Read; with the cap-1 pump
handoff and a 64-slot fake stream the feeder blocks long before the
reader starts — a deterministic deadlock the earlier "passing" runs
masked (a `go test | tail` pipeline hid the exit code). Feed from a
goroutine.
This commit is contained in:
ginuerzh
2026-09-12 09:39:40 +08:00
parent 2cb1365d46
commit ad702b4cbe
+7 -5
View File
@@ -229,11 +229,13 @@ func TestFramedAssemblesAcrossChunks(t *testing.T) {
t.Fatal(err)
}
b := frame.Bytes()
for len(b) > 0 {
n := min(7, len(b))
fs.recvCh <- &proto.Chunk{Data: append([]byte{}, b[:n]...)}
b = b[n:]
}
go func() {
for len(b) > 0 {
n := min(7, len(b))
fs.recvCh <- &proto.Chunk{Data: append([]byte{}, b[:n]...)}
b = b[n:]
}
}()
buf := make([]byte, 8192)
n, err := c.Read(buf)
if err != nil || !bytes.Equal(buf[:n], payload) {