fix: ensure hasher is registered when using a hashing function

Fixes #9297
This commit is contained in:
Jorropo 2022-09-26 06:55:37 +02:00 committed by Antonio Navarro Perez
parent baccaef1b5
commit 773c246232
2 changed files with 7 additions and 0 deletions

View File

@ -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 {

View File

@ -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