mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user