Skip to content

Commit

Permalink
fix(tests): cleanup races & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Apr 21, 2020
1 parent 1cd3631 commit e42842b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 8 additions & 3 deletions impl/graphsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,14 @@ func TestPauseResume(t *testing.T) {

stopPoint := 50
blocksSent := 0
var requestID graphsync.RequestID
requestIDChan := make(chan graphsync.RequestID, 1)
responder.RegisterOutgoingBlockHook(func(p peer.ID, requestData graphsync.RequestData, blockData graphsync.BlockData, hookActions graphsync.OutgoingBlockHookActions) {
_, has := requestData.Extension(td.extensionName)
if has {
requestID = requestData.ID()
select {
case requestIDChan <- requestData.ID():
default:
}
blocksSent++
if blocksSent == stopPoint {
hookActions.PauseResponse()
Expand All @@ -259,7 +262,9 @@ func TestPauseResume(t *testing.T) {
timer := time.NewTimer(100 * time.Millisecond)
testutil.AssertDoesReceiveFirst(t, timer.C, "should pause request", progressChan)

responder.UnpauseResponse(td.host1.ID(), requestID)
requestID := <-requestIDChan
err := responder.UnpauseResponse(td.host1.ID(), requestID)
require.NoError(t, err)

blockChain.VerifyRemainder(ctx, progressChan, stopPoint)
testutil.VerifyEmptyErrors(ctx, t, errChan)
Expand Down
3 changes: 0 additions & 3 deletions requestmanager/requestmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package requestmanager
import (
"context"
"fmt"
"math"

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

const (
// maxPriority is the max priority as defined by the graphsync protocol
maxPriority = graphsync.Priority(math.MaxInt32)
// defaultPriority is the default priority for requests sent by graphsync
defaultPriority = graphsync.Priority(0)
)
Expand Down

0 comments on commit e42842b

Please sign in to comment.