repro_dev_experiment_uri_exits_app.py (2969B)
1 # This file is part of GNU Taler 2 # (C) 2026 Taler Systems S.A. 3 # 4 # GNU Taler is free software; you can redistribute it and/or modify it under the 5 # terms of the GNU General Public License as published by the Free Software 6 # Foundation; either version 3, or (at your option) any later version. 7 # 8 # GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY 9 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 10 # A PARTICULAR PURPOSE. See the GNU General Public License for more details. 11 # 12 # You should have received a copy of the GNU General Public License along with 13 # GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 14 """Reproducer: an unknown dev-experiment URI errors internally and exits the app. 15 16 The wallet must be closed when the URI arrives — scanning a QR code or opening 17 a link from elsewhere — because that is the case where the screen it pops is 18 the only one in the task. 19 20 cd /opt/taler-sim/driver 21 python3 ../findings/repro_dev_experiment_uri_exits_app.py [emulator-5554] 22 23 Exits 0 when both halves reproduce: the 7001 error in the log, and the wallet 24 no longer being the foreground app. 25 """ 26 27 from __future__ import annotations 28 29 import sys 30 import time 31 from pathlib import Path 32 33 sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "driver")) 34 35 from device import PKG, Device # noqa: E402 36 from wallet import Wallet # noqa: E402 37 38 URI = "taler+http://dev-experiment/nonexistent" 39 40 41 def main() -> int: 42 serial = sys.argv[1] if len(sys.argv) > 1 else "emulator-5554" 43 dev = Device(serial) 44 app = Wallet(dev) 45 app.fresh_start(dev_mode=True) 46 app.home() 47 # The URI has to arrive while the wallet is *not* open: with the app 48 # already running the screen pops back to the main screen, and only a 49 # cold start has nothing behind it to pop to. 50 dev.stop() 51 time.sleep(2) 52 dev.logcat(clear=True) 53 54 dev.send_uri(URI) 55 # The wallet opens, handles the URI and only then pops the screen, so the 56 # foreground is sampled until it settles rather than once. 57 left_at = None 58 for _ in range(10): 59 time.sleep(2) 60 if PKG not in dev.current_activity(): 61 left_at = dev.current_activity() 62 break 63 64 screen = dev.dump() 65 log = dev.logcat() 66 internal = [ln for ln in log.splitlines() 67 if "applyDevExperiment" in ln and "7001" in ln] 68 left_app = left_at is not None or PKG not in screen.activity 69 70 print(f"foreground activity afterwards: " 71 f"{left_at or screen.activity or '(none)'}") 72 print(f"on screen: {screen.texts()[:8]}") 73 for line in internal[:2]: 74 print(line.strip()[:260]) 75 print(f"\nwallet left the foreground: {left_app}") 76 print(f"internal error logged: {bool(internal)}") 77 print(f"reproduced: {left_app and bool(internal)}") 78 return 0 if (left_app and internal) else 1 79 80 81 if __name__ == "__main__": 82 raise SystemExit(main())