merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 277301d45e96b36b749e66e6018d535ec06e67c9
parent 6de3f5c28aa25fcd0da94070f982291df280ad75
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 31 Jan 2026 12:03:29 +0100

modify test for #10943

Diffstat:
Msrc/testing/test_merchant_order_refund.sh | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 72 insertions(+), 21 deletions(-)

diff --git a/src/testing/test_merchant_order_refund.sh b/src/testing/test_merchant_order_refund.sh @@ -146,26 +146,42 @@ fi ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE") TOKEN=$(jq -e -r .token < "$LAST_RESPONSE") -STATUS=$(curl "http://localhost:9966/private/orders/${ORDER_ID}" \ - -w "%{http_code}" -s -o "$LAST_RESPONSE") - -if [ "$STATUS" != "200" ] -then - jq . < "$LAST_RESPONSE" - exit_fail "Expected 200, getting order info before claming it. got: $STATUS" -fi +RESPONSE_HEADERS=$(curl "http://localhost:9966/private/orders/${ORDER_ID}" \ + -w "%{header_json}" \ + -s \ + -o "$LAST_RESPONSE") +ETAG=$(echo "$RESPONSE_HEADERS" | jq -r .etag[0]) +ETAG_NQ=$(echo "$ETAG" | tr -d '"') PAY_URL=$(jq -e -r .taler_pay_uri < "$LAST_RESPONSE") echo "OK" +LP_START=$(date +%s) + +echo -n "Long-polling for order status change paid..." + +curl "http://localhost:9966/private/orders/${ORDER_ID}?timeout_ms=30000&lp_not_etag=${ETAG_NQ}" \ + -H "If-none-match: $ETAG" \ + -w "%{header_json}" \ + -s \ + -o "${LAST_RESPONSE}-long-poll" & +LP_PID="$!" + # # PAY THE ORDER # # set -x PAYMENT_START=$(date +%s) echo "Pay first order ${PAY_URL} ..." -taler-wallet-cli --no-throttle -V --wallet-db="$WALLET_DB" handle-uri "${PAY_URL}" -y 2> wallet-pay1.err > wallet-pay1.log +taler-wallet-cli \ + --no-throttle \ + -V \ + --wallet-db="$WALLET_DB" \ + handle-uri "${PAY_URL}" \ + -y \ + 2> wallet-pay1.err \ + > wallet-pay1.log PAYMENT_END=$(date +%s) echo " OK (payment took $(( PAYMENT_END - PAYMENT_START )) secs )" @@ -186,30 +202,53 @@ then exit_fail "Order status should be 'paid'. got: $ORDER_STATUS" fi +# Wait for long-poller +echo -e "Wait for long-poller ..." +wait $LP_PID &> /dev/null +LP_END=$(date +%s) -echo Sending refund for TESTKUDOS:1 +if (( "$LP_END" - "$LP_START" > 10 )) +then + exit_fail "Expected long-poller to return quickly. Instead took from $LP_START to $LP_END" +fi +echo " OK" + +echo -n "Sending refund for TESTKUDOS:1 ..." STATUS=$(curl "http://localhost:9966/private/orders/${ORDER_ID}/refund" \ -d '{"refund":"TESTKUDOS:1","reason":"duplicated"}' \ - -w "%{http_code}" -s -o "$LAST_RESPONSE") + -w "%{http_code}" \ + -s \ + -o "$LAST_RESPONSE") if [ "$STATUS" != "200" ] then jq . < "$LAST_RESPONSE" exit_fail "Expected 200, after refund. got: $STATUS" fi - REFUND_URI=$(jq -e -r .taler_refund_uri < "$LAST_RESPONSE") +echo " OK" REFUND_START=$(date +%s) echo "First refund order ${REFUND_URI} ..." set -x -taler-wallet-cli --no-throttle --wallet-db="$WALLET_DB" handle-uri "${REFUND_URI}" -y 2> wallet-refund1.err > wallet-refund1.log -taler-wallet-cli --no-throttle --wallet-db="$WALLET_DB" run-pending -y 2> wallet-pending-refund1.err > wallet-pending-refund1.log +taler-wallet-cli \ + --no-throttle \ + --wallet-db="$WALLET_DB" \ + handle-uri "${REFUND_URI}" \ + -y \ + 2> wallet-refund1.err \ + > wallet-refund1.log +taler-wallet-cli \ + --no-throttle \ + --wallet-db="$WALLET_DB" \ + run-until-done \ + 2> wallet-pending-refund1.err \ + > wallet-pending-refund1.log REFUND_END=$(date +%s) -echo " OK (refund1 took $(( REFUND_END - REFUND_START )) secs )" +echo " OK (refund1 took $(( REFUND_END - REFUND_START )) secs)" -echo Increasing refund for TESTKUDOS:3 +echo -n "Increasing refund for TESTKUDOS:3 ..." STATUS=$(curl "http://localhost:9966/private/orders/${ORDER_ID}/refund" \ -d '{"refund":"TESTKUDOS:5","reason":"duplicated"}' \ @@ -220,14 +259,26 @@ then jq . < "$LAST_RESPONSE" exit_fail "Expected 200, after refund. got: $STATUS" fi - REFUND_URI=$(jq -e -r .taler_refund_uri < "$LAST_RESPONSE") +echo " OK" REFUND2_START=$(date +%s) -echo "Second refund order ${REFUND_URI} ..." -taler-wallet-cli --no-throttle --wallet-db="$WALLET_DB" handle-uri "${REFUND_URI}" -y 2> wallet-refund2.err > wallet-refund2.log -taler-wallet-cli --no-throttle --wallet-db="$WALLET_DB" run-pending -y 2> wallet-pending-refund2.err > wallet-pending-refund2.log +echo -n "Second refund order ${REFUND_URI} ..." +taler-wallet-cli \ + --no-throttle \ + --wallet-db="$WALLET_DB" \ + handle-uri "${REFUND_URI}" \ + -y \ + 2> wallet-refund2.err \ + > wallet-refund2.log +taler-wallet-cli \ + --no-throttle \ + --wallet-db="$WALLET_DB" \ + run-until-done \ + 2> wallet-pending-refund2.err \ + > wallet-pending-refund2.log REFUND2_END=$(date +%s) -echo " OK (refund2 took $(( REFUND2_END - REFUND_START )) secs )" +echo " OK (refund2 took $(( REFUND2_END - REFUND_START )) secs)" +echo "TEST PASSED" exit 0