repro_release_error_screen.py (3124B)
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: a release build's error screen can explain nothing. 15 16 With developer mode off, the whole explanation is `userFacingMsg` -- the hint 17 and the message concatenated -- so an error carrying neither renders as the 18 word "Error" and the export buttons. 19 20 cd /opt/taler-sim/driver 21 python3 ../findings/repro_release_error_screen.py [emulator-5554] 22 """ 23 24 from __future__ import annotations 25 26 import sys 27 import time 28 from pathlib import Path 29 30 sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "driver")) 31 32 import scenarios # noqa: E402 33 from device import PKG, Device # noqa: E402 34 from stack import Env # noqa: E402 35 from wallet import Wallet # noqa: E402 36 37 # {"code": 7001}: no hint, no message. 38 BARE_ERROR = ("taler+http://dev-experiment/api-error?operation=getBalances" 39 "&detail=eyJjb2RlIjogNzAwMX0&count=20") 40 CHROME = ("Error", "Copy", "Share", "Settings", "Internal event log", 41 "Scan QR code", "Wallet") 42 43 44 def main() -> int: 45 serial = sys.argv[1] if len(sys.argv) > 1 else "emulator-5554" 46 dev = Device(serial) 47 app = Wallet(dev) 48 env = Env.load() 49 scenarios.fund_wallet(app, env, "EUR:10") 50 51 app.handle_uri(BARE_ERROR) 52 time.sleep(2) 53 for _ in range(3): 54 if dev.dump().activity.startswith(PKG): 55 break 56 dev.launch() 57 time.sleep(6) 58 app.home() 59 time.sleep(3) 60 print(f"with developer mode: {dev.dump().texts()[:8]}") 61 62 # Turn developer mode off: that is what a release build is. 63 app.open_settings() 64 app.scroll_to_text(r"(?i)^Developer mode$") 65 screen = dev.dump() 66 row = screen.find(r"(?i)^Developer mode$") 67 if row is None: 68 print("no developer mode row") 69 return 2 70 _, y = row.center 71 width = max(n.bounds[2] for n in screen.nodes) 72 dev.tap(width - 100, y) 73 time.sleep(2) 74 if app.dev_mode_on(): 75 print("could not turn developer mode off") 76 return 2 77 78 app.home() 79 time.sleep(4) 80 texts = dev.dump().texts() 81 print(f"without developer mode: {texts[:8]}") 82 said_error = any(t.strip() == "Error" for t in texts) 83 explained = [t for t in texts 84 if t.strip() not in CHROME and "Export error" not in t] 85 print(f"anything explaining it: {explained[:6]}") 86 print(f"\nreproduced: {said_error and not explained}") 87 return 0 if (said_error and not explained) else 1 88 89 90 if __name__ == "__main__": 91 raise SystemExit(main())