mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 19:32:24 +08:00
29 lines
423 B
Go
29 lines
423 B
Go
package key
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
|
|
)
|
|
|
|
func TestKey(t *testing.T) {
|
|
|
|
h1, err := mh.Sum([]byte("beep boop"), mh.SHA2_256, -1)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
k1 := Key(h1)
|
|
h2 := mh.Multihash(k1)
|
|
k2 := Key(h2)
|
|
|
|
if !bytes.Equal(h1, h2) {
|
|
t.Error("Multihashes not equal.")
|
|
}
|
|
|
|
if k1 != k2 {
|
|
t.Error("Keys not equal.")
|
|
}
|
|
}
|