gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: Add test for double spending


From: gnunet
Subject: [taler-wallet-core] branch master updated: Add test for double spending (still fails as expected)
Date: Thu, 07 May 2020 20:34:20 +0200

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 38601a1c Add test for double spending (still fails as expected)
38601a1c is described below

commit 38601a1c63840bc85eae166f771a974e0629db28
Author: Torsten Grote <address@hidden>
AuthorDate: Thu May 7 15:33:43 2020 -0300

    Add test for double spending (still fails as expected)
---
 integrationtests/common.sh            |  6 +++++-
 integrationtests/test-base.sh         |  1 +
 integrationtests/test-double-link.sh  |  5 +----
 integrationtests/test-double-spend.sh | 28 ++++++++++++++++++++++++++++
 integrationtests/test-recoup.sh       |  4 +---
 5 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/integrationtests/common.sh b/integrationtests/common.sh
index 0104dbc9..4b42531b 100644
--- a/integrationtests/common.sh
+++ b/integrationtests/common.sh
@@ -14,7 +14,6 @@ function setup_config() {
     [[ "$(taler-merchant-httpd -v)" =~ "taler-merchant-httpd v" ]]  || 
exit_skip " MISSING"
     echo " FOUND"
 
-    trap shutdown_services ERR
     trap shutdown_services EXIT
 
     SCRIPT_NAME=$1
@@ -32,6 +31,9 @@ function setup_config() {
     export CONF=test-${SCRIPT_NAME}.conf
     cp template.conf "$CONF"
 
+    export WALLET_DB=wallet-${SCRIPT_NAME}.json
+    rm "$WALLET_DB" 2> /dev/null || true
+
     # Clean up
     DATA_DIR=$(taler-config -f -c "$CONF" -s PATHS -o TALER_HOME)
     rm -rf "$DATA_DIR" || true
@@ -142,6 +144,8 @@ function shutdown_services() {
     echo "Final clean up"
     dropdb "$TARGET_DB" >/dev/null 2>/dev/null || true
 
+    rm "$WALLET_DB" 2> /dev/null || true
+
     rm -rf "$DATA_DIR" || true
     rm "$CONF"
 }
diff --git a/integrationtests/test-base.sh b/integrationtests/test-base.sh
index 337d8b13..80ac466f 100755
--- a/integrationtests/test-base.sh
+++ b/integrationtests/test-base.sh
@@ -13,4 +13,5 @@ wait_for_services
 echo "Running wallet"
 taler-wallet-cli testing integrationtest -e "$EXCHANGE_URL" -m "$MERCHANT_URL" 
-b "$BANK_URL"
 
+echo "SUCCESS"
 exit 0
diff --git a/integrationtests/test-double-link.sh 
b/integrationtests/test-double-link.sh
index 75de484c..5522b94e 100755
--- a/integrationtests/test-double-link.sh
+++ b/integrationtests/test-double-link.sh
@@ -7,8 +7,6 @@ setup_services
 launch_services
 wait_for_services
 
-WALLET_DB=wallet-double-link.json
-
 echo "Getting pay taler:// Uri"
 PAY_URI=$(taler-wallet-cli testing gen-pay-uri -m "$MERCHANT_URL" -k sandbox 
-a "TESTKUDOS:1" -s "foo" | grep -E -o 'taler://.*')
 echo "Trying to pay without balance"
@@ -21,6 +19,5 @@ echo "Trying to pay what was paid already should throw error"
 taler-wallet-cli --wallet-db=$WALLET_DB --no-throttle handle-uri --yes 
"$PAY_URI" 2>&1 | grep -q "already paid" || exit_error "not reporting already 
paid"
 echo "Already paid properly detected"
 
-rm $WALLET_DB || true
-
+echo "SUCCESS"
 exit 0
diff --git a/integrationtests/test-double-spend.sh 
b/integrationtests/test-double-spend.sh
new file mode 100755
index 00000000..ee2a966f
--- /dev/null
+++ b/integrationtests/test-double-spend.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# Script to check that the wallet can not double spend coins and handles this 
error well
+
+source "common.sh"
+setup_config "double-spend"
+setup_services
+launch_services
+wait_for_services
+
+echo "Withdraw TESTKUDOS"
+taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing withdraw -e 
"$EXCHANGE_URL" -b "$BANK_URL" -a "TESTKUDOS:10" >/dev/null
+# Copy wallet database before spending coins
+cp "$WALLET_DB" "$WALLET_DB.bak"
+echo "Spend all the money"
+taler-wallet-cli --wallet-db="$WALLET_DB" testing test-pay -m "$MERCHANT_URL" 
-k sandbox -a "TESTKUDOS:9.5" -s "foo"
+echo "New balance:"
+taler-wallet-cli --wallet-db="$WALLET_DB" balance
+# Restore old wallet database
+mv "$WALLET_DB.bak" "$WALLET_DB"
+echo "Balance after getting old coins back:"
+taler-wallet-cli --wallet-db="$WALLET_DB" balance
+echo "Try to double-spend"
+# TODO this should probably fail more gracefully
+# "exchange_reply: { hint: 'insufficient funds', code: 1200 }
+taler-wallet-cli --wallet-db="$WALLET_DB" testing test-pay -m "$MERCHANT_URL" 
-k sandbox -a "TESTKUDOS:9.5" -s "foo"
+
+echo "SUCCESS"
+exit 0
diff --git a/integrationtests/test-recoup.sh b/integrationtests/test-recoup.sh
index 938a8506..72f7e1ad 100755
--- a/integrationtests/test-recoup.sh
+++ b/integrationtests/test-recoup.sh
@@ -14,8 +14,6 @@ source "common.sh"
 setup_config "recoup"
 
 TMP_DIR=$(mktemp -d revocation-tmp-XXXXXX)
-export WALLET_DB=wallet-revocation.wallet.json
-rm -f $WALLET_DB
 
 taler-config -c "$CONF" -s exchange -o KEYDIR -V "${TMP_DIR}/keydir/"
 taler-config -c "$CONF" -s exchange -o REVOCATION_DIR -V "${TMP_DIR}/revdir/"
@@ -173,7 +171,7 @@ taler-wallet-cli $TIMETRAVEL --wallet-db=$WALLET_DB testing 
test-pay \
                  -a "TESTKUDOS:0.02" -s "bar"
 taler-wallet-cli $TIMETRAVEL --wallet-db=$WALLET_DB run-until-done
 
-echo "Bought something with refresh-recouped coin"
+echo "SUCCESS: Bought something with refresh-recouped coin"
 
 rm -r "$TMP_DIR"
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]