mirror of
https://github.com/ipfs/kubo.git
synced 2025-08-06 19:44:01 +08:00
35 lines
608 B
Go
35 lines
608 B
Go
package commands
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ipfs/boxo/namesys"
|
|
|
|
ipns "github.com/ipfs/boxo/ipns"
|
|
"github.com/libp2p/go-libp2p/core/test"
|
|
)
|
|
|
|
func TestKeyTranslation(t *testing.T) {
|
|
pid := test.RandPeerIDFatal(t)
|
|
pkname := namesys.PkRoutingKey(pid)
|
|
ipnsname := ipns.NameFromPeer(pid).RoutingKey()
|
|
|
|
pkk, err := escapeDhtKey("/pk/" + pid.String())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
ipnsk, err := escapeDhtKey("/ipns/" + pid.String())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if pkk != pkname {
|
|
t.Fatal("keys didn't match!")
|
|
}
|
|
|
|
if ipnsk != string(ipnsname) {
|
|
t.Fatal("keys didn't match!")
|
|
}
|
|
}
|