taler-android

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

repro_unknown_currency_formatting.py (1975B)


      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 word-shaped currency symbol is glued to the number.
     15 
     16     cd /opt/taler-sim/driver
     17     python3 ../findings/repro_unknown_currency_formatting.py [emulator-5554]
     18 
     19 Exits 0 when an amount like "UNKNOWN0.00" is on screen.
     20 """
     21 
     22 from __future__ import annotations
     23 
     24 import re
     25 import sys
     26 import time
     27 from pathlib import Path
     28 
     29 sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "driver"))
     30 
     31 from device import Device  # noqa: E402
     32 from wallet import Wallet  # noqa: E402
     33 
     34 # A currency word immediately followed by digits, with no separator.
     35 GLUED = re.compile(r"^[A-Za-z]{3,}\d")
     36 # Any order id that does not exist at the merchant will do.
     37 PAY_URI = "taler+http://pay/localhost:8080/instances/sim/NOSUCHORDER12345/"
     38 
     39 
     40 def main() -> int:
     41     serial = sys.argv[1] if len(sys.argv) > 1 else "emulator-5554"
     42     dev = Device(serial)
     43     app = Wallet(dev)
     44     app.fresh_start(dev_mode=True)
     45     app.handle_uri(PAY_URI)
     46     time.sleep(8)
     47 
     48     screen = dev.dump()
     49     texts = screen.texts()
     50     glued = [t for t in texts if GLUED.match(t.strip())]
     51     print(f"screen: {texts[:14]}")
     52     print(f"amounts rendered without a separator: {glued}")
     53     print(f"\nreproduced: {bool(glued)}")
     54     return 0 if glued else 1
     55 
     56 
     57 if __name__ == "__main__":
     58     raise SystemExit(main())