Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transport protocol update take 2 #333

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions benchmarks/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (
"github.com/ipfs/go-merkledag"
"github.com/ipfs/go-unixfs/importer/balanced"
ihelper "github.com/ipfs/go-unixfs/importer/helpers"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
ipldselector "github.com/ipld/go-ipld-prime/traversal/selector"
"github.com/ipld/go-ipld-prime/traversal/selector/builder"
selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -77,10 +75,6 @@ func p2pStrestTest(ctx context.Context, b *testing.B, numfiles int, df distFunc,
thisCids := df(ctx, b, instances[:1])
allCids = append(allCids, thisCids...)
}
ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any)

allSelector := ssb.ExploreRecursive(ipldselector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()

runtime.GC()
b.ResetTimer()
Expand All @@ -105,7 +99,7 @@ func p2pStrestTest(ctx context.Context, b *testing.B, numfiles int, df distFunc,
timer := time.NewTimer(30 * time.Second)
start := time.Now()
for j := 0; j < numfiles; j++ {
_, err := pusher.Manager.OpenPushDataChannel(ctx, receiver.Peer, testutil.NewTestTypedVoucher(), allCids[j], allSelector)
_, err := pusher.Manager.OpenPushDataChannel(ctx, receiver.Peer, testutil.NewTestTypedVoucher(), allCids[j], selectorparse.CommonSelector_ExploreAllRecursively)
if err != nil {
b.Fatalf("received error on request: %s", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/testinstance/testinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
datatransfer "github.com/filecoin-project/go-data-transfer/v2"
tn "github.com/filecoin-project/go-data-transfer/v2/benchmarks/testnet"
dtimpl "github.com/filecoin-project/go-data-transfer/v2/impl"
dtnet "github.com/filecoin-project/go-data-transfer/v2/network"
"github.com/filecoin-project/go-data-transfer/v2/testutil"
gstransport "github.com/filecoin-project/go-data-transfer/v2/transport/graphsync"
dtnet "github.com/filecoin-project/go-data-transfer/v2/transport/helpers/network"
)

// TempDirGenerator is any interface that can generate temporary directories
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/testnet/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
gsnet "github.com/ipfs/go-graphsync/network"
"github.com/libp2p/go-libp2p-core/peer"

dtnet "github.com/filecoin-project/go-data-transfer/v2/network"
dtnet "github.com/filecoin-project/go-data-transfer/v2/transport/helpers/network"
)

// Network is an interface for generating graphsync network interfaces
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/testnet/peernet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
mockpeernet "github.com/libp2p/go-libp2p/p2p/net/mock"

dtnet "github.com/filecoin-project/go-data-transfer/v2/network"
dtnet "github.com/filecoin-project/go-data-transfer/v2/transport/helpers/network"
)

type peernet struct {
Expand Down
5 changes: 3 additions & 2 deletions impl/initiating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
dss "github.com/ipfs/go-datastore/sync"
"github.com/ipld/go-ipld-prime/datamodel"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -333,7 +334,7 @@ func TestDataTransferInitiating(t *testing.T) {
events: make(chan datatransfer.EventCode, len(verify.expectedEvents)),
}
ev.setup(t, dt)
h.stor = testutil.AllSelector()
h.stor = selectorparse.CommonSelector_ExploreAllRecursively
h.voucher = testutil.NewTestTypedVoucher()
h.voucherResult = testutil.NewTestTypedVoucher()
require.NoError(t, err)
Expand Down Expand Up @@ -580,7 +581,7 @@ func TestDataTransferRestartInitiating(t *testing.T) {
ev.setup(t, dt)

// setup voucher processing
h.stor = testutil.AllSelector()
h.stor = selectorparse.CommonSelector_ExploreAllRecursively
h.voucher = testutil.NewTestTypedVoucher()
require.NoError(t, h.dt.RegisterVoucherType(h.voucher.Type, h.voucherValidator))
h.voucherResult = testutil.NewTestTypedVoucher()
Expand Down
5 changes: 3 additions & 2 deletions impl/responding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/datamodel"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -617,7 +618,7 @@ func TestDataTransferResponding(t *testing.T) {
events: make(chan datatransfer.EventCode, len(verify.expectedEvents)),
}
ev.setup(t, dt)
h.stor = testutil.AllSelector()
h.stor = selectorparse.CommonSelector_ExploreAllRecursively
h.voucher = testutil.NewTestTypedVoucher()
h.baseCid = testutil.GenerateCids(1)[0]
h.id = datatransfer.TransferID(rand.Int31())
Expand Down Expand Up @@ -999,7 +1000,7 @@ func TestDataTransferRestartResponding(t *testing.T) {
events: make(chan datatransfer.EventCode, len(verify.expectedEvents)),
}
ev.setup(t, dt)
h.stor = testutil.AllSelector()
h.stor = selectorparse.CommonSelector_ExploreAllRecursively
h.voucher = testutil.NewTestTypedVoucher()
h.baseCid = testutil.GenerateCids(1)[0]
h.id = datatransfer.TransferID(rand.Int31())
Expand Down
1 change: 0 additions & 1 deletion impl/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,3 @@ func (m *manager) cancelMessage(chid datatransfer.ChannelID) datatransfer.Messag
}
return message.CancelResponse(chid.ID)
}

File renamed without changes.
File renamed without changes.
23 changes: 7 additions & 16 deletions testutil/gstestdata.go → itest/gstestdata.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testutil
package itest

import (
"bytes"
Expand Down Expand Up @@ -29,37 +29,30 @@ import (
"github.com/ipfs/go-unixfs/importer/balanced"
ihelper "github.com/ipfs/go-unixfs/importer/helpers"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/datamodel"
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"
"github.com/libp2p/go-libp2p-core/protocol"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require"

datatransfer "github.com/filecoin-project/go-data-transfer/v2"
"github.com/filecoin-project/go-data-transfer/v2/network"
gstransport "github.com/filecoin-project/go-data-transfer/v2/transport/graphsync"
"github.com/filecoin-project/go-data-transfer/v2/transport/graphsync/extension"
"github.com/filecoin-project/go-data-transfer/v2/transport/helpers/network"
)

var allSelector datamodel.Node

const loremFile = "lorem.txt"
const loremFileTransferBytes = 20439

func init() {
ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any)
allSelector = ssb.ExploreRecursive(selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
}
const loremLargeFile = "lorem_large.txt"
const loremLargeFileTransferBytes = 217452

const unixfsChunkSize uint64 = 1 << 10
const unixfsLinksPerLevel = 1024

var extsForProtocol = map[protocol.ID]graphsync.ExtensionName{
datatransfer.ProtocolDataTransfer1_2: extension.ExtensionDataTransfer1_1,
network.ProtocolDataTransfer1_2: extension.ExtensionDataTransfer1_1,
network.ProtocolFilDataTransfer1_2: extension.ExtensionDataTransfer1_1,
}

// GraphsyncTestingData is a test harness for testing data transfer on top of
Expand All @@ -83,7 +76,6 @@ type GraphsyncTestingData struct {
GsNet2 gsnet.GraphSyncNetwork
DtNet1 network.DataTransferNetwork
DtNet2 network.DataTransferNetwork
AllSelector datamodel.Node
OrigBytes []byte
TempDir1 string
TempDir2 string
Expand Down Expand Up @@ -152,7 +144,6 @@ func NewGraphsyncTestingData(ctx context.Context, t *testing.T, host1Protocols [
require.NoError(t, err)
gsData.TempDir2 = tempdir
// create a selector for the whole UnixFS dag
gsData.AllSelector = allSelector
gsData.host1Protocols = host1Protocols
gsData.host2Protocols = host2Protocols
return gsData
Expand Down
Loading