Skip to content

Commit bd3f4b4

Browse files
authored
Switch To Circle CI (#57)
* ci(circle): switch to circle Use configs from bitswap * fix(deps): update and standardize * fix(lint): fix lint errors * fix(tests): relax timings for context cancels Since we are not relying on context cancellation as anything but a test failsafe, relax timings significantly for slower machines * fix(test): fix minor test error * fix(tests): minor timing fix * fix(lint): fix lint errors * fix(tests): relax timings for context cancels Since we are not relying on context cancellation as anything but a test failsafe, relax timings
1 parent 94cf785 commit bd3f4b4

File tree

20 files changed

+223
-120
lines changed

20 files changed

+223
-120
lines changed

.circleci/config.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2.1
2+
orbs:
3+
ci-go: ipfs/[email protected]
4+
5+
workflows:
6+
version: 2
7+
test:
8+
jobs:
9+
- ci-go/build
10+
- ci-go/lint
11+
- ci-go/test
12+
- ci-go/test:
13+
race: true
14+
name: "ci-go/test/race"
15+
- ci-go/benchmark:
16+
tolerance: 50
17+
requires:
18+
- ci-go/test

.travis.yml

-31
This file was deleted.

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
44
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
5-
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
6-
[![Coverage Status](https://codecov.io/gh/ipfs/go-graphsync/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-graphsync)
7-
[![Travis CI](https://travis-ci.com/ipfs/go-graphsync.svg?branch=master)](https://travis-ci.com/ipfs/go-graphsync)
5+
[![Matrix](https://img.shields.io/badge/matrix-%23ipfs%3Amatrix.org-blue.svg?style=flat-square)](https://matrix.to/#/#ipfs:matrix.org)
6+
[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
7+
[![Discord](https://img.shields.io/discord/475789330380488707?color=blueviolet&label=discord&style=flat-square)](https://discord.gg/24fmuwR)
8+
[![Coverage Status](https://codecov.io/gh/ipfs/go-graphsync/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-graphsync/branch/master)
9+
[![Build Status](https://circleci.com/gh/ipfs/go-bitswap.svg?style=svg)](https://circleci.com/gh/ipfs/go-graphsync)
810

911
> An implementation of the [graphsync protocol](https://github.com/ipld/specs/blob/master/block-layer/graphsync/graphsync.md) in go!
1012

go.mod

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ go 1.12
55
require (
66
github.com/gogo/protobuf v1.3.1
77
github.com/ipfs/go-block-format v0.0.2
8-
github.com/ipfs/go-blockservice v0.1.3-0.20190908200855-f22eea50656c
9-
github.com/ipfs/go-cid v0.0.4-0.20191112011718-79e75dffeb10
10-
github.com/ipfs/go-datastore v0.1.0
11-
github.com/ipfs/go-ipfs-blockstore v0.1.0
8+
github.com/ipfs/go-blockservice v0.1.3
9+
github.com/ipfs/go-cid v0.0.5
10+
github.com/ipfs/go-datastore v0.4.4
11+
github.com/ipfs/go-ipfs-blockstore v0.1.4
1212
github.com/ipfs/go-ipfs-blocksutil v0.0.1
1313
github.com/ipfs/go-ipfs-chunker v0.0.1
1414
github.com/ipfs/go-ipfs-exchange-offline v0.0.1
1515
github.com/ipfs/go-ipfs-files v0.0.4
1616
github.com/ipfs/go-ipfs-util v0.0.1
1717
github.com/ipfs/go-ipld-format v0.0.2
18-
github.com/ipfs/go-log v1.0.0
18+
github.com/ipfs/go-log v1.0.2
1919
github.com/ipfs/go-merkledag v0.2.4
2020
github.com/ipfs/go-peertaskqueue v0.2.0
2121
github.com/ipfs/go-unixfs v0.2.2-0.20190827150610-868af2e9e5cb
2222
github.com/ipld/go-ipld-prime v0.0.2-0.20191108012745-28a82f04c785
2323
github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5
2424
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
25-
github.com/libp2p/go-libp2p v0.3.0
26-
github.com/libp2p/go-libp2p-core v0.2.4
27-
github.com/multiformats/go-multiaddr v0.1.1
28-
github.com/multiformats/go-multihash v0.0.9
25+
github.com/libp2p/go-libp2p v0.6.0
26+
github.com/libp2p/go-libp2p-core v0.5.0
27+
github.com/multiformats/go-multiaddr v0.2.1
28+
github.com/multiformats/go-multihash v0.0.13
2929
)

go.sum

+132-24
Large diffs are not rendered by default.

impl/graphsync_test.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ func TestSendResponseToIncomingRequest(t *testing.T) {
134134
message := gsmsg.New()
135135
message.AddRequest(gsmsg.NewRequest(requestID, blockChain.TipLink.(cidlink.Link).Cid, blockChain.Selector(), graphsync.Priority(math.MaxInt32), td.extension))
136136
// send request across network
137-
td.gsnet1.SendMessage(ctx, td.host2.ID(), message)
137+
err = td.gsnet1.SendMessage(ctx, td.host2.ID(), message)
138+
if err != nil {
139+
t.Fatal("Unable to send message")
140+
}
138141
// read the values sent back to requestor
139142
var received gsmsg.GraphSyncMessage
140143
var receivedBlocks []blocks.Block
@@ -427,13 +430,17 @@ func TestUnixFSFetch(t *testing.T) {
427430
requestor := New(ctx, td.gsnet1, loader1, storer1)
428431
responder := New(ctx, td.gsnet2, loader2, storer2)
429432
extensionName := graphsync.ExtensionName("Free for all")
430-
responder.RegisterRequestReceivedHook(func(p peer.ID, requestData graphsync.RequestData, hookActions graphsync.RequestReceivedHookActions) {
433+
err = responder.RegisterRequestReceivedHook(func(p peer.ID, requestData graphsync.RequestData, hookActions graphsync.RequestReceivedHookActions) {
431434
hookActions.ValidateRequest()
432435
hookActions.SendExtensionData(graphsync.ExtensionData{
433436
Name: extensionName,
434437
Data: nil,
435438
})
436439
})
440+
if err != nil {
441+
t.Fatal("unable to register extension")
442+
}
443+
437444
// make a go-ipld-prime link for the root UnixFS node
438445
clink := cidlink.Link{Cid: nd.Cid()}
439446

messagequeue/messagequeue.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (mq *MessageQueue) runQueue() {
102102
return
103103
case <-mq.ctx.Done():
104104
if mq.sender != nil {
105-
mq.sender.Reset()
105+
_ = mq.sender.Reset()
106106
}
107107
return
108108
}
@@ -185,7 +185,7 @@ func (mq *MessageQueue) attemptSendAndRecovery(message gsmsg.GraphSyncMessage) b
185185
}
186186

187187
log.Infof("graphsync send error: %s", err)
188-
mq.sender.Reset()
188+
_ = mq.sender.Reset()
189189
mq.sender = nil
190190

191191
select {
@@ -195,7 +195,7 @@ func (mq *MessageQueue) attemptSendAndRecovery(message gsmsg.GraphSyncMessage) b
195195
return true
196196
case <-time.After(time.Millisecond * 100):
197197
// wait 100ms in case disconnect notifications are still propogating
198-
log.Warning("SendMsg errored but neither 'done' nor context.Done() were set")
198+
log.Warn("SendMsg errored but neither 'done' nor context.Done() were set")
199199
}
200200

201201
err = mq.initializeSender()

network/libp2p_impl.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func msgToStream(ctx context.Context, s network.Stream, msg gsmsg.GraphSyncMessa
6262
deadline = dl
6363
}
6464
if err := s.SetWriteDeadline(deadline); err != nil {
65-
log.Warningf("error setting deadline: %s", err)
65+
log.Warnf("error setting deadline: %s", err)
6666
}
6767

6868
switch s.Protocol() {
@@ -76,7 +76,7 @@ func msgToStream(ctx context.Context, s network.Stream, msg gsmsg.GraphSyncMessa
7676
}
7777

7878
if err := s.SetWriteDeadline(time.Time{}); err != nil {
79-
log.Warningf("error resetting deadline: %s", err)
79+
log.Warnf("error resetting deadline: %s", err)
8080
}
8181
return nil
8282
}
@@ -105,11 +105,12 @@ func (gsnet *libp2pGraphSyncNetwork) SendMessage(
105105
}
106106

107107
if err = msgToStream(ctx, s, outgoing); err != nil {
108-
s.Reset()
108+
_ = s.Reset()
109109
return err
110110
}
111111

112112
// TODO(https://github.com/libp2p/go-libp2p-net/issues/28): Avoid this goroutine.
113+
//nolint
113114
go helpers.AwaitEOF(s)
114115
return s.Close()
115116

@@ -130,7 +131,7 @@ func (gsnet *libp2pGraphSyncNetwork) handleNewStream(s network.Stream) {
130131
defer s.Close()
131132

132133
if gsnet.receiver == nil {
133-
s.Reset()
134+
_ = s.Reset()
134135
return
135136
}
136137

@@ -139,7 +140,7 @@ func (gsnet *libp2pGraphSyncNetwork) handleNewStream(s network.Stream) {
139140
received, err := gsmsg.FromPBReader(reader)
140141
if err != nil {
141142
if err != io.EOF {
142-
s.Reset()
143+
_ = s.Reset()
143144
go gsnet.receiver.ReceiveError(err)
144145
log.Debugf("graphsync net handleNewStream from %s error: %s", s.Conn().RemotePeer(), err)
145146
}

network/libp2p_impl_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ func TestMessageSendAndReceive(t *testing.T) {
9595
t.Fatal("Unable to connect peers")
9696
}
9797

98-
gsnet1.SendMessage(ctx, host2.ID(), sent)
98+
err = gsnet1.SendMessage(ctx, host2.ID(), sent)
99+
if err != nil {
100+
t.Fatal("Unable to send message")
101+
}
99102

100103
select {
101104
case <-ctx.Done():

requestmanager/asyncloader/asyncloader_test.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ import (
1818

1919
func TestAsyncLoadInitialLoadSucceedsLocallyPresent(t *testing.T) {
2020
ctx := context.Background()
21-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
21+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
2222
defer cancel()
2323
callCount := 0
2424
blockStore := make(map[ipld.Link][]byte)
2525
loader, storer := testutil.NewTestStore(blockStore)
2626
block := testutil.GenerateBlocksOfSize(1, 100)[0]
2727
writer, commit, err := storer(ipld.LinkContext{})
28+
if err != nil {
29+
t.Fatal("should be able to store")
30+
}
2831
_, err = writer.Write(block.RawData())
2932
if err != nil {
3033
t.Fatal("could not seed block store")
@@ -65,7 +68,7 @@ func TestAsyncLoadInitialLoadSucceedsLocallyPresent(t *testing.T) {
6568

6669
func TestAsyncLoadInitialLoadSucceedsResponsePresent(t *testing.T) {
6770
ctx := context.Background()
68-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
71+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
6972
defer cancel()
7073
callCount := 0
7174
blockStore := make(map[ipld.Link][]byte)
@@ -118,7 +121,7 @@ func TestAsyncLoadInitialLoadSucceedsResponsePresent(t *testing.T) {
118121

119122
func TestAsyncLoadInitialLoadFails(t *testing.T) {
120123
ctx := context.Background()
121-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
124+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
122125
defer cancel()
123126
callCount := 0
124127
blockStore := make(map[ipld.Link][]byte)
@@ -166,7 +169,7 @@ func TestAsyncLoadInitialLoadFails(t *testing.T) {
166169

167170
func TestAsyncLoadInitialLoadIndeterminateWhenRequestNotInProgress(t *testing.T) {
168171
ctx := context.Background()
169-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
172+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
170173
defer cancel()
171174
callCount := 0
172175
blockStore := make(map[ipld.Link][]byte)
@@ -203,7 +206,7 @@ func TestAsyncLoadInitialLoadIndeterminateWhenRequestNotInProgress(t *testing.T)
203206

204207
func TestAsyncLoadInitialLoadIndeterminateThenSucceeds(t *testing.T) {
205208
ctx := context.Background()
206-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
209+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
207210
defer cancel()
208211
callCount := 0
209212
blockStore := make(map[ipld.Link][]byte)
@@ -267,7 +270,7 @@ func TestAsyncLoadInitialLoadIndeterminateThenSucceeds(t *testing.T) {
267270

268271
func TestAsyncLoadInitialLoadIndeterminateThenFails(t *testing.T) {
269272
ctx := context.Background()
270-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
273+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
271274
defer cancel()
272275
callCount := 0
273276
blockStore := make(map[ipld.Link][]byte)
@@ -324,7 +327,7 @@ func TestAsyncLoadInitialLoadIndeterminateThenFails(t *testing.T) {
324327

325328
func TestAsyncLoadInitialLoadIndeterminateThenRequestFinishes(t *testing.T) {
326329
ctx := context.Background()
327-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
330+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
328331
defer cancel()
329332
callCount := 0
330333
blockStore := make(map[ipld.Link][]byte)
@@ -373,7 +376,7 @@ func TestAsyncLoadInitialLoadIndeterminateThenRequestFinishes(t *testing.T) {
373376

374377
func TestAsyncLoadTwiceLoadsLocallySecondTime(t *testing.T) {
375378
ctx := context.Background()
376-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
379+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
377380
defer cancel()
378381
callCount := 0
379382
blockStore := make(map[ipld.Link][]byte)

requestmanager/asyncloader/loadattemptqueue/loadattemptqueue_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
func TestAsyncLoadInitialLoadSucceeds(t *testing.T) {
1717
ctx := context.Background()
18-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
18+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
1919
defer cancel()
2020
callCount := 0
2121
loadAttempter := func(graphsync.RequestID, ipld.Link) ([]byte, error) {
@@ -50,7 +50,7 @@ func TestAsyncLoadInitialLoadSucceeds(t *testing.T) {
5050

5151
func TestAsyncLoadInitialLoadFails(t *testing.T) {
5252
ctx := context.Background()
53-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
53+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
5454
defer cancel()
5555
callCount := 0
5656
loadAttempter := func(graphsync.RequestID, ipld.Link) ([]byte, error) {
@@ -85,7 +85,7 @@ func TestAsyncLoadInitialLoadFails(t *testing.T) {
8585

8686
func TestAsyncLoadInitialLoadIndeterminateRetryFalse(t *testing.T) {
8787
ctx := context.Background()
88-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
88+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
8989
defer cancel()
9090
callCount := 0
9191
loadAttempter := func(graphsync.RequestID, ipld.Link) ([]byte, error) {
@@ -125,7 +125,7 @@ func TestAsyncLoadInitialLoadIndeterminateRetryFalse(t *testing.T) {
125125

126126
func TestAsyncLoadInitialLoadIndeterminateRetryTrueThenRetriedSuccess(t *testing.T) {
127127
ctx := context.Background()
128-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
128+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
129129
defer cancel()
130130
callCount := 0
131131
called := make(chan struct{}, 2)
@@ -174,7 +174,7 @@ func TestAsyncLoadInitialLoadIndeterminateRetryTrueThenRetriedSuccess(t *testing
174174

175175
func TestAsyncLoadInitialLoadIndeterminateThenRequestFinishes(t *testing.T) {
176176
ctx := context.Background()
177-
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
177+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
178178
defer cancel()
179179
callCount := 0
180180
called := make(chan struct{}, 2)

requestmanager/asyncloader/responsecache/responsecache.go

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import (
1616

1717
var log = logging.Logger("graphsync")
1818

19-
type responseCacheMessage interface {
20-
handle(rc *ResponseCache)
21-
}
22-
2319
// UnverifiedBlockStore is an interface for storing blocks
2420
// as they come in and removing them as they are verified
2521
type UnverifiedBlockStore interface {

requestmanager/asyncloader/unverifiedblockstore/unverifiedblockstore_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,14 @@ func TestVerifyBlockPresent(t *testing.T) {
3636
t.Fatal("block should be returned on verification if added")
3737
}
3838
reader, err = loader(cidlink.Link{Cid: block.Cid()}, ipld.LinkContext{})
39+
if err != nil {
40+
t.Fatal("error loading block")
41+
}
3942
var buffer bytes.Buffer
40-
io.Copy(&buffer, reader)
43+
_, err = io.Copy(&buffer, reader)
44+
if err != nil {
45+
t.Fatal("error occurred copying data")
46+
}
4147
if !reflect.DeepEqual(buffer.Bytes(), block.RawData()) || err != nil {
4248
t.Fatal("block should be stored after verification and therefore loadable")
4349
}

0 commit comments

Comments
 (0)