Commit 9b3a1679 authored by Brian Tiger Chow's avatar Brian Tiger Chow

style(testutil) rename testutil.Peer -> testutil.Identity

cc @jbenet
parent 536262ca
...@@ -17,7 +17,7 @@ var log = u.Logger("mockrouter") ...@@ -17,7 +17,7 @@ var log = u.Logger("mockrouter")
type client struct { type client struct {
datastore ds.Datastore datastore ds.Datastore
server server server server
peer testutil.Peer peer testutil.Identity
} }
// FIXME(brian): is this method meant to simulate putting a value into the network? // FIXME(brian): is this method meant to simulate putting a value into the network?
......
...@@ -73,11 +73,11 @@ func (rs *s) Providers(k u.Key) []peer.PeerInfo { ...@@ -73,11 +73,11 @@ func (rs *s) Providers(k u.Key) []peer.PeerInfo {
return ret return ret
} }
func (rs *s) Client(p testutil.Peer) Client { func (rs *s) Client(p testutil.Identity) Client {
return rs.ClientWithDatastore(context.Background(), p, ds.NewMapDatastore()) return rs.ClientWithDatastore(context.Background(), p, ds.NewMapDatastore())
} }
func (rs *s) ClientWithDatastore(_ context.Context, p testutil.Peer, datastore ds.Datastore) Client { func (rs *s) ClientWithDatastore(_ context.Context, p testutil.Identity, datastore ds.Datastore) Client {
return &client{ return &client{
peer: p, peer: p,
datastore: ds.NewMapDatastore(), datastore: ds.NewMapDatastore(),
......
...@@ -13,7 +13,7 @@ import ( ...@@ -13,7 +13,7 @@ import (
func TestKeyNotFound(t *testing.T) { func TestKeyNotFound(t *testing.T) {
var pi = testutil.RandPeerOrFatal(t) var pi = testutil.RandIdentityOrFatal(t)
var key = u.Key("mock key") var key = u.Key("mock key")
var ctx = context.Background() var ctx = context.Background()
...@@ -26,7 +26,7 @@ func TestKeyNotFound(t *testing.T) { ...@@ -26,7 +26,7 @@ func TestKeyNotFound(t *testing.T) {
} }
func TestClientFindProviders(t *testing.T) { func TestClientFindProviders(t *testing.T) {
pi := testutil.RandPeerOrFatal(t) pi := testutil.RandIdentityOrFatal(t)
rs := NewServer() rs := NewServer()
client := rs.Client(pi) client := rs.Client(pi)
...@@ -57,7 +57,7 @@ func TestClientOverMax(t *testing.T) { ...@@ -57,7 +57,7 @@ func TestClientOverMax(t *testing.T) {
k := u.Key("hello") k := u.Key("hello")
numProvidersForHelloKey := 100 numProvidersForHelloKey := 100
for i := 0; i < numProvidersForHelloKey; i++ { for i := 0; i < numProvidersForHelloKey; i++ {
pi := testutil.RandPeerOrFatal(t) pi := testutil.RandIdentityOrFatal(t)
err := rs.Client(pi).Provide(context.Background(), k) err := rs.Client(pi).Provide(context.Background(), k)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -65,7 +65,7 @@ func TestClientOverMax(t *testing.T) { ...@@ -65,7 +65,7 @@ func TestClientOverMax(t *testing.T) {
} }
max := 10 max := 10
pi := testutil.RandPeerOrFatal(t) pi := testutil.RandIdentityOrFatal(t)
client := rs.Client(pi) client := rs.Client(pi)
providersFromClient := client.FindProvidersAsync(context.Background(), k, max) providersFromClient := client.FindProvidersAsync(context.Background(), k, max)
...@@ -100,7 +100,7 @@ func TestCanceledContext(t *testing.T) { ...@@ -100,7 +100,7 @@ func TestCanceledContext(t *testing.T) {
default: default:
} }
pi, err := testutil.RandPeer() pi, err := testutil.RandIdentity()
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
...@@ -112,7 +112,7 @@ func TestCanceledContext(t *testing.T) { ...@@ -112,7 +112,7 @@ func TestCanceledContext(t *testing.T) {
} }
}() }()
local := testutil.RandPeerOrFatal(t) local := testutil.RandIdentityOrFatal(t)
client := rs.Client(local) client := rs.Client(local)
t.Log("warning: max is finite so this test is non-deterministic") t.Log("warning: max is finite so this test is non-deterministic")
...@@ -138,7 +138,7 @@ func TestCanceledContext(t *testing.T) { ...@@ -138,7 +138,7 @@ func TestCanceledContext(t *testing.T) {
func TestValidAfter(t *testing.T) { func TestValidAfter(t *testing.T) {
pi := testutil.RandPeerOrFatal(t) pi := testutil.RandIdentityOrFatal(t)
var key = u.Key("mock key") var key = u.Key("mock key")
var ctx = context.Background() var ctx = context.Background()
conf := DelayConfig{ conf := DelayConfig{
......
...@@ -19,11 +19,11 @@ func NewDHTNetwork(mn mocknet.Mocknet) Server { ...@@ -19,11 +19,11 @@ func NewDHTNetwork(mn mocknet.Mocknet) Server {
} }
} }
func (rs *mocknetserver) Client(p testutil.Peer) Client { func (rs *mocknetserver) Client(p testutil.Identity) Client {
return rs.ClientWithDatastore(context.TODO(), p, ds.NewMapDatastore()) return rs.ClientWithDatastore(context.TODO(), p, ds.NewMapDatastore())
} }
func (rs *mocknetserver) ClientWithDatastore(ctx context.Context, p testutil.Peer, ds ds.Datastore) Client { func (rs *mocknetserver) ClientWithDatastore(ctx context.Context, p testutil.Identity, ds ds.Datastore) Client {
// FIXME AddPeer doesn't appear to be idempotent // FIXME AddPeer doesn't appear to be idempotent
......
...@@ -16,8 +16,8 @@ import ( ...@@ -16,8 +16,8 @@ import (
// Server provides mockrouting Clients // Server provides mockrouting Clients
type Server interface { type Server interface {
Client(p testutil.Peer) Client Client(p testutil.Identity) Client
ClientWithDatastore(context.Context, testutil.Peer, ds.Datastore) Client ClientWithDatastore(context.Context, testutil.Identity, ds.Datastore) Client
} }
// Client implements IpfsRouting // Client implements IpfsRouting
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment