summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-05-27 19:31:23 +0200
committerChristian Grothoff <christian@grothoff.org>2023-05-27 19:31:26 +0200
commit1bfaf0a19f664c313e887cc25cfb80891cd66d3a (patch)
treea9c4d424f919e58fead0bc54c85263a29f0a2124
parentdb344e1a2abbe932ec0efb67ab6ff5995c31e598 (diff)
downloadmerchant-1bfaf0a19f664c313e887cc25cfb80891cd66d3a.tar.gz
merchant-1bfaf0a19f664c313e887cc25cfb80891cd66d3a.tar.bz2
merchant-1bfaf0a19f664c313e887cc25cfb80891cd66d3a.zip
clean up test logic a bit
-rwxr-xr-xsrc/testing/test_merchant_reserve_creation.sh35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/testing/test_merchant_reserve_creation.sh b/src/testing/test_merchant_reserve_creation.sh
index cf231dd5..753b5e41 100755
--- a/src/testing/test_merchant_reserve_creation.sh
+++ b/src/testing/test_merchant_reserve_creation.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is part of TALER
-# Copyright (C) 2014-2021 Taler Systems SA
+# 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
@@ -25,6 +25,9 @@ echo -n "Configuring merchant instance ..."
# create instance
FORTYTHREE=`get_payto_uri fortythree x`
+echo -n "."
+bash
+
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
http://localhost:9966/management/instances \
@@ -33,8 +36,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'Expected 204, instance created. Got instead: ' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. Got instead: $STATUS"
fi
echo "OK"
@@ -45,8 +47,7 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves' \
if [ "$STATUS" != "200" ]
then
- echo 'Expected 200, reserve created. Got instead: ' $STATUS
- exit 1
+ exit_fail "Expected 200, reserve created. Got instead: $STATUS"
fi
echo "OK"
@@ -60,9 +61,8 @@ FUNDED=`jq -r '.merchant_initial_amount == .exchange_initial_amount' < $LAST_RES
if [ "$FUNDED" != "false" ]
then
- echo 'Should not yet be funded if we just created. Got:' $STATUS 'is founded: ' $FUNDED
cat $LAST_RESPONSE
- exit 1
+ exit_fail "Should not yet be funded if we just created. Got: $STATUS is founded: $FUNDED"
fi
@@ -94,13 +94,15 @@ taler-exchange-wirewatch -c $CONF -t -L INFO &> taler-exchange-wirewatch.log
STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'$RESERVE_PUB \
-w "%{http_code}" -s -o $LAST_RESPONSE)
+export LAST_RESPONSE
+
+bash
FUNDED=`jq -r '.merchant_initial_amount == .exchange_initial_amount' < $LAST_RESPONSE`
if [ "$FUNDED" != "true" ]
then
- echo 'should be funded. got:' $STATUS 'is founded: ' $FUNDED
cat $LAST_RESPONSE
- exit 1
+ exit_fail "should be funded. got: $STATUS is founded: $FUNDED"
fi
@@ -112,8 +114,7 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'$RESERV
if [ "$STATUS" != "200" ]
then
- echo 'should respond failed, we did not fund yet. got:' $STATUS
- exit 1
+ exit_fail "should respond failed, we did not fund yet. got: $STATUS"
fi
echo OK
@@ -126,9 +127,8 @@ TIPS_SIZE=`jq -r ".tips | length" < $LAST_RESPONSE`
if [ "$TIPS_SIZE" != "1" ]
then
- echo 'should respond 1, just 1 tip. got:' $TIPS_SIZE
cat $LAST_RESPONSE
- exit 1
+ exit_fail "should respond 1, just 1 tip. got: $TIPS_SIZE"
fi
TIP_ID=`jq -r .tips[0].tip_id < $LAST_RESPONSE`
@@ -142,9 +142,8 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/tips/'$TIP_ID \
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, tip found. got:' $STATUS
cat $LAST_RESPONSE
- exit 1
+ exit_fail "should respond ok, tip found. got: $STATUS"
fi
echo -n " ... "
@@ -154,9 +153,8 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/tips/'$TIP_ID'?pi
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, tip found. got:' $STATUS
cat $LAST_RESPONSE
- exit 1
+ exit_fail "should respond ok, tip found. got: $STATUS"
fi
echo OK
@@ -169,8 +167,7 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves' \
if [ "$STATUS" != "400" ]
then
- echo 'should respond invalid, bad currency. got:' $STATUS
- exit 1
+ exit_fail 'Should respond invalid, bad currency. got: $STATUS"
fi
echo "FAILED (which is ok)"