-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Daemon and DHT Tests #79
Changes from 5 commits
0276c9b
a945d4d
56f57b7
cebcf10
9b93f46
36dbe06
f8ee61a
fafdc17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package daemon | ||
|
||
import ( | ||
"encoding/base64" | ||
"testing" | ||
|
||
config "github.com/jbenet/go-ipfs/config" | ||
core "github.com/jbenet/go-ipfs/core" | ||
ci "github.com/jbenet/go-ipfs/crypto" | ||
) | ||
|
||
func TestDaemonListener(t *testing.T) { | ||
|
||
priv, _, err := ci.GenerateKeyPair(ci.RSA, 512) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
prbytes, err := priv.Bytes() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
privKey := base64.StdEncoding.EncodeToString(prbytes) | ||
|
||
id := &config.Identity{ | ||
PeerID: "QmNgdzLieYi8tgfo2WfTUzNVH5hQK9oAYGVf6dxN12NrHt", | ||
Address: "/ip4/127.0.0.1/tcp/8000", | ||
PrivKey: privKey, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont know if it really matters for the test here, but PeerID can be set to the hash of the public key. I beleive there is a method somewhere (in the crypto package) called IDfromPubKey or something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added* |
||
} | ||
|
||
nodeConfigs := []*config.Config{ | ||
&config.Config{ | ||
Identity: id, | ||
Datastore: config.Datastore{ | ||
Type: "memory", | ||
}, | ||
}, | ||
|
||
&config.Config{ | ||
Identity: id, | ||
Datastore: config.Datastore{ | ||
Type: "leveldb", | ||
Path: ".testdb", | ||
}, | ||
}, | ||
} | ||
|
||
for _, c := range nodeConfigs { | ||
|
||
node, _ := core.NewIpfsNode(c, false) | ||
dl, initErr := NewDaemonListener(node, "localhost:1327") | ||
if initErr != nil { | ||
t.Fatal(initErr) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure it starts up, then make sure it tears down. Good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx |
||
closeErr := dl.Close() | ||
if closeErr != nil { | ||
t.Fatal(closeErr) | ||
} | ||
node.Close() | ||
|
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Close method should shut down each of the individual subsystems in core. im not quite sure whats going on here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah k, need to convert c++ mentality to go