about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-01-08T16·56+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-01-08T16·56+0100
commitea38e39a203a96451b1d0469103b737de5a85105 (patch)
treea2b66ec6149a34050547f31556f1a7e9c8d0f7a0 /tests
parent11cb4bfb257f18c906ef1d6f14ed450be8fa49fe (diff)
Test whether Nix correctly checks the hash of downloaded NARs
Diffstat (limited to 'tests')
-rw-r--r--tests/binary-cache.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/binary-cache.sh b/tests/binary-cache.sh
index ed947a6620d5..71ede03c8320 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