Skip to content

Commit

Permalink
fix: ensure hasher is registered when using a hashing function
Browse files Browse the repository at this point in the history
Fixes #9297
  • Loading branch information
Jorropo authored and ajnavarro committed Sep 26, 2022
1 parent baccaef commit 773c246
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ See 'dag export' and 'dag import' for more information.
if !ok {
return fmt.Errorf("unrecognized hash function: %q", strings.ToLower(hashFunStr))
}
if _, err := mh.GetHasher(hashFunCode); err != nil {
return err
}

enc, err := cmdenv.GetCidEncoder(req)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions test/sharness/t0042-add-skip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ EOF
test_cmp expected actual
'

test_expect_failure "'ipfs add' with an unregistered hash and wrapped leaves fails without crashing" '
ipfs add --hash poseidon-bls12_381-a2-fc1 --raw-leaves=false -r mountdir/planets
'

}

# should work offline
Expand Down

0 comments on commit 773c246

Please sign in to comment.