android-test: smoke is withdraw then pay, both first-class

Structure Abheben before Bezahlen with multi-round UI; SMOKE_STRICT
requires wallet-core signals for both legs when enabled.
This commit is contained in:
Hernâni Marques 2026-07-17 21:59:01 +02:00
parent a7dd6ee824
commit 2bc94b471b
No known key found for this signature in database
GPG key ID: CB5738652768F7E9
4 changed files with 261 additions and 139 deletions

View file

@ -1,12 +1,9 @@
#!/usr/bin/env bash
# GUI-oriented Android smoke (vanilla level): deep-link entry + UI taps.
# GUI-oriented Android smoke: **withdraw (Abheben)** then **pay**, each with
# deep-link entry + multi-round uiautomator taps. Not pay-only.
#
# Entry shortcut (legitimate — same as scanning a QR on the landing):
# adb VIEW taler://withdraw/… and taler://pay…
# Then drives the **graphical UI** via uiautomator dump + taps (Confirm / ToS / Pay).
#
# Systems: STACK=goa | stage | auto
# APK: published F-Droid or APK_PATH=… (from-source)
# 1) taler://withdraw/… + Confirm/Abheben/ToS taps
# 2) taler://pay… + Pay/Confirm taps
#
# See GUI-AUTOMATION-NOTES.md
#
@ -85,20 +82,28 @@ echo "apk: $APK_PATH pkg: $PKG"
"${ADB[@]}" shell settings put global transition_animation_scale 0 || true
"${ADB[@]}" shell settings put global animator_duration_scale 0 || true
WURI=$(curl -sfS -m 25 "$WITHDRAW_JSON" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("taler_withdraw_uri") or d.get("qr_payload") or "")')
[ -n "$WURI" ] || { echo "no withdraw uri" >&2; exit 4; }
echo "withdraw: $WURI"
echo "$WURI" >"$OUT_DIR/last-withdraw.uri"
: "${DO_WITHDRAW:=1}"
: "${DO_PAY:=1}"
: "${SMOKE_STRICT:=0}"
WURI=""
PAY_URI=""
WITHDRAW_OK=0
PAY_OK=0
"${ADB[@]}" shell am force-stop "$PKG" 2>/dev/null || true
"${ADB[@]}" logcat -c 2>/dev/null || true
# --- Shortcut A: deep-link withdraw (≡ QR scan on landing) ---
"${ADB[@]}" shell am start -a android.intent.action.VIEW -d "$WURI" | tee "$OUT_DIR/start-withdraw.txt"
sleep 5
# --- Graphical: drive UI ---
python3 - "$ROOT/lib_ui.py" "$SERIAL" "$OUT_DIR" "$GUI_ROUNDS" "$GUI_SLEEP" <<'PY'
if [ "$DO_WITHDRAW" = "1" ]; then
echo
echo "======== 1 WITHDRAW (Abheben) ========"
WURI=$(curl -sfS -m 25 "$WITHDRAW_JSON" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("taler_withdraw_uri") or d.get("qr_payload") or "")')
[ -n "$WURI" ] || { echo "no withdraw uri" >&2; exit 4; }
echo "withdraw: $WURI"
echo "$WURI" >"$OUT_DIR/last-withdraw.uri"
"${ADB[@]}" shell am start -a android.intent.action.VIEW -d "$WURI" | tee "$OUT_DIR/start-withdraw.txt"
sleep 5
python3 - "$ROOT/lib_ui.py" "$SERIAL" "$OUT_DIR" "$GUI_ROUNDS" "$GUI_SLEEP" <<'PY'
import json, sys, importlib.util
from pathlib import Path
lib_path, serial, out, rounds, sleep_s = (
@ -112,26 +117,28 @@ st = lib.gui_drive(serial, out / "gui-withdraw", rounds=rounds, sleep_s=sleep_s,
print("gui-withdraw taps:", st.get("taps"))
print("gui-withdraw anr:", st.get("anr_dismissals"))
PY
# Pay URI
PAY_URI=""
if [ "$STACK" = "stage" ]; then
if RESP=$(curl -sfS -m 20 -X POST -H 'Content-Type: application/json' -d '{}' \
"$MERCHANT/instances/fermes-des-collines/templates/panier-legumes" 2>/dev/null); then
PAY_URI=$(printf '%s' "$RESP" | python3 -c 'import json,sys;d=json.load(sys.stdin);oid=d.get("order_id")or"";tok=d.get("token")or"";
print("taler://pay/stage.monnaie.lefrancpaysan.ch/instances/fermes-des-collines/%s/?c=%s"%(oid,tok) if oid and tok else "")')
fi
else
PAY_URI="taler://pay-template/taler.hacktivism.ch/instances/goa-shop/paivana"
echo "======== 1 WITHDRAW skipped (DO_WITHDRAW=0) ========"
fi
if [ -n "$PAY_URI" ]; then
echo "pay: $PAY_URI"
echo "$PAY_URI" >"$OUT_DIR/last-pay.uri"
# Shortcut B: deep-link pay (≡ scan pay QR / open paywall link)
"${ADB[@]}" shell am start -a android.intent.action.VIEW -d "$PAY_URI" | tee "$OUT_DIR/start-pay.txt"
sleep 5
python3 - "$ROOT/lib_ui.py" "$SERIAL" "$OUT_DIR" "$GUI_ROUNDS" "$GUI_SLEEP" <<'PY'
if [ "$DO_PAY" = "1" ]; then
echo
echo "======== 2 PAY (Bezahlen) ========"
if [ "$STACK" = "stage" ]; then
if RESP=$(curl -sfS -m 20 -X POST -H 'Content-Type: application/json' -d '{}' \
"$MERCHANT/instances/fermes-des-collines/templates/panier-legumes" 2>/dev/null); then
PAY_URI=$(printf '%s' "$RESP" | python3 -c 'import json,sys;d=json.load(sys.stdin);oid=d.get("order_id")or"";tok=d.get("token")or"";
print("taler://pay/stage.monnaie.lefrancpaysan.ch/instances/fermes-des-collines/%s/?c=%s"%(oid,tok) if oid and tok else "")')
fi
else
PAY_URI="taler://pay-template/taler.hacktivism.ch/instances/goa-shop/paivana"
fi
if [ -n "$PAY_URI" ]; then
echo "pay: $PAY_URI"
echo "$PAY_URI" >"$OUT_DIR/last-pay.uri"
"${ADB[@]}" shell am start -a android.intent.action.VIEW -d "$PAY_URI" | tee "$OUT_DIR/start-pay.txt"
sleep 5
python3 - "$ROOT/lib_ui.py" "$SERIAL" "$OUT_DIR" "$GUI_ROUNDS" "$GUI_SLEEP" <<'PY'
import json, sys, importlib.util
from pathlib import Path
lib_path, serial, out, rounds, sleep_s = (
@ -145,29 +152,50 @@ st = lib.gui_drive(serial, out / "gui-pay", rounds=rounds, sleep_s=sleep_s, phas
print("gui-pay taps:", st.get("taps"))
print("gui-pay anr:", st.get("anr_dismissals"))
PY
else
echo "pay: (no URI)"
fi
else
echo "======== 2 PAY skipped (DO_PAY=0) ========"
fi
"${ADB[@]}" logcat -d -t 400 >"$OUT_DIR/logcat.txt" || true
grep -iE 'taler-wallet|prepareBank|preparePay|confirm|Error|success' "$OUT_DIR/logcat.txt" \
| tail -100 >"$OUT_DIR/logcat-taler.txt" || true
"${ADB[@]}" logcat -d -t 500 >"$OUT_DIR/logcat.txt" || true
grep -iE 'taler-wallet|prepareBank|acceptWithdrawal|confirmWithdrawal|preparePay|confirmPay|Error|success|withdraw|pay' \
"$OUT_DIR/logcat.txt" | tail -100 >"$OUT_DIR/logcat-taler.txt" || true
if [ "$DO_WITHDRAW" = "1" ] && grep -qE 'prepareBankIntegratedWithdrawal|acceptWithdrawal|confirmWithdrawal' \
"$OUT_DIR/logcat.txt" 2>/dev/null; then
WITHDRAW_OK=1
fi
if [ "$DO_PAY" = "1" ] && [ -n "$PAY_URI" ] && \
grep -qiE 'preparePay|confirmPay|preparePurchase|checkPay|pay-template|PayForTemplate' \
"$OUT_DIR/logcat.txt" 2>/dev/null; then
PAY_OK=1
fi
rc=0
echo
echo "=== GUI smoke summary ($STACK) ==="
echo "package: $PKG"
echo "shortcut withdraw URI: delivered"
echo "GUI withdraw: see $OUT_DIR/gui-withdraw-status.json + screenshots"
[ -n "$PAY_URI" ] && echo "shortcut pay URI: delivered"
[ -n "$PAY_URI" ] && echo "GUI pay: see $OUT_DIR/gui-pay-status.json + screenshots"
if grep -q prepareBankIntegratedWithdrawal "$OUT_DIR/logcat.txt" 2>/dev/null; then
echo "wallet-core: prepareBankIntegratedWithdrawal YES"
else
echo "wallet-core: prepareBankIntegratedWithdrawal no (ANR/slow UI?)"
echo "=== GUI smoke summary ($STACK) — withdraw + pay ==="
echo "package: $PKG DO_WITHDRAW=$DO_WITHDRAW DO_PAY=$DO_PAY STRICT=$SMOKE_STRICT"
if [ "$DO_WITHDRAW" = "1" ]; then
echo "withdraw URI: delivered → $OUT_DIR/gui-withdraw-status.json"
echo "withdraw wallet-core: $([ "$WITHDRAW_OK" = 1 ] && echo YES || echo NO)"
if [ "$SMOKE_STRICT" = "1" ] && [ "$WITHDRAW_OK" != "1" ]; then
echo "FAIL: strict withdraw missing"; rc=11
fi
fi
if grep -qiE 'preparePay|confirmPay|pay-template|preparePurchase' "$OUT_DIR/logcat.txt" 2>/dev/null; then
echo "wallet-core: pay path YES"
else
echo "wallet-core: pay path not confirmed in logcat"
if [ "$DO_PAY" = "1" ]; then
echo "pay URI: ${PAY_URI:-none}$OUT_DIR/gui-pay-status.json"
echo "pay wallet-core: $([ "$PAY_OK" = 1 ] && echo YES || echo NO)"
if [ "$SMOKE_STRICT" = "1" ] && [ "$PAY_OK" != "1" ]; then
echo "FAIL: strict pay missing"; [ "$rc" -eq 0 ] && rc=13
fi
fi
if grep -qiE "isn't responding|not responding" "$OUT_DIR/logcat.txt" 2>/dev/null \
|| grep -rqiE "isn't responding" "$OUT_DIR/gui-withdraw" "$OUT_DIR/gui-pay" 2>/dev/null; then
echo "FAIL: ANR"; rc=10
fi
echo "artifacts: $OUT_DIR/"
ls -la "$OUT_DIR" | sed 's/^/ /'
echo "Documented shortcuts → GUI-AUTOMATION-NOTES.md"
exit "$rc"