quic: deflake the holepunching test (#1484)

This commit is contained in:
Marten Seemann 2022-05-15 19:41:52 +02:00 committed by GitHub
parent f383f4681f
commit 69b6d95a7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -550,7 +550,13 @@ func TestHolePunching(t *testing.T) {
// Make sure the server role (the dial on t2) has progressed far enough.
// If it hasn't created the hole punch map entry, the connection will be accepted as a regular connection,
// which would make this test fail.
time.Sleep(25 * time.Millisecond)
require.Eventually(t, func() bool {
tr := t2.(*transport)
tr.holePunchingMx.Lock()
defer tr.holePunchingMx.Unlock()
return len(tr.holePunching) > 0
}, time.Second, 10*time.Millisecond)
conn1, err := t1.Dial(
network.WithSimultaneousConnect(context.Background(), true, ""),
ln2.Multiaddr(),