Commit 15615ccd authored by Brian Tiger Chow's avatar Brian Tiger Chow

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

cc @jbenet
parent d7ff47d8
...@@ -61,7 +61,7 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) { // TODO revisit this ...@@ -61,7 +61,7 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) { // TODO revisit this
defer g.Close() defer g.Close()
block := blocks.NewBlock([]byte("block")) block := blocks.NewBlock([]byte("block"))
pinfo := testutil.RandPeerOrFatal(t) pinfo := testutil.RandIdentityOrFatal(t)
rs.Client(pinfo).Provide(context.Background(), block.Key()) // but not on network rs.Client(pinfo).Provide(context.Background(), block.Key()) // but not on network
solo := g.Next() solo := g.Next()
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
) )
type Network interface { type Network interface {
Adapter(testutil.Peer) bsnet.BitSwapNetwork Adapter(testutil.Identity) bsnet.BitSwapNetwork
HasPeer(peer.ID) bool HasPeer(peer.ID) bool
} }
...@@ -17,11 +17,11 @@ import ( ...@@ -17,11 +17,11 @@ import (
func TestSendRequestToCooperativePeer(t *testing.T) { func TestSendRequestToCooperativePeer(t *testing.T) {
net := VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0)) net := VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0))
recipientPeer := testutil.RandPeerOrFatal(t) recipientPeer := testutil.RandIdentityOrFatal(t)
t.Log("Get two network adapters") t.Log("Get two network adapters")
initiator := net.Adapter(testutil.RandPeerOrFatal(t)) initiator := net.Adapter(testutil.RandIdentityOrFatal(t))
recipient := net.Adapter(recipientPeer) recipient := net.Adapter(recipientPeer)
expectedStr := "response from recipient" expectedStr := "response from recipient"
...@@ -67,8 +67,8 @@ func TestSendRequestToCooperativePeer(t *testing.T) { ...@@ -67,8 +67,8 @@ func TestSendRequestToCooperativePeer(t *testing.T) {
func TestSendMessageAsyncButWaitForResponse(t *testing.T) { func TestSendMessageAsyncButWaitForResponse(t *testing.T) {
net := VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0)) net := VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0))
responderPeer := testutil.RandPeerOrFatal(t) responderPeer := testutil.RandIdentityOrFatal(t)
waiter := net.Adapter(testutil.RandPeerOrFatal(t)) waiter := net.Adapter(testutil.RandIdentityOrFatal(t))
responder := net.Adapter(responderPeer) responder := net.Adapter(responderPeer)
var wg sync.WaitGroup var wg sync.WaitGroup
......
...@@ -19,7 +19,7 @@ func StreamNet(ctx context.Context, net mockpeernet.Mocknet, rs mockrouting.Serv ...@@ -19,7 +19,7 @@ func StreamNet(ctx context.Context, net mockpeernet.Mocknet, rs mockrouting.Serv
return &peernet{net, rs}, nil return &peernet{net, rs}, nil
} }
func (pn *peernet) Adapter(p testutil.Peer) bsnet.BitSwapNetwork { func (pn *peernet) Adapter(p testutil.Identity) bsnet.BitSwapNetwork {
client, err := pn.Mocknet.AddPeer(p.PrivateKey(), p.Address()) client, err := pn.Mocknet.AddPeer(p.PrivateKey(), p.Address())
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
......
...@@ -29,7 +29,7 @@ type network struct { ...@@ -29,7 +29,7 @@ type network struct {
delay delay.D delay delay.D
} }
func (n *network) Adapter(p testutil.Peer) bsnet.BitSwapNetwork { func (n *network) Adapter(p testutil.Identity) bsnet.BitSwapNetwork {
client := &networkClient{ client := &networkClient{
local: p.ID(), local: p.ID(),
network: n, network: n,
......
...@@ -41,7 +41,7 @@ func (g *SessionGenerator) Close() error { ...@@ -41,7 +41,7 @@ func (g *SessionGenerator) Close() error {
func (g *SessionGenerator) Next() Instance { func (g *SessionGenerator) Next() Instance {
g.seq++ g.seq++
p, err := testutil.RandPeer() p, err := testutil.RandIdentity()
if err != nil { if err != nil {
panic("FIXME") // TODO change signature panic("FIXME") // TODO change signature
} }
...@@ -78,7 +78,7 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration { ...@@ -78,7 +78,7 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
// NB: It's easy make mistakes by providing the same peer ID to two different // NB: It's easy make mistakes by providing the same peer ID to two different
// sessions. To safeguard, use the SessionGenerator to generate sessions. It's // sessions. To safeguard, use the SessionGenerator to generate sessions. It's
// just a much better idea. // just a much better idea.
func session(ctx context.Context, net tn.Network, p testutil.Peer) Instance { func session(ctx context.Context, net tn.Network, p testutil.Identity) Instance {
bsdelay := delay.Fixed(0) bsdelay := delay.Fixed(0)
const kWriteCacheElems = 100 const kWriteCacheElems = 100
......
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