From 70f6de4059d29764941f7a759cee462d09f10039 Mon Sep 17 00:00:00 2001 From: ms Date: Fri, 2 Jul 2021 15:51:33 +0200 Subject: fix amount check --- buildbot/check_tip_reserve.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'buildbot') diff --git a/buildbot/check_tip_reserve.py b/buildbot/check_tip_reserve.py index ef821fa..320c614 100755 --- a/buildbot/check_tip_reserve.py +++ b/buildbot/check_tip_reserve.py @@ -24,6 +24,7 @@ def expect_env(name): MERCHANT_BACKEND_BASE_URL = expect_env("TALER_ENV_MERCHANT_BACKEND") TALER_ENV_FRONTENDS_APITOKEN = expect_env("TALER_ENV_FRONTENDS_APITOKEN") +TALER_CONFIG_CURRENCY = expect_env("TALER_CONFIG_CURRENCY") resp = requests.get( urljoin(MERCHANT_BACKEND_BASE_URL, @@ -40,15 +41,21 @@ if len(reserves) == 0: print("merchant backend has NO tip reserves active!") exit(1) -max_amount = Amount.parse(reserves[0].get("committed_amount")) +max_amount = Amount(TALER_CONFIG_CURRENCY, 0, 0) for item in reserves[1:]: - item_amount = Amount.parse(item.get("committed_amount")) - if item_amount > max_amount: - max_amount = item_amount + committed_amount = Amount.parse(item.get("committed_amount")) + allocated_amount = Amount.parse(item.get("merchant_initial_amount")) + confirmed_amount = Amount.parse(item.get("exchange_initial_amount")) + if allocated_amount != confirmed_amount: + print("The exchange never confirmed the tip reserve amount!") + exit(1) + remaining_amount = allocated_amount - committed_amount + if remaining_amount > max_amount: + max_amount = remaining_amount # FIXME, eventually, just check the largest amount left through # all the reserves. print(f"Largest tip reserve: {max_amount}") -print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") +print("\n\n\n\n\n\n\n") print(f"=========================================") print(f"FULL DUMP FROM THE BACKEND:\n{resp.text}") -- cgit v1.2.3