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
07fa9eec
Commit
07fa9eec
authored
Dec 25, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hotfix(core/mock) set Network field
parent
95ba056e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
core/mock.go
core/mock.go
+13
-3
No files found.
core/mock.go
View file @
07fa9eec
...
...
@@ -10,12 +10,18 @@ import (
"github.com/jbenet/go-ipfs/exchange/offline"
mdag
"github.com/jbenet/go-ipfs/merkledag"
nsys
"github.com/jbenet/go-ipfs/namesys"
"github.com/jbenet/go-ipfs/net/mock"
path
"github.com/jbenet/go-ipfs/path"
peer
"github.com/jbenet/go-ipfs/peer"
dht
"github.com/jbenet/go-ipfs/routing/dht"
ds2
"github.com/jbenet/go-ipfs/util/datastore2"
"github.com/jbenet/go-ipfs/util/testutil"
)
// TODO this is super sketch. Deprecate and initialize one that shares code
// with the actual core constructor. Lots of fields aren't initialized.
// Additionally, the context group isn't wired up. This is as good as broken.
// NewMockNode constructs an IpfsNode for use in tests.
func
NewMockNode
()
(
*
IpfsNode
,
error
)
{
ctx
:=
context
.
TODO
()
...
...
@@ -37,13 +43,17 @@ func NewMockNode() (*IpfsNode, error) {
nd
.
Peerstore
=
peer
.
NewPeerstore
()
nd
.
Peerstore
.
AddPrivKey
(
p
,
sk
)
nd
.
Peerstore
.
AddPubKey
(
p
,
pk
)
nd
.
Network
,
err
=
mocknet
.
New
(
ctx
)
.
AddPeer
(
sk
,
testutil
.
RandLocalTCPAddress
())
// effectively offline
if
err
!=
nil
{
return
nil
,
err
}
// Temp Datastore
dstore
:=
ds
.
NewMapDatastore
()
nd
.
Datastore
=
ds2
.
CloserWrap
(
syncds
.
MutexWrap
(
dstore
))
// Routing
nd
.
Routing
=
dht
.
NewDHT
(
ctx
,
nd
.
Identity
,
nd
.
Network
,
nd
.
Datastore
)
dht
:=
dht
.
NewDHT
(
ctx
,
nd
.
Identity
,
nd
.
Network
,
nd
.
Datastore
)
nd
.
Routing
=
dht
// Bitswap
bstore
:=
blockstore
.
NewBlockstore
(
nd
.
Datastore
)
...
...
@@ -55,7 +65,7 @@ func NewMockNode() (*IpfsNode, error) {
nd
.
DAG
=
mdag
.
NewDAGService
(
bserv
)
// Namespace resolver
nd
.
Namesys
=
nsys
.
NewNameSystem
(
nd
.
Routing
)
nd
.
Namesys
=
nsys
.
NewNameSystem
(
dht
)
// Path resolver
nd
.
Resolver
=
&
path
.
Resolver
{
DAG
:
nd
.
DAG
}
...
...
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