ZaStoGram/Tools/run_pathtest_jvm_tests.sh
loop-uh a918b73f48
Some checks failed
Build three ZaStoGram APKs / build (armeabi-v7a, ZaStoGram-standalone-armeabi-v7a, Armv7, armv7) (push) Failing after 49s
Build three ZaStoGram APKs / build (arm64-v8a, ZaStoGram-standalone-arm64-v8a, Arm64, arm64) (push) Failing after 51s
ZaStoGram source guards / guards (push) Failing after 40s
Build three ZaStoGram APKs / build (x86, ZaStoGram-standalone-x86, X86, x86) (push) Failing after 1m8s
Check connection: a path test that runs the real client code and writes one log
New module (jni/tgnet/pathtest, org.telegram.zastogram.pathtest): for every proxy of the list, the official WSS route
and two control hosts it makes 12 attempts 1.5 s apart through the REAL client code and writes one text log with a
JSONL twin into the logs folder (so the logs screen and its zip export carry it): per-attempt lines (server_hello,
alert, rst, fin, silent, connect_failed with time to first byte, DNS and TCP times), a summary table and a plain
verdict per host and profile.

The probe is not a second client: Naive entries go through naive::CreateFor, the WSS route through the real
wss::Socket (setDiagnosticProbe switches off route-health writes), FakeTLS profiles through composeFakeTlsClientHello,
now the single place ConnectionSocket also builds its hello. The probe peeks the first server bytes to classify the
answer. Secrets are never read (random FakeTLS key, throw-away Naive credentials, only the cover domain of a secret),
hosts are ep-<8 hex of sha256(host:port)> unless real names are ticked, every log field is a closed-vocabulary token.

UI: a row in the proxy settings, an offer after a failed proxy check, share button. Tests: JVM tests of the pure
logic, a native host test against the real WssSocket.cpp and local servers (silent, fin, rst, alert, http, overloaded),
guards updated for the shared hello composer. Verified on an x86_64 emulator against lab shapes and the real relay.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-29 12:36:51 +00:00

19 lines
1.3 KiB
Shell
Executable file

#!/bin/bash
# Runs the JVM unit tests of the "Check connection" module (org.telegram.zastogram.pathtest) without Gradle:
# the module's pure-logic classes have no Android dependency, so javac + JUnit 4 is enough and takes seconds
# (the Gradle unit-test task would compile the whole 3000-file app first).
# JUnit: JUNIT_JAR / HAMCREST_JAR, or the copies shipped inside the Gradle distribution.
set -euo pipefail
HERE=$(cd "$(dirname "$0")" && pwd)
SRC=$HERE/../TMessagesProj/src
find_jar() { find "$HOME/.gradle/wrapper/dists" -name "$1" 2>/dev/null | head -1; }
JUNIT=${JUNIT_JAR:-$(find_jar 'junit-4*.jar')}
HAMCREST=${HAMCREST_JAR:-$(find_jar 'hamcrest-core-*.jar')}
[ -n "$JUNIT" ] && [ -n "$HAMCREST" ] || { echo "junit/hamcrest jars not found: set JUNIT_JAR and HAMCREST_JAR" >&2; exit 2; }
OUT=$(mktemp -d)
trap 'rm -rf "$OUT"' EXIT
MAIN=$(ls "$SRC"/main/java/org/telegram/zastogram/pathtest/PathTest{Ids,Attempt,Verdict,Report,NativeResult}.java)
TESTS=$(ls "$SRC"/test/java/org/telegram/zastogram/pathtest/*Test.java)
javac -source 8 -target 8 -Xlint:-options -d "$OUT" -cp "$JUNIT:$HAMCREST" $MAIN $TESTS
CLASSES=$(cd "$SRC/test/java" && ls org/telegram/zastogram/pathtest/*Test.java | sed 's#/#.#g; s#\.java$##' | tr '\n' ' ')
java -cp "$OUT:$JUNIT:$HAMCREST" org.junit.runner.JUnitCore $CLASSES