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-dms3
Commits
f17ede83
Commit
f17ede83
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(integrationtest) use RoutingOptions in mocknet repo
parent
9e5b3b77
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
20 deletions
+23
-20
test/integration/addcat_test.go
test/integration/addcat_test.go
+2
-2
test/integration/bitswap_wo_routing_test.go
test/integration/bitswap_wo_routing_test.go
+1
-1
test/integration/core.go
test/integration/core.go
+17
-14
test/integration/three_legged_cat_test.go
test/integration/three_legged_cat_test.go
+3
-3
No files found.
test/integration/addcat_test.go
View file @
f17ede83
...
...
@@ -104,12 +104,12 @@ func DirectAddCat(data []byte, conf testutil.LatencyConfig) error {
return
errors
.
New
(
"test initialization error"
)
}
adder
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
peers
[
0
],
mn
.
Host
(
peers
[
0
]),
conf
)))
adder
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
peers
[
0
],
mn
.
Host
(
peers
[
0
]),
conf
,
core
.
DHTOption
)))
if
err
!=
nil
{
return
err
}
defer
adder
.
Close
()
catter
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
peers
[
1
],
mn
.
Host
(
peers
[
1
]),
conf
)))
catter
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
peers
[
1
],
mn
.
Host
(
peers
[
1
]),
conf
,
core
.
DHTOption
)))
if
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
test/integration/bitswap_wo_routing_test.go
View file @
f17ede83
...
...
@@ -34,7 +34,7 @@ func TestBitswapWithoutRouting(t *testing.T) {
var
nodes
[]
*
core
.
IpfsNode
for
_
,
p
:=
range
peers
{
n
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
p
,
mn
.
Host
(
p
),
conf
)))
n
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
p
,
mn
.
Host
(
p
),
conf
,
core
.
DHTOption
)))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
test/integration/core.go
View file @
f17ede83
...
...
@@ -4,6 +4,7 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
syncds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
ds2
"github.com/jbenet/go-ipfs/util/datastore2"
blockstore
"github.com/jbenet/go-ipfs/blocks/blockstore"
core
"github.com/jbenet/go-ipfs/core"
bitswap
"github.com/jbenet/go-ipfs/exchange/bitswap"
...
...
@@ -11,16 +12,14 @@ import (
host
"github.com/jbenet/go-ipfs/p2p/host"
peer
"github.com/jbenet/go-ipfs/p2p/peer"
"github.com/jbenet/go-ipfs/repo"
dht
"github.com/jbenet/go-ipfs/routing/dht"
delay
"github.com/jbenet/go-ipfs/thirdparty/delay"
eventlog
"github.com/jbenet/go-ipfs/thirdparty/eventlog"
ds2
"github.com/jbenet/go-ipfs/util/datastore2"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
var
log
=
eventlog
.
Logger
(
"epictest"
)
func
MocknetTestRepo
(
p
peer
.
ID
,
h
host
.
Host
,
conf
testutil
.
LatencyConfig
)
core
.
ConfigOption
{
func
MocknetTestRepo
(
p
peer
.
ID
,
h
host
.
Host
,
conf
testutil
.
LatencyConfig
,
routing
core
.
RoutingOption
)
core
.
ConfigOption
{
return
func
(
ctx
context
.
Context
)
(
*
core
.
IpfsNode
,
error
)
{
const
kWriteCacheElems
=
100
const
alwaysSendToPeer
=
true
...
...
@@ -30,22 +29,26 @@ func MocknetTestRepo(p peer.ID, h host.Host, conf testutil.LatencyConfig) core.C
}
ds
:=
r
.
Datastore
()
log
.
Debugf
(
"MocknetTestRepo: %s %s %s"
,
p
,
h
.
ID
(),
h
)
dhtt
:=
dht
.
NewDHT
(
ctx
,
h
,
ds
)
n
:=
&
core
.
IpfsNode
{
Peerstore
:
h
.
Peerstore
(),
Repo
:
r
,
PeerHost
:
h
,
Identity
:
p
,
}
dhtt
,
err
:=
routing
(
ctx
,
n
)
if
err
!=
nil
{
return
nil
,
err
}
bsn
:=
bsnet
.
NewFromIpfsHost
(
h
,
dhtt
)
bstore
,
err
:=
blockstore
.
WriteCached
(
blockstore
.
NewBlockstore
(
ds
),
kWriteCacheElems
)
if
err
!=
nil
{
return
nil
,
err
}
exch
:=
bitswap
.
New
(
ctx
,
p
,
bsn
,
bstore
,
alwaysSendToPeer
)
return
&
core
.
IpfsNode
{
Peerstore
:
h
.
Peerstore
(),
Blockstore
:
bstore
,
Exchange
:
exch
,
Repo
:
r
,
PeerHost
:
h
,
Routing
:
dhtt
,
Identity
:
p
,
},
nil
n
.
Blockstore
=
bstore
n
.
Exchange
=
exch
n
.
Routing
=
dhtt
return
n
,
nil
}
}
This diff is collapsed.
Click to expand it.
test/integration/three_legged_cat_test.go
View file @
f17ede83
...
...
@@ -80,17 +80,17 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
if
len
(
peers
)
<
numPeers
{
return
errors
.
New
(
"test initialization error"
)
}
bootstrap
,
err
:=
core
.
NewIPFSNode
(
ctx
,
MocknetTestRepo
(
peers
[
2
],
mn
.
Host
(
peers
[
2
]),
conf
))
bootstrap
,
err
:=
core
.
NewIPFSNode
(
ctx
,
MocknetTestRepo
(
peers
[
2
],
mn
.
Host
(
peers
[
2
]),
conf
,
core
.
DHTOption
))
if
err
!=
nil
{
return
err
}
defer
bootstrap
.
Close
()
adder
,
err
:=
core
.
NewIPFSNode
(
ctx
,
MocknetTestRepo
(
peers
[
0
],
mn
.
Host
(
peers
[
0
]),
conf
))
adder
,
err
:=
core
.
NewIPFSNode
(
ctx
,
MocknetTestRepo
(
peers
[
0
],
mn
.
Host
(
peers
[
0
]),
conf
,
core
.
DHTOption
))
if
err
!=
nil
{
return
err
}
defer
adder
.
Close
()
catter
,
err
:=
core
.
NewIPFSNode
(
ctx
,
MocknetTestRepo
(
peers
[
1
],
mn
.
Host
(
peers
[
1
]),
conf
))
catter
,
err
:=
core
.
NewIPFSNode
(
ctx
,
MocknetTestRepo
(
peers
[
1
],
mn
.
Host
(
peers
[
1
]),
conf
,
core
.
DHTOption
))
if
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
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