summaryrefslogtreecommitdiff
path: root/tests/derivations.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2023-01-09 16:48:01 +0100
committerLudovic Courtès <ludo@gnu.org>2023-01-09 17:40:54 +0100
commit407175a1d0e29f45639e7f28a531b3981cd20085 (patch)
tree4b29a28466d8128a4b89b208735dfdf181d88364 /tests/derivations.scm
parent5d24e57a611b43ff68700379338b899f62d198cc (diff)
daemon: Improve error message for wrong hash sizes.
* nix/libutil/hash.cc (parseHash): Show the hash algorithm name and expected size in the error message. * tests/derivations.scm ("fixed-output derivation, invalid hash size"): New test.
Diffstat (limited to 'tests/derivations.scm')
-rw-r--r--tests/derivations.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 3d25365b14c..66c777cfe7e 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -396,6 +396,18 @@
396 (call-with-input-file p get-bytevector-all)) 396 (call-with-input-file p get-bytevector-all))
397 (bytevector? (query-path-hash %store p))))))) 397 (bytevector? (query-path-hash %store p)))))))
398 398
399(test-assert "fixed-output derivation, invalid hash size"
400 (guard (c ((store-protocol-error? c)
401 (string-contains-ci (store-protocol-error-message c)
402 "invalid SHA512 hash")))
403 (derivation %store "download-with-invalid-hash"
404 "builtin:download" '()
405 #:env-vars `(("url"
406 . ,(object->string "http://example.org")))
407 #:hash-algo 'sha512
408 #:hash #vu8(1 2 3))
409 #f))
410
399(test-assert "derivation with a fixed-output input" 411(test-assert "derivation with a fixed-output input"
400 ;; A derivation D using a fixed-output derivation F doesn't has the same 412 ;; A derivation D using a fixed-output derivation F doesn't has the same
401 ;; output path when passed F or F', as long as F and F' have the same output 413 ;; output path when passed F or F', as long as F and F' have the same output