Skip to content

Commit

Permalink
Use net.Error cast
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Aug 10, 2023
1 parent cd34a6b commit ed9f4a1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions p2p/test/transport/deadline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package transport_integration

import (
"context"
"net"
"testing"
"time"

Expand All @@ -12,8 +13,7 @@ import (

func TestReadWriteDeadlines(t *testing.T) {
// Send a lot of data so that writes have to flush (can't just buffer it all)
sendBuf := make([]byte, 1<<20)

sendBuf := make([]byte, 10<<20)
for _, tc := range transportsToTest {
t.Run(tc.Name, func(t *testing.T) {
listener := tc.HostGenerator(t, TransportTestCaseOpts{})
Expand Down Expand Up @@ -43,7 +43,7 @@ func TestReadWriteDeadlines(t *testing.T) {
buf := make([]byte, 1)
_, err = s.Read(buf)
require.Error(t, err)
require.Contains(t, err.Error(), "deadline")
require.True(t, err.(net.Error).Timeout())
require.Less(t, time.Since(start), 1*time.Second)
})

Expand All @@ -57,7 +57,7 @@ func TestReadWriteDeadlines(t *testing.T) {
start := time.Now()
_, err = s.Write(sendBuf)
require.Error(t, err)
require.Contains(t, err.Error(), "deadline")
require.True(t, err.(net.Error).Timeout())
require.Less(t, time.Since(start), 1*time.Second)
})

Expand All @@ -80,7 +80,7 @@ func TestReadWriteDeadlines(t *testing.T) {
_, err = s.Write(sendBuf)
}
require.Error(t, err)
require.Contains(t, err.Error(), "deadline")
require.True(t, err.(net.Error).Timeout())
require.Less(t, time.Since(start), 1*time.Second)
})
}
Expand Down

0 comments on commit ed9f4a1

Please sign in to comment.