diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-04-16 10:24:11 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-04-16 10:24:11 +0200 |
commit | a4079ad642c675adf64f4d15ea0b0a5892756be4 (patch) | |
tree | 12bfca96e0be558de11e3afc8a20e33391e4026a /src | |
parent | fd72cd4793c3bad944a2fb943c984645d99c0f35 (diff) | |
download | merchant-a4079ad642c675adf64f4d15ea0b0a5892756be4.tar.gz merchant-a4079ad642c675adf64f4d15ea0b0a5892756be4.tar.bz2 merchant-a4079ad642c675adf64f4d15ea0b0a5892756be4.zip |
fix style issues, pass paramter to taler-merchant-wirewatch
Diffstat (limited to 'src')
-rwxr-xr-x | src/testing/test_merchant_wirewatch.sh | 144 |
1 files changed, 74 insertions, 70 deletions
diff --git a/src/testing/test_merchant_wirewatch.sh b/src/testing/test_merchant_wirewatch.sh index 6943e758..32c5544c 100755 --- a/src/testing/test_merchant_wirewatch.sh +++ b/src/testing/test_merchant_wirewatch.sh @@ -31,7 +31,7 @@ export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:${TALER_DB}" export LIBEUFIN_SANDBOX_ADMIN_PASSWORD="secret" export LIBEUFIN_SANDBOX_URL="http://localhost:1${NEXUS_PORT}/" -export GNUNET_PAYTO=`get_payto_uri gnunet x` +export GNUNET_PAYTO=$(get_payto_uri gnunet x) export LIBEUFIN_SANDBOX_USERNAME="admin" export LIBEUFIN_SANDBOX_PASSWORD="secret" @@ -48,17 +48,19 @@ export LIBEUFIN_NEXUS_URL="http://localhost:${NEXUS_PORT}" # These two are from taler-bank-manage-testing... # Make credit user, will be Merchant client. -CREDIT_USERNAME=`taler-config -c $CONF \ +CREDIT_USERNAME=$(taler-config -c "$CONF" \ -s "taler-merchant-wirewatch" \ - -o "USERNAME"` -CREDIT_PASSWORD=`taler-config -c $CONF \ + -o "USERNAME") +CREDIT_PASSWORD=$(taler-config -c "$CONF" \ -s "taler-merchant-wirewatch" \ - -o "PASSWORD"` + -o "PASSWORD") echo -n "Create credit user (for gnunet-merchant) at Nexus ..." export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:${TALER_DB}" -libeufin-nexus superuser "$CREDIT_USERNAME" --password="$CREDIT_PASSWORD" +libeufin-nexus \ + superuser "$CREDIT_USERNAME" \ + --password="$CREDIT_PASSWORD" echo " OK" export LIBEUFIN_NEXUS_USERNAME="$CREDIT_USERNAME" export LIBEUFIN_NEXUS_PASSWORD="$CREDIT_PASSWORD" @@ -108,16 +110,20 @@ libeufin-cli \ FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \") -echo -n "Setting FACADE URL in configuration" -taler-config -c $CONF \ +echo -n "Setting FACADE URL ${FACADE_URL} in configuration..." +taler-config -c "$CONF" \ -s "taler-merchant-wirewatch" \ -o "WIRE_GATEWAY_URL" \ -V "${FACADE_URL}" echo " OK" echo -n "First prepare wallet with coins..." -rm $WALLET_DB -taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api --expect-success 'withdrawTestBalance' \ +rm "${WALLET_DB}" +taler-wallet-cli \ + --no-throttle \ + --wallet-db=$WALLET_DB \ + api \ + --expect-success 'withdrawTestBalance' \ "$(jq -n ' { amount: "TESTKUDOS:99", @@ -127,7 +133,11 @@ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api --expect-success 'with --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 +taler-wallet-cli \ + --wallet-db=$WALLET_DB \ + run-until-done \ + 2>wallet-withdraw-finish-1.err \ + >wallet-withdraw-finish-1.out echo " OK" # @@ -135,8 +145,8 @@ echo " OK" # echo -n "Configuring merchant default instance ..." -TOR_PAYTO=`get_payto_uri tor x` -GNUNET_PAYTO=`get_payto_uri gnunet x` +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 \ @@ -147,16 +157,15 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \ if [ "$STATUS" != "204" ] then - echo 'should respond ok, instance created. got:' $STATUS - exit 1 + exit_fail "Expected 204 no content. Got: $STATUS" fi -echo OK +echo "OK" echo -n "Configuring merchant test instance ..." -SURVEY_PAYTO=`get_payto_uri survey x` -TUTORIAL_PAYTO=`get_payto_uri tutorial x` +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 \ @@ -167,10 +176,9 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \ if [ "$STATUS" != "204" ] then - echo 'should respond ok, instance created. got:' $STATUS - exit 1 + exit_fail "Expected 204 no content. Got: $STATUS" fi -echo OK +echo "OK" RANDOM_IMG='data:image/png;base64,abcdefg' @@ -182,28 +190,30 @@ STATUS=$(curl 'http://localhost:9966/instances/test/private/orders' \ if [ "$STATUS" != "200" ] then - echo 'should respond ok, order created. got:' $STATUS `cat $LAST_RESPONSE` - exit 1 + exit_fail "Expected 200 OK. Got: $STATUS " $(cat "$LAST_RESPONSE") fi -ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE` -TOKEN=`jq -e -r .token < $LAST_RESPONSE` +ORDER_ID=$(jq -e -r .order_id < $LAST_RESPONSE) +TOKEN=$(jq -e -r .token < $LAST_RESPONSE) STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}" \ -w "%{http_code}" -s -o $LAST_RESPONSE) if [ "$STATUS" != "200" ] then - echo 'should respond ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE` - exit 1 + exit_fail "Expected 200 ok. Got: $STATUS" $(cat $LAST_RESPONSE) fi -PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE` +PAY_URL=$(jq -e -r .taler_pay_uri < $LAST_RESPONSE) echo OK -NOW=`date +%s` +NOW=$(date +%s) echo -n "Pay first order ..." -taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri "${PAY_URL}" -y 2> wallet-pay1.err > wallet-pay1.log -NOW2=`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 $( echo -n $(($NOW2 - $NOW))) secs)" STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}" \ @@ -211,85 +221,83 @@ STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}" if [ "$STATUS" != "200" ] then - echo 'should respond ok, after pay. got:' $STATUS `cat $LAST_RESPONSE` - exit 1 + exit_fail "Expected 200 Ok. Got: $STATUS" $(cat $LAST_RESPONSE) fi -ORDER_STATUS=`jq -r .order_status < $LAST_RESPONSE` +ORDER_STATUS=$(jq -r .order_status < $LAST_RESPONSE) if [ "$ORDER_STATUS" != "paid" ] then - echo 'order should be paid. got:' $ORDER_STATUS `cat $LAST_RESPONSE` - exit 1 + exit_fail "Expected order status 'paid'. Got: $ORDER_STATUS" $(cat $LAST_RESPONSE) fi # # WIRE TRANSFER TO MERCHANT AND NOTIFY BACKEND # -PAY_DEADLINE=`jq -r .contract_terms.pay_deadline.t_s < $LAST_RESPONSE` -WIRE_DEADLINE=`jq -r .contract_terms.wire_transfer_deadline.t_s < $LAST_RESPONSE` +PAY_DEADLINE=$(jq -r .contract_terms.pay_deadline.t_s < $LAST_RESPONSE) +WIRE_DEADLINE=$(jq -r .contract_terms.wire_transfer_deadline.t_s < $LAST_RESPONSE) -NOW=`date +%s` +NOW=$(date +%s) -TO_SLEEP=`echo $(( $WIRE_DEADLINE - $NOW ))` -echo "waiting $TO_SLEEP secs for wire transfer" +TO_SLEEP=$(echo $(( $WIRE_DEADLINE - $NOW )) ) +echo "Waiting ${TO_SLEEP}s for wire transfer" echo -n "Perform wire transfers ..." -taler-exchange-aggregator -y -c $CONF -T ${TO_SLEEP}000000 -t -L INFO &> aggregator.log -taler-exchange-transfer -c $CONF -t -L INFO &> transfer.log +taler-exchange-aggregator \ + -y \ + -c "$CONF" \ + -T "${TO_SLEEP}000000" \ + -t \ + -L INFO &> aggregator.log +taler-exchange-transfer\ + -c "$CONF" \ + -t \ + -L INFO &> transfer.log echo " DONE" -echo -n "waiting for Nexus and Sandbox to settle the payment .." +echo -n "Waiting for Nexus and Sandbox to settle the payment ..." sleep 3 echo " DONE" echo -n "Obtaining wire transfer details from bank..." -taler-merchant-wirewatch -t -L INFO &> merchant-wirewatch.log +taler-merchant-wirewatch \ + -c "$CONF" \ + -t \ + -L INFO &> merchant-wirewatch.log echo " OK" echo -n "Fetching wire transfers of DEFAULT instance ..." - STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ -w "%{http_code}" -s -o $LAST_RESPONSE) - if [ "$STATUS" != "200" ] then jq . < $LAST_RESPONSE - exit_fail "Expected response 200 Ok. got: $STATUS" + exit_fail "Expected response 200 Ok. Got: $STATUS" fi - -TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE` - +TRANSFERS_LIST_SIZE=$(jq -r '.transfers | length' < $LAST_RESPONSE) if [ "$TRANSFERS_LIST_SIZE" != "1" ] then jq . < $LAST_RESPONSE - exit_fail "Expected one transfer. got: $TRANSFERS_LIST_SIZE" + exit_fail "Expected one transfer. Got: $TRANSFERS_LIST_SIZE" fi - -echo "OK" +echo " OK" echo -n "Fetching wire transfers of 'test' instance ..." - STATUS=$(curl 'http://localhost:9966/instances/test/private/transfers' \ -w "%{http_code}" -s -o $LAST_RESPONSE) - if [ "$STATUS" != "200" ] then jq . < $LAST_RESPONSE - exit_fail "Expected response 200 Ok. got: $STATUS" + exit_fail "Expected response 200 Ok. Got: $STATUS" fi - -TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE` - +TRANSFERS_LIST_SIZE=$(jq -r '.transfers | length' < $LAST_RESPONSE) if [ "$TRANSFERS_LIST_SIZE" != "0" ] then jq . < $LAST_RESPONSE exit_fail "Expected response ok. got: $STATUS" fi - -echo "OK" - +echo " OK" echo -n "Checking order status ..." STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}?transfer=YES" \ @@ -298,19 +306,15 @@ STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}?t if [ "$STATUS" != "200" ] then jq . < $LAST_RESPONSE - exit_fail 'should response ok, after order inquiry. got:' $STATUS `cat $LAST_RESPONSE` - exit 1 + exit_fail "Expected 200 ok. got: $STATUS" $(cat $LAST_RESPONSE) fi -WAS_WIRED=`jq -r .wired < $LAST_RESPONSE` - +WAS_WIRED=$(jq -r .wired < $LAST_RESPONSE) if [ "$WAS_WIRED" != "true" ] then jq . < $LAST_RESPONSE - echo '.wired false, expected true' - exit 1 + exit_fail "Got .wired 'false', expected 'true'" fi - echo " OK" exit 0 |