diff --git a/idstore.go b/idstore.go index 1166e5b..b1a85b6 100644 --- a/idstore.go +++ b/idstore.go @@ -34,7 +34,7 @@ func extractContents(k cid.Cid) (bool, []byte) { } dmh, err := mh.Decode(k.Hash()) - if err != nil || dmh.Code != mh.ID { + if err != nil || dmh.Code != mh.IDENTITY { return false, nil } return true, dmh.Digest diff --git a/idstore_test.go b/idstore_test.go index 321d5ec..65b902e 100644 --- a/idstore_test.go +++ b/idstore_test.go @@ -17,7 +17,7 @@ func createTestStores() (Blockstore, *callbackDatastore) { } func TestIdStore(t *testing.T) { - idhash1, _ := cid.NewPrefixV1(cid.Raw, mh.ID).Sum([]byte("idhash1")) + idhash1, _ := cid.NewPrefixV1(cid.Raw, mh.IDENTITY).Sum([]byte("idhash1")) idblock1, _ := blk.NewBlockWithCid([]byte("idhash1"), idhash1) hash1, _ := cid.NewPrefixV1(cid.Raw, mh.SHA2_256).Sum([]byte("hash1")) block1, _ := blk.NewBlockWithCid([]byte("hash1"), hash1) @@ -110,7 +110,7 @@ func TestIdStore(t *testing.T) { t.Fatal(err) } - idhash2, _ := cid.NewPrefixV1(cid.Raw, mh.ID).Sum([]byte("idhash2")) + idhash2, _ := cid.NewPrefixV1(cid.Raw, mh.IDENTITY).Sum([]byte("idhash2")) idblock2, _ := blk.NewBlockWithCid([]byte("idhash2"), idhash2) hash2, _ := cid.NewPrefixV1(cid.Raw, mh.SHA2_256).Sum([]byte("hash2")) block2, _ := blk.NewBlockWithCid([]byte("hash2"), hash2) @@ -146,10 +146,13 @@ func TestIdStore(t *testing.T) { } ch, err := ids.AllKeysChan(context.TODO()) + if err != nil { + t.Fatal(err) + } cnt := 0 for c := range ch { cnt++ - if c.Prefix().MhType == mh.ID { + if c.Prefix().MhType == mh.IDENTITY { t.Fatalf("block with identity hash found in blockstore") } }