test for the dht key escaping
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Feb 15, 2016 at 00:00 UTC
c5b2e09708921721e2a5fb6ba753b1b220667098
1 file changed
+31
core/commands/dht_test.go
new
+31
@@ -0,0 +1,31 @@
1
+package commands
2
+
3
+import (
4
+ "testing"
5
+
6
+ "github.com/ipfs/go-ipfs/namesys"
7
+ tu "github.com/ipfs/go-ipfs/thirdparty/testutil"
8
+)
9
+
10
+func TestKeyTranslation(t *testing.T) {
11
+ pid := tu.RandPeerIDFatal(t)
12
+ a, b := namesys.IpnsKeysForID(pid)
13
+
14
+ pkk, err := escapeDhtKey("/pk/" + pid.Pretty())
15
+ if err != nil {
16
+ t.Fatal(err)
17
+ }
18
+
19
+ ipnsk, err := escapeDhtKey("/ipns/" + pid.Pretty())
20
+ if err != nil {
21
+ t.Fatal(err)
22
+ }
23
+
24
+ if pkk != a {
25
+ t.Fatal("keys didnt match!")
26
+ }
27
+
28
+ if ipnsk != b {
29
+ t.Fatal("keys didnt match!")
30
+ }
31
+}