Skip to content

Commit

Permalink
Upgrade graphsync + ipld-prime (#49)
Browse files Browse the repository at this point in the history
* chore(deps): upgrade graphsync + ipld-prime

* fix(deps): mod tidy
  • Loading branch information
hannahhoward authored Apr 29, 2020
1 parent 813e13a commit 8b34b63
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 81 deletions.
4 changes: 2 additions & 2 deletions channels/channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
datatransfer "github.com/filecoin-project/go-data-transfer"
"github.com/filecoin-project/go-data-transfer/channels"
"github.com/filecoin-project/go-data-transfer/testutil"
ipldfree "github.com/ipld/go-ipld-prime/impl/free"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
"github.com/ipld/go-ipld-prime/traversal/selector/builder"
"github.com/stretchr/testify/require"
)
Expand All @@ -33,7 +33,7 @@ func TestChannels(t *testing.T) {
fv1 := &fakeVoucher{}
fv2 := &fakeVoucher{}
cids := testutil.GenerateCids(2)
selector := builder.NewSelectorSpecBuilder(ipldfree.NodeBuilder()).Matcher().Node()
selector := builder.NewSelectorSpecBuilder(basicnode.Style.Any).Matcher().Node()
peers := testutil.GeneratePeers(4)

t.Run("adding channels", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/ipfs/go-blockservice v0.1.3
github.com/ipfs/go-cid v0.0.5
github.com/ipfs/go-datastore v0.4.4
github.com/ipfs/go-graphsync v0.0.6-0.20200421234158-1c39fe6201ab
github.com/ipfs/go-graphsync v0.0.6-0.20200428204348-97a8cf76a482
github.com/ipfs/go-ipfs-blockstore v0.1.4
github.com/ipfs/go-ipfs-blocksutil v0.0.1
github.com/ipfs/go-ipfs-chunker v0.0.5
Expand All @@ -20,7 +20,7 @@ require (
github.com/ipfs/go-log v1.0.2
github.com/ipfs/go-merkledag v0.3.1
github.com/ipfs/go-unixfs v0.2.4
github.com/ipld/go-ipld-prime v0.0.2-0.20200229094926-eb71617f4aeb
github.com/ipld/go-ipld-prime v0.0.2-0.20200428162820-8b59dc292b8e
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/libp2p/go-libp2p v0.6.0
github.com/libp2p/go-libp2p-core v0.5.0
Expand Down
71 changes: 6 additions & 65 deletions go.sum

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions impl/graphsync/graphsync_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/ipfs/go-graphsync"
gsmsg "github.com/ipfs/go-graphsync/message"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/encoding/dagcbor"
ipldfree "github.com/ipld/go-ipld-prime/impl/free"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
"github.com/ipld/go-ipld-prime/traversal/selector"
"github.com/ipld/go-ipld-prime/traversal/selector/builder"
"github.com/libp2p/go-libp2p-core/peer"
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestDataTransferOneWay(t *testing.T) {
dt := NewGraphSyncDataTransfer(host1, gs, gsData.StoredCounter1)

t.Run("OpenPushDataTransfer", func(t *testing.T) {
ssb := builder.NewSelectorSpecBuilder(ipldfree.NodeBuilder())
ssb := builder.NewSelectorSpecBuilder(basicnode.Style.Any)

// this is the selector for "get the whole DAG"
// TODO: support storage deals with custom payload selectors
Expand Down Expand Up @@ -135,8 +135,10 @@ func TestDataTransferOneWay(t *testing.T) {
require.False(t, receivedRequest.IsCancel())
require.False(t, receivedRequest.IsPull())
reader := bytes.NewReader(receivedRequest.Selector())
receivedSelector, err := dagcbor.Decoder(ipldfree.NodeBuilder(), reader)
nb := basicnode.Style.Any.NewBuilder()
err = dagcbor.Decoder(nb, reader)
require.NoError(t, err)
receivedSelector := nb.Build()
require.Equal(t, receivedSelector, stor)
receivedVoucher := new(fakeDTType)
err = receivedVoucher.FromBytes(receivedRequest.Voucher())
Expand All @@ -146,7 +148,7 @@ func TestDataTransferOneWay(t *testing.T) {
})

t.Run("OpenPullDataTransfer", func(t *testing.T) {
ssb := builder.NewSelectorSpecBuilder(ipldfree.NodeBuilder())
ssb := builder.NewSelectorSpecBuilder(basicnode.Style.Any)

stor := ssb.ExploreRecursive(selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
Expand Down Expand Up @@ -179,8 +181,10 @@ func TestDataTransferOneWay(t *testing.T) {
require.False(t, receivedRequest.IsCancel())
require.True(t, receivedRequest.IsPull())
reader := bytes.NewReader(receivedRequest.Selector())
receivedSelector, err := dagcbor.Decoder(ipldfree.NodeBuilder(), reader)
nb := basicnode.Style.Any.NewBuilder()
err = dagcbor.Decoder(nb, reader)
require.NoError(t, err)
receivedSelector := nb.Build()
require.Equal(t, receivedSelector, stor)
receivedVoucher := new(fakeDTType)
err = receivedVoucher.FromBytes(receivedRequest.Voucher())
Expand Down
2 changes: 1 addition & 1 deletion impl/graphsync/graphsync_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/ipld/go-ipld-prime/encoding/dagcbor"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
11 changes: 8 additions & 3 deletions impl/graphsync/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

logging "github.com/ipfs/go-log"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/encoding/dagcbor"
ipldfree "github.com/ipld/go-ipld-prime/impl/free"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
)

var log = logging.Logger("graphsync-impl")
Expand All @@ -24,5 +24,10 @@ func nodeAsBytes(node ipld.Node) ([]byte, error) {
// nodeFromBytes deserializes an ipld.Node
func nodeFromBytes(from []byte) (ipld.Node, error) {
reader := bytes.NewReader(from)
return dagcbor.Decoder(ipldfree.NodeBuilder(), reader)
nb := basicnode.Style.Any.NewBuilder()
err := dagcbor.Decoder(nb, reader)
if err != nil {
return nil, err
}
return nb.Build(), err
}
4 changes: 2 additions & 2 deletions testutil/gstestdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/ipfs/go-unixfs/importer/balanced"
ihelper "github.com/ipfs/go-unixfs/importer/helpers"
"github.com/ipld/go-ipld-prime"
ipldfree "github.com/ipld/go-ipld-prime/impl/free"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
"github.com/ipld/go-ipld-prime/traversal/selector"
"github.com/ipld/go-ipld-prime/traversal/selector/builder"
"github.com/libp2p/go-libp2p-core/host"
Expand Down Expand Up @@ -140,7 +140,7 @@ func NewGraphsyncTestingData(ctx context.Context, t *testing.T) *GraphsyncTestin
gsData.GsNet2 = gsnet.NewFromLibp2pHost(gsData.Host2)

// create a selector for the whole UnixFS dag
ssb := builder.NewSelectorSpecBuilder(ipldfree.NodeBuilder())
ssb := builder.NewSelectorSpecBuilder(basicnode.Style.Any)

gsData.AllSelector = ssb.ExploreRecursive(selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
Expand Down

0 comments on commit 8b34b63

Please sign in to comment.