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:
31
core/commands/dht_test.go
Normal file
31
core/commands/dht_test.go
Normal 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!")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user