Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Aug 9, 2024
1 parent 529b9f2 commit 3d78636
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions sctptransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ ACCEPT:
MaxRetransmits: maxRetransmits,
}, r, r.api.settingEngine.LoggerFactory.NewLogger("ortc"))
if err != nil {
// This data channel is invalid. Close it an log an error.
dc.Close()
// This data channel is invalid. Close it and log an error.
if err := dc.Close(); err != nil {

Check failure on line 241 in sctptransport.go

View workflow job for this annotation

GitHub Actions / lint / Go

shadow: declaration of "err" shadows declaration at line 183 (govet)
r.log.Errorf("Failed to close invalid data channel: %v", err)

Check warning on line 242 in sctptransport.go

View check run for this annotation

Codecov / codecov/patch

sctptransport.go#L241-L242

Added lines #L241 - L242 were not covered by tests
}
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.
Expand Down
13 changes: 9 additions & 4 deletions sctptransport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check failure on line 71 in sctptransport_test.go

View workflow job for this annotation

GitHub Actions / lint / Go

shadow: declaration of "err" shadows declaration at line 66 (govet)
t.Error("failed to send message")
}
})
})

Expand All @@ -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 {

Check failure on line 96 in sctptransport_test.go

View workflow job for this annotation

GitHub Actions / lint / Go

shadow: declaration of "err" shadows declaration at line 66 (govet)
t.Error("failed to send initial msg", err)
}
})
}
})
Expand All @@ -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:
Expand Down

0 comments on commit 3d78636

Please sign in to comment.