Skip to content

Commit e42842b

Browse files
committed
fix(tests): cleanup races & lint
1 parent 1cd3631 commit e42842b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

impl/graphsync_test.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,14 @@ func TestPauseResume(t *testing.T) {
239239

240240
stopPoint := 50
241241
blocksSent := 0
242-
var requestID graphsync.RequestID
242+
requestIDChan := make(chan graphsync.RequestID, 1)
243243
responder.RegisterOutgoingBlockHook(func(p peer.ID, requestData graphsync.RequestData, blockData graphsync.BlockData, hookActions graphsync.OutgoingBlockHookActions) {
244244
_, has := requestData.Extension(td.extensionName)
245245
if has {
246-
requestID = requestData.ID()
246+
select {
247+
case requestIDChan <- requestData.ID():
248+
default:
249+
}
247250
blocksSent++
248251
if blocksSent == stopPoint {
249252
hookActions.PauseResponse()
@@ -259,7 +262,9 @@ func TestPauseResume(t *testing.T) {
259262
timer := time.NewTimer(100 * time.Millisecond)
260263
testutil.AssertDoesReceiveFirst(t, timer.C, "should pause request", progressChan)
261264

262-
responder.UnpauseResponse(td.host1.ID(), requestID)
265+
requestID := <-requestIDChan
266+
err := responder.UnpauseResponse(td.host1.ID(), requestID)
267+
require.NoError(t, err)
263268

264269
blockChain.VerifyRemainder(ctx, progressChan, stopPoint)
265270
testutil.VerifyEmptyErrors(ctx, t, errChan)

requestmanager/requestmanager.go

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package requestmanager
33
import (
44
"context"
55
"fmt"
6-
"math"
76

87
blocks "github.com/ipfs/go-block-format"
98
"github.com/ipfs/go-graphsync"
@@ -23,8 +22,6 @@ import (
2322
var log = logging.Logger("graphsync")
2423

2524
const (
26-
// maxPriority is the max priority as defined by the graphsync protocol
27-
maxPriority = graphsync.Priority(math.MaxInt32)
2825
// defaultPriority is the default priority for requests sent by graphsync
2926
defaultPriority = graphsync.Priority(0)
3027
)

0 commit comments

Comments
 (0)