Remove hardcoded home path from test scripts

Share directories are now created under \$DATA_ROOT/<peer>/share/
with generated dummy files instead of pointing at /home/frejoh/Downloads.
Tests are now fully self-contained and safe to share.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Fredrik Johansson
2026-06-22 13:42:28 +02:00
parent b87f14a361
commit 0051c8fdbf
2 changed files with 24 additions and 6 deletions

View File

@@ -25,6 +25,15 @@ DATA_ROOT="/tmp/waste-test"
rm -rf "$DATA_ROOT"
mkdir -p "$DATA_ROOT/bin"
# Seed per-peer share directories with dummy files.
mkdir -p "$DATA_ROOT/alice/share" "$DATA_ROOT/bob/share" "$DATA_ROOT/charlie/share"
echo "alice's notes" > "$DATA_ROOT/alice/share/notes.txt"
dd if=/dev/urandom bs=1K count=64 2>/dev/null | base64 > "$DATA_ROOT/alice/share/photo.jpg.b64"
dd if=/dev/urandom bs=1K count=128 2>/dev/null | base64 > "$DATA_ROOT/bob/share/archive.tar.b64"
echo -e "file1.mp3\nfile2.mp3" > "$DATA_ROOT/bob/share/playlist.m3u"
echo "charlie's doc" > "$DATA_ROOT/charlie/share/document.txt"
echo "#!/bin/sh" > "$DATA_ROOT/charlie/share/script.sh"
# Kill any leftover processes from a previous run holding our fixed ports.
for port in "$ANCHOR_PORT" "$ALICE_IPC" "$BOB_IPC" "$CHARLIE_IPC"; do
pid=$(lsof -ti tcp:"$port" 2>/dev/null || true)
@@ -206,7 +215,7 @@ log "$ALICE_COLOR" "alice" "starting daemon (ipc :${ALICE_IPC})"
-data-dir "$DATA_ROOT/alice" \
-ipc-port "$ALICE_IPC" \
-anchor "$ANCHOR_URL" \
-share-dir "/home/frejoh/Downloads/alice" \
-share-dir "$DATA_ROOT/alice/share" \
2> >(while IFS= read -r l; do echo -e "${ALICE_COLOR}${DIM}[alice] ${l}${RESET}"; done) &
PIDS+=($!)
@@ -216,7 +225,7 @@ log "$BOB_COLOR" "bob" "starting daemon (ipc :${BOB_IPC})"
-data-dir "$DATA_ROOT/bob" \
-ipc-port "$BOB_IPC" \
-anchor "$ANCHOR_URL" \
-share-dir "/home/frejoh/Downloads/bob" \
-share-dir "$DATA_ROOT/bob/share" \
2> >(while IFS= read -r l; do echo -e "${BOB_COLOR}${DIM}[bob] ${l}${RESET}"; done) &
PIDS+=($!)
@@ -226,7 +235,7 @@ log "$CHARLIE_COLOR" "charlie" "starting daemon (ipc :${CHARLIE_IPC})"
-data-dir "$DATA_ROOT/charlie" \
-ipc-port "$CHARLIE_IPC" \
-anchor "$ANCHOR_URL" \
-share-dir "/home/frejoh/Downloads/charlie" \
-share-dir "$DATA_ROOT/charlie/share" \
2> >(while IFS= read -r l; do echo -e "${CHARLIE_COLOR}${DIM}[charlie]${l}${RESET}"; done) &
PIDS+=($!)