taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

repro_unknown_wire_method.py (2829B)


      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 wire method hangs the add-account form.
     15 
     16 The exchange advertises a `cyclos` account; `WireType` has no member for it and
     17 the property it decodes into has no default, so the whole getDepositWireTypes
     18 reply throws and the form sits on its spinner for ever.
     19 
     20 Needs the simulator's stack, whose exchange signs a Cyclos address by default
     21 (SIM_EXTRA_PAYTOS in backend/stack.sh).
     22 
     23     cd /opt/taler-sim/driver
     24     python3 ../findings/repro_unknown_wire_method.py [emulator-5554]
     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 import scenarios  # noqa: E402
     36 from device import Device  # noqa: E402
     37 from stack import Env  # noqa: E402
     38 from wallet import Wallet  # noqa: E402
     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     env = Env.load()
     46     scenarios.fund_wallet(app, env, "EUR:10")
     47 
     48     dev.logcat(clear=True)
     49     app.open_settings()
     50     app.scroll_to_text(r"(?i)^Bank accounts$")
     51     dev.tap_text(r"(?i)^Bank accounts$", timeout=20)
     52     time.sleep(3)
     53     dev.tap_text(r"(?i)^Add account$", timeout=20)
     54     # Give the form far longer than it should need.
     55     time.sleep(20)
     56     texts = dev.dump().texts()
     57     print(f"the add-account form after 20s: {texts}")
     58 
     59     log = dev.logcat(lines=600)
     60     failures = [l for l in log.splitlines() if "getDepositWireTypes" in l
     61                 and "Error" in l]
     62     print("the log says: " + (failures[-1][-220:] if failures else "nothing"))
     63 
     64     fields = dev.dump().editable()
     65     stuck = not fields and not any(
     66         t.strip().lower() in ("iban", "x-taler-bank", "bitcoin") for t in texts)
     67     unknown_method = any("does not contain element with name" in l
     68                          for l in failures)
     69     print(f"\nform is empty: {stuck}")
     70     print(f"an unknown wire method is why: {unknown_method}")
     71     print(f"reproduced: {stuck and unknown_method}")
     72     return 0 if (stuck and unknown_method) else 1
     73 
     74 
     75 if __name__ == "__main__":
     76     raise SystemExit(main())