提交 016f18c8 作者: Jeromy Johnson

Merge pull request #2340 from ipfs/fix/key-escape

fix dht command key escaping
......@@ -573,7 +573,7 @@ func escapeDhtKey(s string) (key.Key, error) {
return key.B58KeyDecode(s), nil
case 3:
k := key.B58KeyDecode(parts[2])
return key.Key(path.Join(append(parts[:2], k.String()))), nil
return key.Key(path.Join(append(parts[:2], string(k)))), nil
default:
return "", errors.New("invalid key")
}
......
package commands
import (
"testing"
"github.com/ipfs/go-ipfs/namesys"
tu "github.com/ipfs/go-ipfs/thirdparty/testutil"
)
func TestKeyTranslation(t *testing.T) {
pid := tu.RandPeerIDFatal(t)
a, b := namesys.IpnsKeysForID(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 != a {
t.Fatal("keys didnt match!")
}
if ipnsk != b {
t.Fatal("keys didnt match!")
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论