mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-25 04:17:44 +08:00
Namesys is a very useful submodule. Given a ValueStore and a Datastore it can resolve and publish /ipns/ paths. This functionality does not need to be sequestered inside go-ipfs as it can and should be used without IPFS, for example, for implementing lightweight IPNS publishing services or for resolving /ipns/ paths. "keystore" extraction was necessary, as there is a dependency to it in namesys. Keystore is also a useful module by itself within the stack. Fixes #6537
35 lines
576 B
Go
35 lines
576 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 didnt match!")
|
|
}
|
|
|
|
if ipnsk != ipnsname {
|
|
t.Fatal("keys didnt match!")
|
|
}
|
|
}
|