Skip to content

Commit

Permalink
fix(lint): fix lint & mod tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Jul 7, 2020
1 parent 77f3f13 commit 39f3e94
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 61 deletions.
17 changes: 0 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ github.com/filecoin-project/go-statestore v0.1.0 h1:t56reH59843TwXHkMcwyuayStBIi
github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI=
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg=
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8=
github.com/filecoin-project/lotus v0.4.1 h1:rg9X3TY7ymT+m6ATIQ7xt8FW2CpCeznwOFfbONPMz84=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI=
Expand Down Expand Up @@ -157,22 +156,6 @@ github.com/ipfs/go-ds-badger v0.0.5/go.mod h1:g5AuuCGmr7efyzQhLL8MzwqcauPojGPUaH
github.com/ipfs/go-ds-badger v0.2.1/go.mod h1:Tx7l3aTph3FMFrRS838dcSJh+jjA7cX9DrGVwx/NOwE=
github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc=
github.com/ipfs/go-ds-leveldb v0.4.1/go.mod h1:jpbku/YqBSsBc1qgME8BkWS4AxzF2cEu1Ii2r79Hh9s=
github.com/ipfs/go-graphsync v0.0.6-0.20200706043744-cce83184947b h1:rGRUbT7+ppNbZFvddfi+jmLWDtmreDxAoEv6+0LZIQw=
github.com/ipfs/go-graphsync v0.0.6-0.20200706043744-cce83184947b/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-graphsync v0.0.6-0.20200706054931-8241d2fe69e2 h1:om8VlCqu93Zf608yAL40dVuKc6dARUJzBZnjGT3YYNQ=
github.com/ipfs/go-graphsync v0.0.6-0.20200706054931-8241d2fe69e2/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-graphsync v0.0.6-0.20200706061258-3fe41bf10543 h1:ysS5XlF36zXYP/wZHEHKwgljg1iwMmm1vo01L7l5mkM=
github.com/ipfs/go-graphsync v0.0.6-0.20200706061258-3fe41bf10543/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-graphsync v0.0.6-0.20200706061822-013825e9d79a h1:deAybS+FtHM0ayzaL5BgmbuSRO7CteK02ZhbjcmCC6c=
github.com/ipfs/go-graphsync v0.0.6-0.20200706061822-013825e9d79a/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-graphsync v0.0.6-0.20200706074121-688c030b0d22 h1:lcEfV5GOX9C5RINCLnjeJ2/l/INuE2TEJPDoPsWHkZ8=
github.com/ipfs/go-graphsync v0.0.6-0.20200706074121-688c030b0d22/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-graphsync v0.0.6-0.20200706080831-f9f3a4f17d34 h1:LuxL7HEzNToE7IoZps8qCYnEhByU1Z+dEUaYEEMr+aU=
github.com/ipfs/go-graphsync v0.0.6-0.20200706080831-f9f3a4f17d34/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-graphsync v0.0.6-0.20200706092719-fc05cbee1dc0 h1:quYeHRwPBkJj29dAchlaX6QYol364aUjUs3mnRv0qOc=
github.com/ipfs/go-graphsync v0.0.6-0.20200706092719-fc05cbee1dc0/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-graphsync v0.0.6-0.20200706175901-e868862698b0 h1:Yb7NolSIm4GEvC2OOFm6Op5je3CxSR5BmAk9pCtSSyY=
github.com/ipfs/go-graphsync v0.0.6-0.20200706175901-e868862698b0/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-graphsync v0.0.6-0.20200706184155-3e432f510b99 h1:mVU4DT7Isk4zh30dl74JO0EAqq7/LGERRKtZH4iG60M=
github.com/ipfs/go-graphsync v0.0.6-0.20200706184155-3e432f510b99/go.mod h1:4htIl/cpQ2vS80RlH9LPaABTp7uYjybMiv3BlytKFh4=
github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08=
Expand Down
3 changes: 3 additions & 0 deletions impl/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func (m *manager) OnRequestReceived(chid datatransfer.ChannelID, request message
return nil, err
}
chst, err := m.channels.GetByID(context.TODO(), chid)
if err != nil {
return nil, err
}
if chst.Status() == datatransfer.ResponderPaused ||
chst.Status() == datatransfer.ResponderFinalizing {
return nil, transport.ErrPause
Expand Down
3 changes: 2 additions & 1 deletion impl/initiating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ func TestDataTransferInitiating(t *testing.T) {
h.storedCounter = storedcounter.New(h.ds, datastore.NewKey("counter"))
dt, err := NewDataTransfer(h.ds, h.network, h.transport, h.storedCounter)
require.NoError(t, err)
dt.Start(ctx)
err = dt.Start(ctx)
require.NoError(t, err)
h.dt = dt
ev := eventVerifier{
expectedEvents: verify.expectedEvents,
Expand Down
73 changes: 36 additions & 37 deletions impl/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func TestRoundTrip(t *testing.T) {

dt1, err := NewDataTransfer(gsData.DtDs1, gsData.DtNet1, tp1, gsData.StoredCounter1)
require.NoError(t, err)
dt1.Start(ctx)

err = dt1.Start(ctx)
require.NoError(t, err)
dt2, err := NewDataTransfer(gsData.DtDs2, gsData.DtNet2, tp2, gsData.StoredCounter2)
require.NoError(t, err)
dt2.Start(ctx)

err = dt2.Start(ctx)
require.NoError(t, err)
finished := make(chan struct{}, 2)
errChan := make(chan struct{}, 2)
opened := make(chan struct{}, 2)
Expand Down Expand Up @@ -181,31 +181,31 @@ func TestSimulatedRetrievalFlow(t *testing.T) {

dt1, err := NewDataTransfer(gsData.DtDs1, gsData.DtNet1, tp1, gsData.StoredCounter1)
require.NoError(t, err)
dt1.Start(ctx)

err = dt1.Start(ctx)
require.NoError(t, err)
dt2, err := NewDataTransfer(gsData.DtDs2, gsData.DtNet2, tp2, gsData.StoredCounter2)
require.NoError(t, err)
dt2.Start(ctx)

err = dt2.Start(ctx)
require.NoError(t, err)
var chid datatransfer.ChannelID
errChan := make(chan struct{}, 2)
clientPausePoint := 0
clientFinished := make(chan struct{}, 1)
finalVoucherResult := testutil.NewFakeDTType()
encodedFVR, err := encoding.Encode(finalVoucherResult)
require.NoError(t, err)
var clientSubscriber datatransfer.Subscriber = func(event datatransfer.Event, channelState datatransfer.ChannelState) {
if event.Code == datatransfer.Accept {
dt2.PauseDataTransferChannel(ctx, chid)
err := dt2.PauseDataTransferChannel(ctx, chid)
require.NoError(t, err)
timer := time.NewTimer(config.unpauseRequestorDelay)
go func() {
select {
case <-ctx.Done():
t.Fatal("should have unpaused")
case <-timer.C:
}
dt2.ResumeDataTransferChannel(ctx, chid)
<-timer.C
err := dt2.ResumeDataTransferChannel(ctx, chid)
require.NoError(t, err)
if config.payForUnseal {
dt2.SendVoucher(ctx, chid, testutil.NewFakeDTType())
err := dt2.SendVoucher(ctx, chid, testutil.NewFakeDTType())
require.NoError(t, err)
}
}()
}
Expand All @@ -217,14 +217,14 @@ func TestSimulatedRetrievalFlow(t *testing.T) {
encodedLVR, err := encoding.Encode(lastVoucherResult)
require.NoError(t, err)
if bytes.Equal(encodedLVR, encodedFVR) {
dt2.SendVoucher(ctx, chid, testutil.NewFakeDTType())
require.NoError(t, dt2.SendVoucher(ctx, chid, testutil.NewFakeDTType()))
}
}

if event.Code == datatransfer.Progress &&
clientPausePoint < len(config.pausePoints) &&
channelState.Received() > config.pausePoints[clientPausePoint] {
dt2.SendVoucher(ctx, chid, testutil.NewFakeDTType())
require.NoError(t, dt2.SendVoucher(ctx, chid, testutil.NewFakeDTType()))
clientPausePoint++
}
if channelState.Status() == datatransfer.Completed {
Expand All @@ -238,12 +238,8 @@ func TestSimulatedRetrievalFlow(t *testing.T) {
if !config.payForUnseal {
timer := time.NewTimer(config.unpauseResponderDelay)
go func() {
select {
case <-ctx.Done():
t.Fatal("should have unpaused")
case <-timer.C:
}
dt1.ResumeDataTransferChannel(ctx, chid)
<-timer.C
require.NoError(t, dt1.ResumeDataTransferChannel(ctx, chid))
}()
}
}
Expand Down Expand Up @@ -313,12 +309,12 @@ func TestPauseAndResume(t *testing.T) {

dt1, err := NewDataTransfer(gsData.DtDs1, gsData.DtNet1, tp1, gsData.StoredCounter1)
require.NoError(t, err)
dt1.Start(ctx)

err = dt1.Start(ctx)
require.NoError(t, err)
dt2, err := NewDataTransfer(gsData.DtDs2, gsData.DtNet2, tp2, gsData.StoredCounter2)
require.NoError(t, err)
dt2.Start(ctx)

err = dt2.Start(ctx)
require.NoError(t, err)
finished := make(chan struct{}, 2)
errChan := make(chan struct{}, 2)
opened := make(chan struct{}, 2)
Expand Down Expand Up @@ -402,16 +398,16 @@ func TestPauseAndResume(t *testing.T) {
case sentIncrement := <-sent:
sentIncrements = append(sentIncrements, sentIncrement)
if len(sentIncrements) == 5 {
dt1.PauseDataTransferChannel(ctx, chid)
require.NoError(t, dt1.PauseDataTransferChannel(ctx, chid))
time.Sleep(100 * time.Millisecond)
dt1.ResumeDataTransferChannel(ctx, chid)
require.NoError(t, dt1.ResumeDataTransferChannel(ctx, chid))
}
case receivedIncrement := <-received:
receivedIncrements = append(receivedIncrements, receivedIncrement)
if len(receivedIncrements) == 10 {
dt2.PauseDataTransferChannel(ctx, chid)
require.NoError(t, dt2.PauseDataTransferChannel(ctx, chid))
time.Sleep(100 * time.Millisecond)
dt2.ResumeDataTransferChannel(ctx, chid)
require.NoError(t, dt2.ResumeDataTransferChannel(ctx, chid))
}
case <-errChan:
t.Fatal("received error on data transfer")
Expand Down Expand Up @@ -443,14 +439,16 @@ func TestDataTransferSubscribing(t *testing.T) {
sv.stubErrorPush()
dt2, err := NewDataTransfer(gsData.DtDs2, gsData.DtNet2, tp2, gsData.StoredCounter2)
require.NoError(t, err)
dt2.Start(ctx)
err = dt2.Start(ctx)
require.NoError(t, err)
require.NoError(t, dt2.RegisterVoucherType(&testutil.FakeDTType{}, sv))
voucher := testutil.FakeDTType{Data: "applesauce"}
baseCid := testutil.GenerateCids(1)[0]

dt1, err := NewDataTransfer(gsData.DtDs1, gsData.DtNet1, tp1, gsData.StoredCounter1)
require.NoError(t, err)
dt1.Start(ctx)
err = dt1.Start(ctx)
require.NoError(t, err)
subscribe1Calls := make(chan struct{}, 1)
subscribe1 := func(event datatransfer.Event, channelState datatransfer.ChannelState) {
if event.Code == datatransfer.Error {
Expand Down Expand Up @@ -583,6 +581,7 @@ func TestRespondingToPushGraphsyncRequests(t *testing.T) {
dt1, err := NewDataTransfer(gsData.DtDs1, gsData.DtNet1, tp1, gsData.StoredCounter1)
require.NoError(t, err)
dt1.Start(ctx)
require.NoError(t, err)
voucherResult := testutil.NewFakeDTType()
err = dt1.RegisterVoucherResultType(voucherResult)
require.NoError(t, err)
Expand Down Expand Up @@ -667,7 +666,7 @@ func TestResponseHookWhenExtensionNotFound(t *testing.T) {
dt1, err := NewDataTransfer(gsData.DtDs1, gsData.DtNet1, tp1, gsData.StoredCounter1)
require.NoError(t, err)
dt1.Start(ctx)

require.NoError(t, err)
t.Run("when it's not our extension, does not error and does not validate", func(t *testing.T) {
//register a hook that validates the request so we don't fail in gs because the request
//never gets processed
Expand Down Expand Up @@ -723,7 +722,7 @@ func TestRespondingToPullGraphsyncRequests(t *testing.T) {
dt1, err := NewDataTransfer(gsData.DtDs2, gsData.DtNet2, tp2, gsData.StoredCounter2)
require.NoError(t, err)
dt1.Start(ctx)

require.NoError(t, err)
require.NoError(t, dt1.RegisterVoucherType(&testutil.FakeDTType{}, sv))

voucher := testutil.NewFakeDTType()
Expand Down Expand Up @@ -753,7 +752,7 @@ func TestRespondingToPullGraphsyncRequests(t *testing.T) {
dt1, err := NewDataTransfer(gsData.DtDs2, gsData.DtNet2, tp2, gsData.StoredCounter2)
require.NoError(t, err)
dt1.Start(ctx)

require.NoError(t, err)
require.NoError(t, dt1.RegisterVoucherType(&testutil.FakeDTType{}, sv))
voucher := testutil.NewFakeDTType()
dtRequest, err := message.NewRequest(id, true, voucher.Type(), voucher, testutil.GenerateCids(1)[0], gsData.AllSelector)
Expand Down
9 changes: 6 additions & 3 deletions impl/responding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ func TestDataTransferResponding(t *testing.T) {
h.network.Delegate.ReceiveRequest(h.ctx, h.peers[1], h.pushRequest)
_, err := h.transport.EventHandler.OnRequestReceived(channelID(h.id, h.peers), h.pauseUpdate)
require.NoError(t, err)
h.dt.PauseDataTransferChannel(h.ctx, channelID(h.id, h.peers))
err = h.dt.PauseDataTransferChannel(h.ctx, channelID(h.id, h.peers))
require.NoError(t, err)
_, err = h.transport.EventHandler.OnRequestReceived(channelID(h.id, h.peers), h.resumeUpdate)
require.EqualError(t, err, transport.ErrPause.Error())
},
Expand Down Expand Up @@ -464,6 +465,7 @@ func TestDataTransferResponding(t *testing.T) {
_, err := h.transport.EventHandler.OnRequestReceived(channelID(h.id, h.peers), h.pullRequest)
require.NoError(t, err)
err = h.transport.EventHandler.OnChannelCompleted(channelID(h.id, h.peers), true)
require.NoError(t, err)
require.Len(t, h.network.SentMessages, 1)
response, ok := h.network.SentMessages[0].Message.(message.DataTransferResponse)
require.True(t, ok)
Expand Down Expand Up @@ -495,7 +497,8 @@ func TestDataTransferResponding(t *testing.T) {
h.storedCounter = storedcounter.New(h.ds, datastore.NewKey("counter"))
dt, err := NewDataTransfer(h.ds, h.network, h.transport, h.storedCounter)
require.NoError(t, err)
dt.Start(ctx)
err = dt.Start(ctx)
require.NoError(t, err)
h.dt = dt
ev := eventVerifier{
expectedEvents: verify.expectedEvents,
Expand All @@ -522,7 +525,7 @@ func TestDataTransferResponding(t *testing.T) {
if verify.configureValidator != nil {
verify.configureValidator(h.sv)
}
err = h.dt.RegisterVoucherType(h.voucher, h.sv)
require.NoError(t, h.dt.RegisterVoucherType(h.voucher, h.sv))
h.srv = newSRV()
if verify.configureRevalidator != nil {
verify.configureRevalidator(h.srv)
Expand Down
7 changes: 4 additions & 3 deletions transport/graphsync/graphsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ func TestManager(t *testing.T) {
action: func(gsData *harness) {
gsData.fgs.LeaveRequestsOpen()
stor, _ := gsData.outgoing.Selector()
gsData.transport.OpenChannel(
_ = gsData.transport.OpenChannel(
gsData.ctx,
gsData.other,
datatransfer.ChannelID{ID: gsData.transferID, Responder: gsData.other, Initiator: gsData.self},
Expand All @@ -643,7 +643,8 @@ func TestManager(t *testing.T) {
assertHasOutgoingMessage(t, requestReceived.Extensions, gsData.outgoing)
completed := make(chan struct{})
go func() {
gsData.transport.PauseChannel(context.Background(), datatransfer.ChannelID{ID: gsData.transferID, Responder: gsData.other, Initiator: gsData.self})
err := gsData.transport.PauseChannel(context.Background(), datatransfer.ChannelID{ID: gsData.transferID, Responder: gsData.other, Initiator: gsData.self})
require.NoError(t, err)
close(completed)
}()
time.Sleep(100 * time.Millisecond)
Expand Down Expand Up @@ -697,7 +698,7 @@ func TestManager(t *testing.T) {
requestUpdatedHookActions: &testutil.FakeRequestUpdatedActions{},
incomingResponseHookActions: &testutil.FakeIncomingResponseHookActions{},
}
transport.SetEventHandler(&data.events)
require.NoError(t, transport.SetEventHandler(&data.events))
if data.action != nil {
data.action(gsData)
}
Expand Down

0 comments on commit 39f3e94

Please sign in to comment.