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

fix staticcheck #73

Merged
merged 1 commit into from
May 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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