master
go 34 lines 608 Bytes
Raw
1 package commands
2
3 import (
4 "testing"
5
6 "github.com/ipfs/boxo/namesys"
7
8 ipns "github.com/ipfs/boxo/ipns"
9 "github.com/libp2p/go-libp2p/core/test"
10 )
11
12 func TestKeyTranslation(t *testing.T) {
13 pid := test.RandPeerIDFatal(t)
14 pkname := namesys.PkRoutingKey(pid)
15 ipnsname := ipns.NameFromPeer(pid).RoutingKey()
16
17 pkk, err := escapeDhtKey("/pk/" + pid.String())
18 if err != nil {
19 t.Fatal(err)
20 }
21
22 ipnsk, err := escapeDhtKey("/ipns/" + pid.String())
23 if err != nil {
24 t.Fatal(err)
25 }
26
27 if pkk != pkname {
28 t.Fatal("keys didn't match!")
29 }
30
31 if ipnsk != string(ipnsname) {
32 t.Fatal("keys didn't match!")
33 }
34 }