github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/blocks/key/key_test.go (about)

     1  package key
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  
     7  	mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
     8  )
     9  
    10  func TestKey(t *testing.T) {
    11  
    12  	h1, err := mh.Sum([]byte("beep boop"), mh.SHA2_256, -1)
    13  	if err != nil {
    14  		t.Error(err)
    15  	}
    16  
    17  	k1 := Key(h1)
    18  	h2 := mh.Multihash(k1)
    19  	k2 := Key(h2)
    20  
    21  	if !bytes.Equal(h1, h2) {
    22  		t.Error("Multihashes not equal.")
    23  	}
    24  
    25  	if k1 != k2 {
    26  		t.Error("Keys not equal.")
    27  	}
    28  }