Skip to content

Commit

Permalink
Move time.Sleep call in turbotunnel test
Browse files Browse the repository at this point in the history
An update the the kcp-go library removes the guarantee that all data
written to a KCP connection will be flushed before the connection is
closed. Moving the sleep call has no impact on the integrity of the
tests, and gives the connection time to flush data before the connection
is closed.

See xtaci/kcp-go#273
  • Loading branch information
cohosh committed Sep 23, 2024
1 parent 99521fb commit 4497d68
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/turbotunnel/queuepacketconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,16 @@ func TestQueuePacketConnWriteToKCP(t *testing.T) {
panic(err)
}

// A sleep after the Write makes buffer reuse more likely, and is needed
// to allow time for flushing all bytes written to the connection before close.
// This is not guaranteed by kcp-go. See https://github.com/xtaci/kcp-go/issues/273
time.Sleep(100 * time.Millisecond)

err = conn.Close()
if err != nil {
panic(err)
}

// A sleep after the Write makes buffer reuse more likely.
time.Sleep(100 * time.Millisecond)

if len(transcript.Transcript) == 0 {
panic("empty transcript")
}
Expand Down

0 comments on commit 4497d68

Please sign in to comment.