From 5d57e2806c29ff758af2f7e36fa13cc88387c306 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Fri, 10 Sep 2021 00:16:09 +0000 Subject: [PATCH] Fix dial tests --- wsnet/dial.go | 4 +++- wsnet/dial_test.go | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wsnet/dial.go b/wsnet/dial.go index 7f00a128..8b7f4a56 100644 --- a/wsnet/dial.go +++ b/wsnet/dial.go @@ -178,7 +178,9 @@ func Dial(ctx context.Context, conn net.Conn, options *DialOptions) (*Dialer, er err = dialer.negotiate(ctx) if err != nil { - return nil, xerrors.Errorf("negotiate rtc connection: %w", err) + // Return the dialer since we have tests that verify things are closed + // if negotiation fails. + return dialer, xerrors.Errorf("negotiate rtc connection: %w", err) } return dialer, nil diff --git a/wsnet/dial_test.go b/wsnet/dial_test.go index 4aa6f195..d57559c3 100644 --- a/wsnet/dial_test.go +++ b/wsnet/dial_test.go @@ -62,7 +62,15 @@ func TestDial(t *testing.T) { defer cancelFunc() dialer, err := DialWebsocket(ctx, connectAddr, nil, nil) require.True(t, errors.Is(err, context.DeadlineExceeded)) + require.NotNil(t, dialer) require.Error(t, dialer.conn.Close(), "already wrote close") + + // Ensure the rtc peer connection is closed. Setting the config options + // to empty struct does nothing, but it does fail if the rtc peer conn + // is closed. + err = dialer.rtc.SetConfiguration(webrtc.Configuration{}) + require.Error(t, err) + require.ErrorIs(t, err, webrtc.ErrConnectionClosed) }) t.Run("Ping", func(t *testing.T) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy