diff options
author | MS <ms@taler.net> | 2022-07-12 11:37:20 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-08-06 13:21:07 +0200 |
commit | ba23a5ced35729b579e9c3453433dd1c26fa7898 (patch) | |
tree | 959fb479d602c4977ecf5be9a58e5ca6a3288216 /src/testing/test_merchant_transfer_tracking.sh | |
parent | d6e8a1950a59cc9f4832da1b56db2249f641e89d (diff) |
towards libeufin based tests
Diffstat (limited to 'src/testing/test_merchant_transfer_tracking.sh')
-rwxr-xr-x | src/testing/test_merchant_transfer_tracking.sh | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/src/testing/test_merchant_transfer_tracking.sh b/src/testing/test_merchant_transfer_tracking.sh index 4f8cf2c5..0fee9096 100755 --- a/src/testing/test_merchant_transfer_tracking.sh +++ b/src/testing/test_merchant_transfer_tracking.sh @@ -29,7 +29,7 @@ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'withdrawTestBalance' bankBaseUrl: $BANK_URL, exchangeBaseUrl: $EXCHANGE_URL }' \ - --arg BANK_URL "$BANK_URL" \ + --arg BANK_URL "$BANK_URL/access-api/" \ --arg EXCHANGE_URL "$EXCHANGE_URL" )" 2>wallet-withdraw-1.err >wallet-withdraw-1.out taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out @@ -40,7 +40,8 @@ echo " OK" # echo -n "Configuring merchant default instance ..." - +TOR_PAYTO=`get_payto_uri tor x` +GNUNET_PAYTO=`get_payto_uri gnunet x` # create with 2 address STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ @@ -58,12 +59,17 @@ 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 \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ +<<<<<<< HEAD -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:8082/Survey","payto://x-taler-bank/localhost:8082/Tutorial"],"id":"test","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ +======= + -d "{\"auth\":{\"method\":\"external\"},\"payto_uris\":[\"$SURVEY_PAYTO\",\"$TUTORIAL_PAYTO\"],\"id\":\"test\",\"name\":\"default\",\"address\":{},\"jurisdiction\":{},\"default_max_wire_fee\":\"TESTKUDOS:1\", \"default_max_deposit_fee\":\"TESTKUDOS:1\",\"default_wire_fee_amortization\":1,\"default_wire_transfer_delay\":{\"d_ms\" : 50000},\"default_pay_delay\":{\"d_ms\": 60000}}" \ +>>>>>>> 0df2345 (towards libeufin based tests) -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] @@ -141,23 +147,31 @@ taler-exchange-aggregator -y -c $CONF -T ${TO_SLEEP}000000 -t -L INFO &> aggrega taler-exchange-transfer -c $CONF -t -L INFO &> transfer.log echo " DONE" -echo -n "Obtaining wire transfer details from bank..." +echo -n "waiting for Nexus and Sandbox to settle the payment .." +sleep 3 +echo " DONE" -# First, extract the wire transfer data from the bank. -# As there is no "nice" API, we do this by dumping the -# bank database and grabbing the 'right' wire transfer, -# which is the one outgoing from the exchange (account 2). -export BANKDATA=`taler-bank-manage -c $CONF django dumpdata 2>/dev/null | tail -n1 | jq '.[] | select(.model=="app.banktransaction")' | jq 'select(.fields.debit_account==2)'` -export SUBJECT=`echo $BANKDATA | jq -r .fields.subject` +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. +export BANKDATA=`get_bankaccount_transactions exchange x | jq '.transactions[0]'` +export SUBJECT=`echo $BANKDATA | jq -r .subject` export WTID=`echo $SUBJECT | awk '{print $1}'` export WURL=`echo $SUBJECT | awk '{print $2}'` -export CREDIT_AMOUNT=`echo $BANKDATA | jq -r .fields.amount` -export TARGET=`echo $BANKDATA | jq -r .fields.credit_account` -# 'TARGET' is now the numeric value of the account, we need to get the actual account *name*: -BANKADATA=`taler-bank-manage -c $CONF django dumpdata 2>/dev/null | tail -n1 | jq '.[] | select(.model=="auth.user")' | jq 'select(.pk=='$TARGET')'` -ACCOUNT_NAME=`echo $BANKADATA | jq -r .fields.username` -TARGET_PAYTO="payto://x-taler-bank/localhost:8082/$ACCOUNT_NAME" - +export CREDIT_AMOUNT="`echo $BANKDATA | jq -r .currency`:`echo $BANKDATA | jq -r .amount`" +export TARGET=`echo $BANKDATA | jq -r .creditorIban` +# Figure out which account got payed, in order to +# resort the right (and complete: including the receiver-name) +# TARGET_PAYTO +if `echo $SURVEY_PAYTO | grep -q $TARGET`; then + export TARGET_PAYTO=$SURVEY_PAYTO; +fi +if `echo $TUTORIAL_PAYTO | grep -q $TARGET`; then + export TARGET_PAYTO=$TUTORIAL_PAYTO; +fi +echo " DONE" if [ "$EXCHANGE_URL" != "$WURL" ] then exit_fail "Wrong exchange URL in subject '$SUBJECT', expected $EXCHANGE_URL" @@ -178,7 +192,7 @@ echo -n "Notifying merchant of correct wire transfer, but on wrong instance..." #issue 6912 #here we are notifying the transfer into a wrong instance (default) and the payto_uri of the default instance STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ - -d '{"credit_amount":"'$CREDIT_AMOUNT'","wtid":"'$WTID'","payto_uri":"payto://x-taler-bank/localhost:8082/Tor","exchange_url":"'$WURL'"}' \ + -d "{\"credit_amount\":\"$CREDIT_AMOUNT\",\"wtid\":\"$WTID\",\"payto_uri\":\"$TOR_PAYTO\",\"exchange_url\":\"$WURL\"}" \ -m 3 \ -w "%{http_code}" -s -o $LAST_RESPONSE) |