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
5423a008
Commit
5423a008
authored
Oct 04, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create test node and make first ipns test pass
parent
0c7ff7b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
1 deletion
+57
-1
fuse/ipns/ipns_test.go
fuse/ipns/ipns_test.go
+8
-1
util/testutil/node.go
util/testutil/node.go
+49
-0
No files found.
fuse/ipns/ipns_test.go
View file @
5423a008
...
...
@@ -6,6 +6,7 @@ import (
"testing"
fstest
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs/fstestutil"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
func
randBytes
(
size
int
)
[]
byte
{
...
...
@@ -15,7 +16,12 @@ func randBytes(size int) []byte {
}
func
TestIpnsBasicIO
(
t
*
testing
.
T
)
{
fs
,
err
:=
NewIpns
(
nil
,
""
)
localnode
,
err
:=
testutil
.
NewMockNode
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fs
,
err
:=
NewIpns
(
localnode
,
""
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -59,4 +65,5 @@ func TestIpnsBasicIO(t *testing.T) {
}
fi
.
Close
()
}
util/testutil/node.go
0 → 100644
View file @
5423a008
package
testutil
import
(
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
syncds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go/sync"
bs
"github.com/jbenet/go-ipfs/blockservice"
core
"github.com/jbenet/go-ipfs/core"
ci
"github.com/jbenet/go-ipfs/crypto"
mdag
"github.com/jbenet/go-ipfs/merkledag"
nsys
"github.com/jbenet/go-ipfs/namesys"
"github.com/jbenet/go-ipfs/peer"
mdht
"github.com/jbenet/go-ipfs/routing/mock"
)
var
_
=
core
.
IpfsNode
{}
func
NewMockNode
()
(
*
core
.
IpfsNode
,
error
)
{
nd
:=
new
(
core
.
IpfsNode
)
//Generate Identity
nd
.
Identity
=
&
peer
.
Peer
{
ID
:
[]
byte
(
"TESTING"
)}
pk
,
sk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
1024
)
if
err
!=
nil
{
return
nil
,
err
}
nd
.
Identity
.
PrivKey
=
pk
nd
.
Identity
.
PubKey
=
sk
// Temp Datastore
dstore
:=
ds
.
NewMapDatastore
()
nd
.
Datastore
=
syncds
.
MutexWrap
(
dstore
)
// Routing
dht
:=
mdht
.
NewMockRouter
(
nd
.
Identity
,
nd
.
Datastore
)
// Bitswap
//??
bserv
,
err
:=
bs
.
NewBlockService
(
nd
.
Datastore
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
dserv
:=
&
mdag
.
DAGService
{
bserv
}
// Namespace resolver
nd
.
Namesys
=
nsys
.
NewMasterResolver
(
dht
,
dserv
)
return
nd
,
nil
}
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