diff options
Diffstat (limited to 'src/testing/test_merchant_transfer_tracking.sh')
-rwxr-xr-x | src/testing/test_merchant_transfer_tracking.sh | 95 |
1 files changed, 63 insertions, 32 deletions
diff --git a/src/testing/test_merchant_transfer_tracking.sh b/src/testing/test_merchant_transfer_tracking.sh index 6ac079f3..cba85d12 100755 --- a/src/testing/test_merchant_transfer_tracking.sh +++ b/src/testing/test_merchant_transfer_tracking.sh @@ -20,19 +20,30 @@ set -eu -echo "Re-initializing database (needed for current libeufin)" # FIXME-MS: enable idempotency AND db-reset! -dropdb talercheck || true -createdb talercheck +# 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/taler-bank-access/" +else + ACCOUNT="exchange-account-1" + WIRE_METHOD="iban" + BANK_FLAGS="-ns -d $WIRE_METHOD -u $ACCOUNT" + BANK_URL="http://localhost:18082/demobanks/default/access-api/" +fi . setup.sh # Launch system. -setup -c "test_template.conf" -enms -u "exchange-account-1" -d "iban" -LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX) -WALLET_DB=$(mktemp test_wallet.json-XXXXXX) +setup -c "test_template.conf" \ + -em \ + $BANK_FLAGS +LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) +WALLET_DB=$(mktemp -p "${TMPDIR:-/tmp}" test_wallet.json-XXXXXX) CONF="test_template.conf.edited" -#FORTYTHREE=$(get_payto_uri merchant x) -BANK_URL="http://localhost:18082/demobanks/default/" EXCHANGE_URL="http://localhost:8081/" echo -n "First prepare wallet with coins..." @@ -48,11 +59,20 @@ taler-wallet-cli \ bankAccessApiBaseUrl: $BANK_URL, exchangeBaseUrl: $EXCHANGE_URL }' \ - --arg BANK_URL "${BANK_URL}access-api/" \ + --arg BANK_URL "${BANK_URL}" \ --arg EXCHANGE_URL "$EXCHANGE_URL" )" 2>wallet-withdraw-1.err >wallet-withdraw-1.out echo -n "." -sleep 10 +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 "." # NOTE: once libeufin can do long-polling, we should # be able to reduce the delay here and run wirewatch @@ -71,8 +91,18 @@ echo " OK" # echo -n "Configuring merchant default instance ..." -TOR_PAYTO=$(get_payto_uri tor x) -GNUNET_PAYTO=$(get_payto_uri gnunet x) +if [ 1 = "$USE_FAKEBANK" ] +then + TOR_PAYTO="payto://x-taler-bank/localhost/tor?receiver-name=tor" + GNUNET_PAYTO="payto://x-taler-bank/localhost/gnunet?receiver-name=gnunet" + SURVEY_PAYTO="payto://x-taler-bank/localhost/survey?receiver-name=survey" + TUTORIAL_PAYTO="payto://x-taler-bank/localhost/tutorial?receiver-name=tutorial" +else + TOR_PAYTO=$(get_payto_uri tor x) + GNUNET_PAYTO=$(get_payto_uri gnunet x) + SURVEY_PAYTO=$(get_payto_uri survey x) + TUTORIAL_PAYTO=$(get_payto_uri tutorial x) +fi # create with 2 address STATUS=$(curl -H "Content-Type: application/json" -X POST \ @@ -88,8 +118,6 @@ fi echo "OK" echo -n "Configuring merchant test instance ..." -SURVEY_PAYTO=$(get_payto_uri survey x) -TUTORIAL_PAYTO=$(get_payto_uri tutorial x) # create with 2 address STATUS=$(curl -H "Content-Type: application/json" -X POST \ @@ -180,16 +208,27 @@ sleep 3 echo " DONE" echo -n "Obtaining wire transfer details from bank..." -# Emulating the previous pybank-based logic of getting -# the wire transfer information _via the exchange_ bank -# account. NOTE: grabbing tx == 0, since the latest -# transaction appear first in the bank's history. -BANKDATA=$(get_bankaccount_transactions exchange x | jq '.transactions[0]') -SUBJECT=$(echo "$BANKDATA" | jq -r .subject) -WTID=$(echo "$SUBJECT" | awk '{print $1}') -WURL=$(echo "$SUBJECT" | awk '{print $2}') -CREDIT_AMOUNT=$(echo "$BANKDATA" | jq -r .currency):$(echo "$BANKDATA" | jq -r .amount) -TARGET=$(echo "$BANKDATA" | jq -r .creditorIban) + +if [ 1 = "$USE_FAKEBANK" ] +then + BANKDATA="$(curl 'http://localhost:8082/exchange/history/outgoing?delta=1' -s)" + WTID=$(echo "$BANKDATA" | jq -r .outgoing_transactions[0].wtid) + WURL=$(echo "$BANKDATA" | jq -r .outgoing_transactions[0].exchange_base_url) + CREDIT_AMOUNT=$(echo "$BANKDATA" | jq -r .outgoing_transactions[0].amount) + TARGET_PAYTO=$(echo "$BANKDATA" | jq -r .outgoing_transactions[0].credit_account) + TARGET=$(echo "$TARGET_PAYTO" | awk -F = '{print $2}') +else + # Emulating the previous pybank-based logic of getting + # the wire transfer information _via the exchange_ bank + # account. NOTE: grabbing tx == 0, since the latest + # transaction appear first in the bank's history. + BANKDATA=$(get_bankaccount_transactions exchange x | jq '.transactions[0]') + SUBJECT=$(echo "$BANKDATA" | jq -r .subject) + WTID=$(echo "$SUBJECT" | awk '{print $1}') + WURL=$(echo "$SUBJECT" | awk '{print $2}') + CREDIT_AMOUNT=$(echo "$BANKDATA" | jq -r .currency):$(echo "$BANKDATA" | jq -r .amount) + TARGET=$(echo "$BANKDATA" | jq -r .creditorIban) +fi # Figure out which account got paid, in order to # resort the right (and complete: including the receiver-name) # TARGET_PAYTO @@ -199,22 +238,14 @@ fi if echo "$TUTORIAL_PAYTO" | grep -q "$TARGET" > /dev/null; then TARGET_PAYTO="$TUTORIAL_PAYTO"; fi -echo " DONE" if [ "$EXCHANGE_URL" != "$WURL" ] then exit_fail "Wrong exchange URL in subject '$SUBJECT', expected $EXCHANGE_URL" fi - echo " OK" set +e -export TARGET_PAYTO -export WURL -export WTID -export CREDIT_AMOUNT -export LAST_RESPONSE - echo -n "Notifying merchant of correct wire transfer, but on wrong instance..." #issue 6912 |