taler-android

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

repro_global_currency_null_masterpub.py (2451B)


      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 """Minimal reproducer: "Treat as global" on an un-contacted exchange.
     15 
     16 Found by explore.py (seed 11, step 34) and shrunk to four taps.  See
     17 addglobalcurrencyexchange-null-masterpub.md for the analysis.
     18 
     19     cd /opt/taler-sim/driver && python3 ../findings/repro_global_currency_null_masterpub.py
     20 
     21 Exits 0 when the internal error reproduces, 1 when it does not.
     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 from device import Device  # noqa: E402
     33 from wallet import Wallet  # noqa: E402
     34 
     35 # A builtin exchange the wallet has never talked to, so its masterPub is still
     36 # null.  exchange.demo.taler.net works too; the local one does not, because
     37 # withdrawing from it fetches /keys and fills masterPub in.
     38 UNCONTACTED = "exchange.taler-ops.ch"
     39 
     40 
     41 def main() -> int:
     42     dev = Device(sys.argv[1] if len(sys.argv) > 1 else "emulator-5554")
     43     app = Wallet(dev)
     44 
     45     app.fresh_start(dev_mode=True)
     46     dev.logcat(clear=True)
     47 
     48     app.open_settings()
     49     app.scroll_to_text(r"(?i)^Payment services$")
     50     dev.tap_text(r"(?i)^Payment services$")
     51     dev.wait_for(UNCONTACTED, timeout=30)
     52     dev.tap_text(f"Menu: {UNCONTACTED}", timeout=30)
     53     dev.tap_text(r"(?i)^Treat as global$", timeout=30)
     54     time.sleep(3)
     55 
     56     log = dev.logcat()
     57     screen = dev.dump()
     58     hit = "addGlobalCurrencyExchange error" in log and "exchangeMasterPub" in log
     59     print(f"screen after the tap: {screen.texts()}")
     60     for line in log.splitlines():
     61         if "addGlobalCurrencyExchange" in line and "error" in line:
     62             print(line.strip()[:400])
     63     print(f"\nreproduced: {hit}")
     64     return 0 if hit else 1
     65 
     66 
     67 if __name__ == "__main__":
     68     sys.exit(main())