Files
lix/tests/functional/substitute-truncated-nar.sh
T
eldritch horrors 0d24aee673 testing: drop compression from truncated nar test
some versions of zstd enable checksumming, some don't. don't use it.

fixes #1027

Change-Id: I06811072d9e56a682a792f084cf76a81c7b5b4ce
2025-11-05 00:02:10 +01:00

28 lines
811 B
Bash

source common.sh
BINARY_CACHE=file://$cacheDir?compression=none
build() {
nix-build --no-out-link "$@" --expr 'derivation {
name = "text";
system = builtins.currentSystem;
builder = "/bin/sh";
args = [ "-c" "echo some text to make the nar less empty > $out" ];
}'
}
path=$(build)
nix copy --to "$BINARY_CACHE" "$path"
nix-collect-garbage >/dev/null 2>&1
nar=0513ia03lmqyq8bipmvv0awjji48li22rbmm9p5iwzm08y8m810z.nar
[ -e $cacheDir/nar/$nar ] || fail "long nar missing?"
truncate -s $(( $(stat -c %s $cacheDir/nar/$nar) - 10 )) $cacheDir/nar/$nar
# Copying back '$path' from the binary cache. This should fail as it is truncated
if build --option substituters "$BINARY_CACHE" --option require-sigs false -j0; then
fail "Importing a truncated nar should fail"
fi