Skip to content

Commit

Permalink
Merge pull request ipfs/go-ipfs-blockstore#73 from ipfs/fix-staticcheck
Browse files Browse the repository at this point in the history
fix staticcheck

This commit was moved from ipfs/go-ipfs-blockstore@12cea36
  • Loading branch information
marten-seemann authored May 16, 2021
2 parents e74b9b5 + 9255102 commit 3b36077
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion blockstore/idstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions blockstore/idstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}
}
Expand Down

0 comments on commit 3b36077

Please sign in to comment.