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-bitswap
Commits
15615ccd
Commit
15615ccd
authored
Dec 24, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style(testutil) rename testutil.Peer -> testutil.Identity
cc @jbenet
parent
d7ff47d8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
10 deletions
+10
-10
bitswap_test.go
bitswap_test.go
+1
-1
testnet/interface.go
testnet/interface.go
+1
-1
testnet/network_test.go
testnet/network_test.go
+4
-4
testnet/peernet.go
testnet/peernet.go
+1
-1
testnet/virtual.go
testnet/virtual.go
+1
-1
testutils.go
testutils.go
+2
-2
No files found.
bitswap_test.go
View file @
15615ccd
...
...
@@ -61,7 +61,7 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) { // TODO revisit this
defer
g
.
Close
()
block
:=
blocks
.
NewBlock
([]
byte
(
"block"
))
pinfo
:=
testutil
.
Rand
Peer
OrFatal
(
t
)
pinfo
:=
testutil
.
Rand
Identity
OrFatal
(
t
)
rs
.
Client
(
pinfo
)
.
Provide
(
context
.
Background
(),
block
.
Key
())
// but not on network
solo
:=
g
.
Next
()
...
...
testnet/interface.go
View file @
15615ccd
...
...
@@ -7,7 +7,7 @@ import (
)
type
Network
interface
{
Adapter
(
testutil
.
Peer
)
bsnet
.
BitSwapNetwork
Adapter
(
testutil
.
Identity
)
bsnet
.
BitSwapNetwork
HasPeer
(
peer
.
ID
)
bool
}
testnet/network_test.go
View file @
15615ccd
...
...
@@ -17,11 +17,11 @@ import (
func
TestSendRequestToCooperativePeer
(
t
*
testing
.
T
)
{
net
:=
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
0
))
recipientPeer
:=
testutil
.
Rand
Peer
OrFatal
(
t
)
recipientPeer
:=
testutil
.
Rand
Identity
OrFatal
(
t
)
t
.
Log
(
"Get two network adapters"
)
initiator
:=
net
.
Adapter
(
testutil
.
Rand
Peer
OrFatal
(
t
))
initiator
:=
net
.
Adapter
(
testutil
.
Rand
Identity
OrFatal
(
t
))
recipient
:=
net
.
Adapter
(
recipientPeer
)
expectedStr
:=
"response from recipient"
...
...
@@ -67,8 +67,8 @@ func TestSendRequestToCooperativePeer(t *testing.T) {
func
TestSendMessageAsyncButWaitForResponse
(
t
*
testing
.
T
)
{
net
:=
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
0
))
responderPeer
:=
testutil
.
Rand
Peer
OrFatal
(
t
)
waiter
:=
net
.
Adapter
(
testutil
.
Rand
Peer
OrFatal
(
t
))
responderPeer
:=
testutil
.
Rand
Identity
OrFatal
(
t
)
waiter
:=
net
.
Adapter
(
testutil
.
Rand
Identity
OrFatal
(
t
))
responder
:=
net
.
Adapter
(
responderPeer
)
var
wg
sync
.
WaitGroup
...
...
testnet/peernet.go
View file @
15615ccd
...
...
@@ -19,7 +19,7 @@ func StreamNet(ctx context.Context, net mockpeernet.Mocknet, rs mockrouting.Serv
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
())
if
err
!=
nil
{
panic
(
err
.
Error
())
...
...
testnet/virtual.go
View file @
15615ccd
...
...
@@ -29,7 +29,7 @@ type network struct {
delay
delay
.
D
}
func
(
n
*
network
)
Adapter
(
p
testutil
.
Peer
)
bsnet
.
BitSwapNetwork
{
func
(
n
*
network
)
Adapter
(
p
testutil
.
Identity
)
bsnet
.
BitSwapNetwork
{
client
:=
&
networkClient
{
local
:
p
.
ID
(),
network
:
n
,
...
...
testutils.go
View file @
15615ccd
...
...
@@ -41,7 +41,7 @@ func (g *SessionGenerator) Close() error {
func
(
g
*
SessionGenerator
)
Next
()
Instance
{
g
.
seq
++
p
,
err
:=
testutil
.
Rand
Peer
()
p
,
err
:=
testutil
.
Rand
Identity
()
if
err
!=
nil
{
panic
(
"FIXME"
)
// TODO change signature
}
...
...
@@ -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
// sessions. To safeguard, use the SessionGenerator to generate sessions. It's
// 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
)
const
kWriteCacheElems
=
100
...
...
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