From 9320b1965ea6fb52bcf4aa5a58226eb38719abf1 Mon Sep 17 00:00:00 2001 From: sukun Date: Fri, 9 Aug 2024 17:38:09 +0530 Subject: [PATCH] Lint fixes --- sctptransport.go | 4 +++- sctptransport_test.go | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sctptransport.go b/sctptransport.go index 7af054f3a25..5ea2df952f7 100644 --- a/sctptransport.go +++ b/sctptransport.go @@ -238,7 +238,9 @@ ACCEPT: }, r, r.api.settingEngine.LoggerFactory.NewLogger("ortc")) if err != nil { // This data channel is invalid. Close it an log an error. - dc.Close() + if err := dc.Close(); err != nil { + r.log.Errorf("Failed to close invalid data channel: %v", err) + } r.log.Errorf("Failed to accept data channel: %v", err) r.onError(err) // We've received a datachannel with invalid configuration. We can still receive other datachannels. diff --git a/sctptransport_test.go b/sctptransport_test.go index cb5371f5ae0..2f97bcd569f 100644 --- a/sctptransport_test.go +++ b/sctptransport_test.go @@ -67,8 +67,10 @@ func TestSCTPTransportOnClose(t *testing.T) { require.NoError(t, err) answerPC.OnDataChannel(func(dc *DataChannel) { - dc.OnMessage(func(msg DataChannelMessage) { - dc.Send([]byte("hello")) + dc.OnMessage(func(_ DataChannelMessage) { + if err := dc.Send([]byte("hello")); err != nil { + t.Error("failed to send message") + } }) }) @@ -91,7 +93,9 @@ func TestSCTPTransportOnClose(t *testing.T) { recvMsg <- struct{}{} }) dc.OnOpen(func() { - dc.Send([]byte("hello")) + if err := dc.Send([]byte("hello")); err != nil { + t.Error("failed to send initial msg", err) + } }) } }) @@ -111,7 +115,8 @@ func TestSCTPTransportOnClose(t *testing.T) { ch <- err }) - offerPC.Close() // This will trigger sctp onclose callback on remote + err = offerPC.Close() // This will trigger sctp onclose callback on remote + require.NoError(t, err) select { case <-ch: