Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #73 from ipfs/fix-staticcheck
Browse files Browse the repository at this point in the history
fix staticcheck
  • Loading branch information
marten-seemann committed May 16, 2021
2 parents 10b7bf0 + c8a6ece commit 12cea36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 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 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 12cea36

Please sign in to comment.