1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 03:19:47 +08:00
Files
kubo/core/commands/dht_test.go
2022-09-09 17:09:38 +02:00

35 lines
578 B
Go

package commands
import (
"testing"
"github.com/ipfs/go-namesys"
ipns "github.com/ipfs/go-ipns"
"github.com/libp2p/go-libp2p/core/test"
)
func TestKeyTranslation(t *testing.T) {
pid := test.RandPeerIDFatal(t)
pkname := namesys.PkKeyForID(pid)
ipnsname := ipns.RecordKey(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 != pkname {
t.Fatal("keys didn't match!")
}
if ipnsk != ipnsname {
t.Fatal("keys didn't match!")
}
}