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

Remove 'FindProviders` from routing mocks #3617

Merged
merged 2 commits into from
Feb 12, 2017
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
14 changes: 9 additions & 5 deletions exchange/reprovide/reprovide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
dssync "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/sync"
pstore "gx/ipfs/QmeXj9VAjmYQZxpmVz7VzccbJrpmr8qkCDSjfVNsPTWTYU/go-libp2p-peerstore"

. "github.com/ipfs/go-ipfs/exchange/reprovide"
)
Expand Down Expand Up @@ -37,16 +38,19 @@ func TestReprovide(t *testing.T) {
t.Fatal(err)
}

provs, err := clB.FindProviders(ctx, blk.Cid())
if err != nil {
t.Fatal(err)
var providers []pstore.PeerInfo
maxProvs := 100

provChan := clB.FindProvidersAsync(ctx, blk.Cid(), maxProvs)
for p := range provChan {
providers = append(providers, p)
}

if len(provs) == 0 {
if len(providers) == 0 {
t.Fatal("Should have gotten a provider")
}

if provs[0].ID != idA.ID() {
if providers[0].ID != idA.ID() {
t.Fatal("Somehow got the wrong peer back as a provider.")
}
}
16 changes: 8 additions & 8 deletions routing/mock/centralized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

delay "github.com/ipfs/go-ipfs/thirdparty/delay"
"github.com/ipfs/go-ipfs/thirdparty/testutil"

u "gx/ipfs/Qmb912gdngC1UWwTkhuW8knyRbcWeu5kqkxBpveLmW8bSr/go-ipfs-util"
cid "gx/ipfs/QmcTcsTvfaeEBRFo1TkFgT8sRmgi1n1LTZpecfVP8fzpGD/go-cid"
pstore "gx/ipfs/QmeXj9VAjmYQZxpmVz7VzccbJrpmr8qkCDSjfVNsPTWTYU/go-libp2p-peerstore"
Expand Down Expand Up @@ -154,20 +153,21 @@ func TestValidAfter(t *testing.T) {
rs.Client(pi).Provide(ctx, key)

var providers []pstore.PeerInfo
providers, err := rs.Client(pi).FindProviders(ctx, key)
if err != nil {
t.Fatal(err)
max := 100
providersChan := rs.Client(pi).FindProvidersAsync(ctx, key, max)
for p := range providersChan {
providers = append(providers, p)
}
if len(providers) > 0 {
t.Fail()
}

conf.ValueVisibility.Set(0)
providers, err = rs.Client(pi).FindProviders(ctx, key)
if err != nil {
t.Fatal(err)
}
providersChan = rs.Client(pi).FindProvidersAsync(ctx, key, max)
t.Log("providers", providers)
for p := range providersChan {
providers = append(providers, p)
}
if len(providers) != 1 {
t.Fail()
}
Expand Down
3 changes: 0 additions & 3 deletions routing/mock/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
routing "gx/ipfs/QmbkGVaN9W6RYJK4Ws5FvMKXKDqdRQ5snhtaa92qP6L8eU/go-libp2p-routing"
cid "gx/ipfs/QmcTcsTvfaeEBRFo1TkFgT8sRmgi1n1LTZpecfVP8fzpGD/go-cid"
pstore "gx/ipfs/QmeXj9VAjmYQZxpmVz7VzccbJrpmr8qkCDSjfVNsPTWTYU/go-libp2p-peerstore"
peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer"
)

Expand All @@ -25,7 +23,6 @@ type Server interface {

// Client implements IpfsRouting
type Client interface {
FindProviders(context.Context, *cid.Cid) ([]pstore.PeerInfo, error)
routing.IpfsRouting
}

Expand Down
4 changes: 0 additions & 4 deletions routing/offline/offline.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ func (c *offlineRouting) GetValues(ctx context.Context, key string, _ int) ([]ro
}, nil
}

func (c *offlineRouting) FindProviders(ctx context.Context, key *cid.Cid) ([]pstore.PeerInfo, error) {
return nil, ErrOffline
}

func (c *offlineRouting) FindPeer(ctx context.Context, pid peer.ID) (pstore.PeerInfo, error) {
return pstore.PeerInfo{}, ErrOffline
}
Expand Down