#!/bin/bash # This file is part of TALER # Copyright (C) 2014-2023 Taler Systems SA # # TALER is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3, or # (at your option) any later version. # # TALER is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public # License along with TALER; see the file COPYING. If not, see # # set -eu # Replace with 0 for nexus... USE_FAKEBANK=1 if [ 1 = "$USE_FAKEBANK" ] then ACCOUNT="exchange-account-2" WIRE_METHOD="x-taler-bank" BANK_FLAGS="-f -d $WIRE_METHOD -u $ACCOUNT" BANK_URL="http://localhost:8082/" else echo -n "Testing for libeufin-bank" libeufin-bank --help >/dev/null /dev/null wallet-withdraw-1.err >wallet-withdraw-1.out echo -n "." if [ 1 = "$USE_FAKEBANK" ] then # Fakebank is instant... sleep 0 else sleep 10 # NOTE: once libeufin can do long-polling, we should # be able to reduce the delay here and run wirewatch # always in the background via setup fi echo -n "." taler-exchange-wirewatch -L "INFO" -c "$CONF" -t &> taler-exchange-wirewatch.out echo -n "." taler-wallet-cli \ --wallet-db="$WALLET_DB" \ run-until-done \ 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out echo " OK" echo -n "Pay first order ..." NOW=$(date +%s) taler-wallet-cli \ --no-throttle \ --wallet-db="$WALLET_DB" \ handle-uri "${PAY_URL}" \ -y \ 2> wallet-pay1.err > wallet-pay1.log NOW2=$(date +%s) echo " OK (took $(( NOW2 - NOW)) secs )" STATUS=$(curl "http://localhost:9966/private/orders/${ORDER_ID}" \ -w "%{http_code}" -s -o "$LAST_RESPONSE") if [ "$STATUS" != "200" ] then cat "$LAST_RESPONSE" exit_fail "Expected 200 ok, after pay. got: $STATUS" fi ORDER_STATUS=$(jq -r .order_status < "$LAST_RESPONSE") if [ "$ORDER_STATUS" != "paid" ] then cat "$LAST_RESPONSE" exit_fail "Expected 'paid'. got: $ORDER_STATUS" fi echo -n "Updating product..." PRODUCT_DATA=$(echo "$MANAGED_PRODUCT_TEMPLATE" | jq 'del(.product_id) | . + {"total_stock": (.total_stock + 2) }') STATUS=$(curl 'http://localhost:9966/private/products/3' -X PATCH \ -d "$PRODUCT_DATA" \ -w "%{http_code}" -s -o "$LAST_RESPONSE") if [ "$STATUS" != "204" ] then cat "$LAST_RESPONSE" exit_fail "Expected 204, updating product. got: $STATUS" fi echo " OK" exit 0