Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
414ff341
Commit
414ff341
authored
Sep 23, 2014
by
Jeromy
Committed by
Brian Tiger Chow
Sep 23, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change back to using Client method
parent
c45cc8c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
13 deletions
+18
-13
exchange/bitswap/bitswap_test.go
exchange/bitswap/bitswap_test.go
+1
-2
exchange/bitswap/testnet/routing.go
exchange/bitswap/testnet/routing.go
+0
-1
exchange/bitswap/testnet/routing_test.go
exchange/bitswap/testnet/routing_test.go
+7
-9
routing/mock/routing.go
routing/mock/routing.go
+10
-1
No files found.
exchange/bitswap/bitswap_test.go
View file @
414ff341
...
...
@@ -281,8 +281,7 @@ func session(net tn.Network, rs mock.RoutingServer, id peer.ID) instance {
p
:=
&
peer
.
Peer
{
ID
:
id
}
adapter
:=
net
.
Adapter
(
p
)
htc
:=
mock
.
NewMockRouter
(
p
,
nil
)
htc
.
SetRoutingServer
(
rs
)
htc
:=
rs
.
Client
(
p
)
blockstore
:=
bstore
.
NewBlockstore
(
ds
.
NewMapDatastore
())
const
alwaysSendToPeer
=
true
...
...
exchange/bitswap/testnet/routing.go
deleted
100644 → 0
View file @
c45cc8c4
package
bitswap
exchange/bitswap/testnet/routing_test.go
View file @
414ff341
...
...
@@ -43,12 +43,10 @@ func TestSetAndGet(t *testing.T) {
}
func
TestClientFindProviders
(
t
*
testing
.
T
)
{
peer
:=
&
peer
.
Peer
{
ID
:
[]
byte
(
"42"
),
}
peer
:=
&
peer
.
Peer
{
ID
:
[]
byte
(
"42"
)}
rs
:=
mock
.
VirtualRoutingServer
()
client
:=
mock
.
NewMockRouter
(
peer
,
nil
)
client
.
SetRoutingServer
(
rs
)
client
:=
rs
.
Client
(
peer
)
k
:=
u
.
Key
(
"hello"
)
err
:=
client
.
Provide
(
context
.
Background
(),
k
)
if
err
!=
nil
{
...
...
@@ -99,8 +97,9 @@ func TestClientOverMax(t *testing.T) {
}
max
:=
10
client
:=
mock
.
NewMockRouter
(
&
peer
.
Peer
{
ID
:
[]
byte
(
"TODO"
)},
nil
)
client
.
SetRoutingServer
(
rs
)
peer
:=
&
peer
.
Peer
{
ID
:
[]
byte
(
"TODO"
)}
client
:=
rs
.
Client
(
peer
)
providersFromClient
:=
client
.
FindProvidersAsync
(
context
.
Background
(),
k
,
max
)
i
:=
0
for
_
=
range
providersFromClient
{
...
...
@@ -132,8 +131,7 @@ func TestCanceledContext(t *testing.T) {
}()
local
:=
&
peer
.
Peer
{
ID
:
[]
byte
(
"peer id doesn't matter"
)}
client
:=
mock
.
NewMockRouter
(
local
,
nil
)
client
.
SetRoutingServer
(
rs
)
client
:=
rs
.
Client
(
local
)
t
.
Log
(
"warning: max is finite so this test is non-deterministic"
)
t
.
Log
(
"context cancellation could simply take lower priority"
)
...
...
routing/mock/routing.go
View file @
414ff341
...
...
@@ -20,7 +20,7 @@ type MockRouter struct {
peer
*
peer
.
Peer
}
func
NewMockRouter
(
local
*
peer
.
Peer
,
dstore
ds
.
Datastore
)
*
Mock
Rout
er
{
func
NewMockRouter
(
local
*
peer
.
Peer
,
dstore
ds
.
Datastore
)
routing
.
Ipfs
Rout
ing
{
return
&
MockRouter
{
datastore
:
dstore
,
peer
:
local
,
...
...
@@ -84,6 +84,8 @@ type RoutingServer interface {
Announce
(
*
peer
.
Peer
,
u
.
Key
)
error
Providers
(
u
.
Key
)
[]
*
peer
.
Peer
Client
(
p
*
peer
.
Peer
)
routing
.
IpfsRouting
}
func
VirtualRoutingServer
()
RoutingServer
{
...
...
@@ -128,3 +130,10 @@ func (rs *hashTable) Providers(k u.Key) []*peer.Peer {
return
ret
}
func
(
rs
*
hashTable
)
Client
(
p
*
peer
.
Peer
)
routing
.
IpfsRouting
{
return
&
MockRouter
{
peer
:
p
,
hashTable
:
rs
,
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment