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
94147479
Commit
94147479
authored
Dec 23, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use testutil peer in sess
parent
4c6a6012
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
testutils.go
testutils.go
+10
-5
No files found.
testutils.go
View file @
94147479
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
peer
"github.com/jbenet/go-ipfs/peer"
peer
"github.com/jbenet/go-ipfs/peer"
datastore2
"github.com/jbenet/go-ipfs/util/datastore2"
datastore2
"github.com/jbenet/go-ipfs/util/datastore2"
delay
"github.com/jbenet/go-ipfs/util/delay"
delay
"github.com/jbenet/go-ipfs/util/delay"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
)
func
NewSessionGenerator
(
func
NewSessionGenerator
(
...
@@ -40,7 +41,11 @@ func (g *SessionGenerator) Close() error {
...
@@ -40,7 +41,11 @@ func (g *SessionGenerator) Close() error {
func
(
g
*
SessionGenerator
)
Next
()
Instance
{
func
(
g
*
SessionGenerator
)
Next
()
Instance
{
g
.
seq
++
g
.
seq
++
return
session
(
g
.
ctx
,
g
.
net
,
peer
.
ID
(
g
.
seq
))
p
,
err
:=
testutil
.
RandPeer
()
if
err
!=
nil
{
panic
(
"FIXME"
)
// TODO change signature
}
return
session
(
g
.
ctx
,
g
.
net
,
p
)
}
}
func
(
g
*
SessionGenerator
)
Instances
(
n
int
)
[]
Instance
{
func
(
g
*
SessionGenerator
)
Instances
(
n
int
)
[]
Instance
{
...
@@ -73,9 +78,9 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
...
@@ -73,9 +78,9 @@ 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
peer
.
ID
)
Instance
{
func
session
(
ctx
context
.
Context
,
net
tn
.
Network
,
p
testutil
.
Peer
)
Instance
{
adapter
:=
net
.
Adapter
(
p
)
adapter
:=
net
.
Adapter
(
p
.
ID
()
)
bsdelay
:=
delay
.
Fixed
(
0
)
bsdelay
:=
delay
.
Fixed
(
0
)
const
kWriteCacheElems
=
100
const
kWriteCacheElems
=
100
...
@@ -87,10 +92,10 @@ func session(ctx context.Context, net tn.Network, p peer.ID) Instance {
...
@@ -87,10 +92,10 @@ func session(ctx context.Context, net tn.Network, p peer.ID) Instance {
const
alwaysSendToPeer
=
true
const
alwaysSendToPeer
=
true
bs
:=
New
(
ctx
,
p
,
adapter
,
bstore
,
alwaysSendToPeer
)
bs
:=
New
(
ctx
,
p
.
ID
()
,
adapter
,
bstore
,
alwaysSendToPeer
)
return
Instance
{
return
Instance
{
Peer
:
p
,
Peer
:
p
.
ID
()
,
Exchange
:
bs
,
Exchange
:
bs
,
blockstore
:
bstore
,
blockstore
:
bstore
,
blockstoreDelay
:
bsdelay
,
blockstoreDelay
:
bsdelay
,
...
...
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