1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 11:31:54 +08:00

test for the dht key escaping

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Jeromy
2016-02-15 00:00:09 -08:00
parent 65c66fd09b
commit c5b2e09708

31
core/commands/dht_test.go Normal file
View File

@ -0,0 +1,31 @@
package commands
import (
"testing"
"github.com/ipfs/go-ipfs/namesys"
tu "github.com/ipfs/go-ipfs/thirdparty/testutil"
)
func TestKeyTranslation(t *testing.T) {
pid := tu.RandPeerIDFatal(t)
a, b := namesys.IpnsKeysForID(pid)
pkk, err := escapeDhtKey("/pk/" + pid.Pretty())
if err != nil {
t.Fatal(err)
}
ipnsk, err := escapeDhtKey("/ipns/" + pid.Pretty())
if err != nil {
t.Fatal(err)
}
if pkk != a {
t.Fatal("keys didnt match!")
}
if ipnsk != b {
t.Fatal("keys didnt match!")
}
}