From ea38e39a203a96451b1d0469103b737de5a85105 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 8 Jan 2014 17:56:30 +0100 Subject: [PATCH] Test whether Nix correctly checks the hash of downloaded NARs --- tests/binary-cache.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/binary-cache.sh b/tests/binary-cache.sh index ed947a662..71ede03c8 100644 --- a/tests/binary-cache.sh +++ b/tests/binary-cache.sh @@ -40,6 +40,20 @@ nix-store --check-validity $outPath nix-store -qR $outPath | grep input-2 +# Test whether Nix notices if the NAR doesn't match the hash in the NAR info. +clearStore + +nar=$(ls $cacheDir/*.nar.xz | head -n1) +mv $nar $nar.good +mkdir -p $TEST_ROOT/empty +nix-store --dump $TEST_ROOT/empty | xz > $nar + +nix-build --option binary-caches "file://$cacheDir" dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log +grep -q "hash mismatch in downloaded path" $TEST_ROOT/log + +mv $nar.good $nar + + # Test whether this unsigned cache is rejected if the user requires signed caches. clearStore