1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-03 12:16:18 +08:00
Files
kubo/core/commands/dht_test.go
Lars Gierth 2c3ed7efb0 gx: update go-datastore, go-libp2p-swarm
License: MIT
Signed-off-by: Lars Gierth <larsg@systemli.org>
2018-10-04 19:52:42 -04:00

35 lines
650 B
Go

package commands
import (
"testing"
"github.com/ipfs/go-ipfs/namesys"
tu "gx/ipfs/QmNfQbgBfARAtrYsBguChX6VJ5nbjeoYy1KdC36aaYWqG8/go-testutil"
ipns "gx/ipfs/QmYZdD9dRfHtoYt4qAFgtKoiPBAoXntmM3ZcktZVvAgB4s/go-ipns"
)
func TestKeyTranslation(t *testing.T) {
pid := tu.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 didnt match!")
}
if ipnsk != ipnsname {
t.Fatal("keys didnt match!")
}
}