commit d3627b8d1629cc989ac32ea94fee49381b3be278
parent fa8839ae6dc7aad8ac255c98602557b6b441930d
Author: Florian Dold <florian@dold.me>
Date: Wed, 10 Jun 2026 11:42:20 +0200
update devtesting to match libeufin
Diffstat:
1 file changed, 22 insertions(+), 54 deletions(-)
diff --git a/roles/devtesting/tasks/files/taler-devtesting b/roles/devtesting/tasks/files/taler-devtesting
@@ -5,37 +5,6 @@ import shlex
import os
import sys
import subprocess
-import random
-
-
-def calculate_iban_check_digits(country_code, bban):
- numeric_iban_str = ""
- for char in bban + country_code + "00":
- if char.isdigit():
- numeric_iban_str += char
- elif "A" <= char.upper() <= "Z":
- numeric_iban_str += str(ord(char.upper()) - ord("A") + 10)
- else:
- raise ValueError(
- f"Invalid character '{char}' in IBAN for checksum calculation."
- )
- remainder = int(numeric_iban_str) % 97
- check_digits_int = 98 - remainder
- return str(check_digits_int).zfill(2)
-
-
-def generate_random_swiss_iban():
- country_code = "CH"
- bban = "".join([str(random.randint(0, 9)) for _ in range(12 + 5)])
- check_digits = calculate_iban_check_digits(country_code, bban)
- return f"{country_code}{check_digits}{bban}"
-
-
-def generate_random_german_iban():
- country_code = "DE"
- bban = "".join([str(random.randint(0, 9)) for _ in range(18)])
- check_digits = calculate_iban_check_digits(country_code, bban)
- return f"{country_code}{check_digits}{bban}"
@click.group()
@@ -54,23 +23,15 @@ def get_nexus_currency():
@cli.command()
-@click.option("--amount", required=True)
-@click.option("--subject", required=True)
-@click.option("--debitor-payto")
-def fake_incoming(amount, subject, debitor_payto):
+@click.argument("credit-payto")
+@click.option("--debit-payto")
+def fake_incoming(credit_payto, debit_payto):
currency = get_nexus_currency()
-
- if debitor_payto is None:
- if currency == "CHF":
- iban = generate_random_swiss_iban()
- elif currency == "EUR":
- iban = generate_random_german_iban()
- else:
- raise Exception(f"unsupported currency {repr(currency)}")
- debitor_payto = f"payto://iban/{iban}?receiver-name=Tammy%20Tester"
-
+ debit_opts = []
+ if debit_payto is not None:
+ debit_opts = ["--debit-payto", debit_payto]
print(f"Faking incoming {currency} transaction", file=sys.stderr)
- print(f"Debitor Payto: ", debitor_payto, file=sys.stderr)
+ print(f"Debir Payto: ", debit_payto, file=sys.stderr)
subprocess.run(
[
"sudo",
@@ -79,11 +40,9 @@ def fake_incoming(amount, subject, debitor_payto):
"libeufin-nexus",
"testing",
"fake-incoming",
- "--amount",
- amount,
- "--subject",
- subject,
- debitor_payto,
+ "--credit-payto",
+ credit_payto,
+ *debit_opts,
],
check=True,
)
@@ -93,12 +52,21 @@ def fake_incoming(amount, subject, debitor_payto):
def geniban():
currency = get_nexus_currency()
if currency == "CHF":
- iban = generate_random_swiss_iban()
+ cc = "CH"
elif currency == "EUR":
- iban = generate_random_german_iban()
+ cc = "DE"
else:
raise Exception(f"unsupported currency {repr(currency)}")
- print(iban)
+ subprocess.run(
+ [
+ "libeufin-nexus",
+ "testing",
+ "iban",
+ "gen",
+ "--country",
+ cc,
+ ]
+ )
if __name__ == "__main__":