Naut/tests/integration/run_interop.sh
ookami125 2178d6a70c Initial commit: Naut-Torrent — from-scratch 10 GbE BitTorrent client
A maintainable, extensible BitTorrent client (C11, Linux/io_uring) targeting
10 GbE saturation. All torrent functionality is built from scratch; liburing
is the only linked third-party dependency on the data path.

Implements Phases 1-7 of the roadmap:
- core: page-aligned buffer pool, MPMC/Treiber queues, bitfields, worker pool
- crypto: SHA-1/256 (SHA-NI + scalar), Merkle (BEP-52), RC4 (MSE)
- bencode/metainfo: zero-copy parser, v1/v2/hybrid .torrent + magnet
- peer: sans-IO wire codec, MSE/PE handshake state machine, BEP-10, ut_metadata, PEX
- piece/storage: block-level multi-peer engine, rarest-first + endgame,
  per-file completion events + single-file relocate (move-as-you-finish)
- tracker/dht: HTTP + UDP (BEP-15) trackers, BEP-5 KRPC iterative lookup
- platform: io_uring reactor (SQPOLL, registered buffers, SEND_ZC)
- surface: versioned RPC, native plugin ABI, sandboxed Lua scripting, nautd/nautctl

Verified against libtorrent (single/multi/hybrid, MSE, magnet-via-DHT, swarm);
unit + interop tests green; ASan/UBSan/TSan clean. Scripting reference in
docs/scripting.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 12:12:00 -04:00

41 lines
1.6 KiB
Bash

#!/usr/bin/env bash
# Phase 3 interop gate: seed each fixture torrent with libtorrent and download
# it with the from-scratch naut_leech, asserting a byte-identical content tree.
# Skips (exit 77 = ctest SKIP) if python libtorrent is unavailable.
set -u
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
LEECH="${1:-$ROOT/build/naut_leech}"
SEEDER="$ROOT/tests/integration/seeder.py"
DATA="$ROOT/tests/fixtures/data"
python3 -c 'import libtorrent' 2>/dev/null || { echo "SKIP: python libtorrent not available"; exit 77; }
[ -x "$LEECH" ] || { echo "FAIL: $LEECH not built"; exit 1; }
fail=0
run_one() {
local tor="$1" cmp="$2"
local out; out="$(mktemp -d /tmp/naut_interop.XXXXXX)"
local log; log="$(mktemp /tmp/naut_seed.XXXXXX)"
python3 "$SEEDER" "$ROOT/tests/fixtures/$tor" "$DATA" > "$log" 2>&1 &
local seed=$!
local port=""
for _ in $(seq 1 100); do port=$(grep -oP 'PORT \K[0-9]+' "$log" 2>/dev/null); [ -n "$port" ] && break; sleep 0.1; done
if [ -z "$port" ]; then echo "FAIL[$tor]: seeder did not start"; cat "$log"; kill "$seed" 2>/dev/null; fail=1; rm -rf "$out" "$log"; return; fi
if timeout 30 "$LEECH" "$ROOT/tests/fixtures/$tor" "$out" 127.0.0.1 "$port" 2>&1 | grep -q "COMPLETE"; then
if diff -r "$out/$cmp" "$DATA/$cmp" >/dev/null; then
echo "PASS[$tor]: byte-identical content tree"
else
echo "FAIL[$tor]: content mismatch"; fail=1
fi
else
echo "FAIL[$tor]: download did not complete"; fail=1
fi
kill "$seed" 2>/dev/null; rm -rf "$out" "$log"
}
run_one single_v1.torrent single.bin
run_one multi_v1.torrent multi
run_one hybrid.torrent multi
exit $fail