make sure RunHandshake has returned before closing, improve MITM tests

This commit is contained in:
Marten Seemann
2022-08-13 16:12:46 +03:00
parent f2fa98c0dd
commit 7fde609eef
4 changed files with 90 additions and 100 deletions

View File

@@ -1,14 +1,11 @@
package self_test
import (
"bytes"
"context"
"fmt"
"io"
mrand "math/rand"
"net"
"runtime/pprof"
"strings"
"sync/atomic"
"time"
@@ -45,12 +42,6 @@ func (c *faultyConn) WriteTo(p []byte, addr net.Addr) (int, error) {
return 0, io.ErrClosedPipe
}
func areHandshakesRunning() bool {
var b bytes.Buffer
pprof.Lookup("goroutine").WriteTo(&b, 1)
return strings.Contains(b.String(), "RunHandshake")
}
var _ = Describe("Timeout tests", func() {
checkTimeoutError := func(err error) {
ExpectWithOffset(1, err).To(MatchError(&quic.IdleTimeoutError{}))
@@ -382,14 +373,6 @@ var _ = Describe("Timeout tests", func() {
Context("faulty packet conns", func() {
const handshakeTimeout = time.Second / 2
BeforeEach(func() {
Expect(areHandshakesRunning()).To(BeFalse())
})
AfterEach(func() {
Expect(areHandshakesRunning()).To(BeFalse())
})
runServer := func(ln quic.Listener) error {
conn, err := ln.Accept(context.Background())
if err != nil {