gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated (d585c409 -> 0d5a3d7


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (d585c409 -> 0d5a3d7b)
Date: Tue, 08 Oct 2019 18:49:27 +0200

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

grothoff pushed a change to branch master
in repository exchange.

    from d585c409 add test for missing wire transfer for reserve closure
     new bde4c742 add logic to generate fresh database
     new 0d5a3d7b more comprehensive test-auditor.sh, including 
generate-auditor-basedb now

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/auditor/auditor.conf               |   4 +-
 src/auditor/generate-auditor-basedb.sh |  45 ++-
 src/auditor/test-auditor.sh            | 618 ++++++++++++++++++++-------------
 src/include/taler_signatures.h         |  14 +
 4 files changed, 429 insertions(+), 252 deletions(-)

diff --git a/src/auditor/auditor.conf b/src/auditor/auditor.conf
index a099f9b7..f90d4dbb 100644
--- a/src/auditor/auditor.conf
+++ b/src/auditor/auditor.conf
@@ -1,7 +1,7 @@
 # This file is in the public domain.
 #
 [auditor]
-# Which database backend do we use for the auditor? 
+# Which database backend do we use for the auditor?
 DB = postgres
 
 # Option specifying which amount is considered 'tiny'
@@ -26,4 +26,4 @@ UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
 UNIXPATH_MODE = 660
 
 # HTTP port the auditor listens to
-PORT = 8082
+PORT = 8083
diff --git a/src/auditor/generate-auditor-basedb.sh 
b/src/auditor/generate-auditor-basedb.sh
index 60bb644a..0fe20570 100755
--- a/src/auditor/generate-auditor-basedb.sh
+++ b/src/auditor/generate-auditor-basedb.sh
@@ -1,7 +1,10 @@
 #!/bin/bash
 # Script to generate the basic database for auditor
 # testing from a 'correct' interaction between exchange,
-# wallet and merchant.  Creates 'auditor-basedb.sql'.
+# wallet and merchant.
+#
+# Creates $BASEDB.sql, $BASEDB.fees and $BASEDB.mpub.
+# Default $BASEDB is "auditor-basedb", override via $1.
 #
 # Currently must be run online as it interacts with
 # bank.test.taler.net; also requires the wallet CLI
@@ -38,7 +41,7 @@ cp generate-auditor-basedb-template.conf $CONF
 echo -n "Testing for taler-bank-manage"
 taler-bank-manage -h >/dev/null </dev/null || exit_skip " MISSING"
 echo " FOUND"
-echo "Testing for taler-wallet-cli"
+echo -n "Testing for taler-wallet-cli"
 taler-wallet-cli -h >/dev/null </dev/null || exit_skip " MISSING"
 echo " FOUND"
 
@@ -91,12 +94,32 @@ taler-bank-manage -c $CONF serve-http &
 taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
 taler-merchant-httpd -c $CONF 2> taler-merchant-httpd.log &
 taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
-
-
-# FIXME: also launch taler-auditor-httpd!
-
-# FIXME: interactive test here instead of waiting!
-sleep 10
+taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log &
+
+# Wait for all services to be available
+for n in `seq 1 20`
+do
+    echo -n "."
+    sleep 0.1
+    OK=0
+    # exchange
+    wget http://localhost:8081/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    # merchant
+    wget http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    # bank
+    wget http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    # Auditor
+    wget http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    OK=1
+    break
+done
+
+if [ 1 != $OK ]
+then
+    kill `jobs -p`
+    exit_skip "Failed to launch services"
+fi
+echo " DONE"
 
 # run wallet CLI
 echo "Running wallet"
@@ -120,3 +143,9 @@ dropdb $TARGET_DB
 rm -f e2a.dat a2e.dat
 rm -rf $DATA_DIR || true
 rm $CONF
+
+echo "====================================="
+echo "  Finished generation of $BASEDB"
+echo "====================================="
+
+exit 0
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 23c2fafe..7e9f826d 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -216,10 +216,7 @@ echo -n "Check for lag detection... "
 # re-generating the test database as we do not
 # report lag of less than 1h (see GRACE_PERIOD in
 # taler-wire-auditor.c)
-AGE=`stat -c %Y ${BASEDB}.fees`
-NOW=`date +%s`
-DELTA=`expr $NOW - $AGE`
-if [ $DELTA -gt 3600 ]
+if [ $DATABASE_AGE -gt 3600 ]
 then
     jq -e .lag_details[0] < test-wire-audit.json > /dev/null || exit_fail "Lag 
not detected in run without aggregator at age $DELTA"
 
@@ -230,7 +227,7 @@ then
     fi
     echo "PASS"
 else
-    echo "SKIP"
+    echo "SKIP (database too new)"
 fi
 
 
@@ -805,32 +802,43 @@ function test_14() {
 
 echo "===========14: wire-fee disagreement==========="
 
+# Check wire transfer lag reported (no aggregator!)
+# NOTE: This test is EXPECTED to fail for ~1h after
+# re-generating the test database as we do not
+# report lag of less than 1h (see GRACE_PERIOD in
+# taler-wire-auditor.c)
+if [ $DATABASE_AGE -gt 3600 ]
+then
 
-# Wire fees are only checked/generated once there are
-# actual outgoing wire transfers, so we need to run the
-# aggregator here.
-pre_audit aggregator
-echo "UPDATE wire_fee SET wire_fee_frac=100;" | psql -Aqt $DB
-audit_only
-post_audit
+    # Wire fees are only checked/generated once there are
+    # actual outgoing wire transfers, so we need to run the
+    # aggregator here.
+    pre_audit aggregator
+    echo "UPDATE wire_fee SET wire_fee_frac=100;" | psql -Aqt $DB
+    audit_only
+    post_audit
 
-echo -n "Testing inconsistency detection... "
-TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
-if test "x$TABLE" != "xwire-fee"
-then
-    exit_fail "Reported table wrong: $TABLE"
-fi
-DIAG=`jq -r .row_inconsistencies[0].diagnostic < test-audit.json`
-if test "x$DIAG" != "xwire fee signature invalid at given time"
-then
-    exit_fail "Reported diagnostic wrong: $DIAG"
-fi
-echo PASS
+    echo -n "Testing inconsistency detection... "
+    TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
+    if test "x$TABLE" != "xwire-fee"
+    then
+        exit_fail "Reported table wrong: $TABLE"
+    fi
+    DIAG=`jq -r .row_inconsistencies[0].diagnostic < test-audit.json`
+    if test "x$DIAG" != "xwire fee signature invalid at given time"
+    then
+        exit_fail "Reported diagnostic wrong: $DIAG"
+    fi
+    echo PASS
 
-# cannot easily undo aggregator, hence full reload
-echo -n "Reloading database ..."
-full_reload
-echo "DONE"
+    # cannot easily undo aggregator, hence full reload
+    echo -n "Reloading database ..."
+    full_reload
+    echo "DONE"
+
+else
+    echo "Test skipped (database too new)"
+fi
 
 }
 
@@ -839,26 +847,40 @@ echo "DONE"
 # Test where h_wire in the deposit table is wrong
 function test_15() {
 echo "===========15: deposit wire hash wrong================="
-# Modify h_wire hash, so it is inconsistent with 'wire'
-echo "UPDATE deposits SET 
h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f52188c3c01d9005b7d755c397e92624f09cfa709104b3b65605fe5130c90d7e1b7ee30f8fc570f39c16b853'
 WHERE deposit_serial_id=1" | psql -Aqt $DB
 
-# The auditor checks h_wire consistency only for
-# coins where the wire transfer has happened, hence
-# run aggregator first to get this test to work.
-run_audit aggregator
+# Check wire transfer lag reported (no aggregator!)
 
-echo -n "Testing inconsistency detection... "
-TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
-if test "x$TABLE" != "xaggregation" -a "x$TABLE" != "xdeposits"
+# NOTE: This test is EXPECTED to fail for ~1h after
+# re-generating the test database as we do not
+# report lag of less than 1h (see GRACE_PERIOD in
+# taler-wire-auditor.c)
+if [ $DATABASE_AGE -gt 3600 ]
 then
-    exit_fail "Reported table wrong: $TABLE"
-fi
-echo PASS
 
-# cannot easily undo aggregator, hence full reload
-echo -n "Reloading database ..."
-full_reload
-echo "DONE"
+    # Modify h_wire hash, so it is inconsistent with 'wire'
+    echo "UPDATE deposits SET 
h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f52188c3c01d9005b7d755c397e92624f09cfa709104b3b65605fe5130c90d7e1b7ee30f8fc570f39c16b853'
 WHERE deposit_serial_id=1" | psql -Aqt $DB
+
+    # The auditor checks h_wire consistency only for
+    # coins where the wire transfer has happened, hence
+    # run aggregator first to get this test to work.
+    run_audit aggregator
+
+    echo -n "Testing inconsistency detection... "
+    TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
+    if test "x$TABLE" != "xaggregation" -a "x$TABLE" != "xdeposits"
+    then
+        exit_fail "Reported table wrong: $TABLE"
+    fi
+    echo PASS
+
+    # cannot easily undo aggregator, hence full reload
+    echo -n "Reloading database ..."
+    full_reload
+    echo "DONE"
+
+else
+    echo "Test skipped (database too new)"
+fi
 }
 
 
@@ -866,79 +888,92 @@ echo "DONE"
 function test_16() {
 echo "===========16: incorrect wire_out amount================="
 
-# First, we need to run the aggregator so we even
-# have a wire_out to modify.
-pre_audit aggregator
+# Check wire transfer lag reported (no aggregator!)
+# NOTE: This test is EXPECTED to fail for ~1h after
+# re-generating the test database as we do not
+# report lag of less than 1h (see GRACE_PERIOD in
+# taler-wire-auditor.c)
+if [ $DATABASE_AGE -gt 3600 ]
+then
 
-# Modify wire amount, such that it is inconsistent with 'aggregation'
-# (exchange account is #2, so the logic below should select the outgoing
-# wire transfer):
-OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 
ORDER BY id LIMIT 1;" | psql $DB -Aqt`
-OLD_AMOUNT=`echo "SELECT amount FROM app_banktransaction WHERE 
id='${OLD_ID}';" | psql $DB -Aqt`
-NEW_AMOUNT="TESTKUDOS:50"
-echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE 
id='${OLD_ID}';" | psql -Aqt $DB
+    # First, we need to run the aggregator so we even
+    # have a wire_out to modify.
+    pre_audit aggregator
 
-audit_only
+    # Modify wire amount, such that it is inconsistent with 'aggregation'
+    # (exchange account is #2, so the logic below should select the outgoing
+    # wire transfer):
+    OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 
ORDER BY id LIMIT 1;" | psql $DB -Aqt`
+    OLD_AMOUNT=`echo "SELECT amount FROM app_banktransaction WHERE 
id='${OLD_ID}';" | psql $DB -Aqt`
+    NEW_AMOUNT="TESTKUDOS:50"
+    echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE 
id='${OLD_ID}';" | psql -Aqt $DB
 
-echo -n "Testing inconsistency detection... "
+    audit_only
 
-AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < 
test-wire-audit.json`
-if test "x$AMOUNT" != "x$OLD_AMOUNT"
-then
-    exit_fail "Reported justified amount wrong: $AMOUNT"
-fi
-AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < 
test-wire-audit.json`
-if test "x$AMOUNT" != "x$NEW_AMOUNT"
-then
-    exit_fail "Reported wired amount wrong: $AMOUNT"
-fi
-TOTAL_AMOUNT=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
-if test "x$TOTAL_AMOUNT" != "xTESTKUDOS:0"
-then
-    exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT"
-fi
-TOTAL_AMOUNT=`jq -r .total_wire_out_delta_plus < test-wire-audit.json`
-if test "x$TOTAL_AMOUNT" = "xTESTKUDOS:0"
-then
-    exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
-fi
-echo PASS
+    echo -n "Testing inconsistency detection... "
 
-echo "Second modification: wire nothing"
-NEW_AMOUNT="TESTKUDOS:0"
-echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE 
id='${OLD_ID}';" | psql -Aqt $DB
+    AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < 
test-wire-audit.json`
+    if test "x$AMOUNT" != "x$OLD_AMOUNT"
+    then
+        exit_fail "Reported justified amount wrong: $AMOUNT"
+    fi
+    AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < 
test-wire-audit.json`
+    if test "x$AMOUNT" != "x$NEW_AMOUNT"
+    then
+        exit_fail "Reported wired amount wrong: $AMOUNT"
+    fi
+    TOTAL_AMOUNT=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
+    if test "x$TOTAL_AMOUNT" != "xTESTKUDOS:0"
+    then
+        exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT"
+    fi
+    TOTAL_AMOUNT=`jq -r .total_wire_out_delta_plus < test-wire-audit.json`
+    if test "x$TOTAL_AMOUNT" = "xTESTKUDOS:0"
+    then
+        exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
+    fi
+    echo PASS
 
-audit_only
+    echo "Second modification: wire nothing"
+    NEW_AMOUNT="TESTKUDOS:0"
+    echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE 
id='${OLD_ID}';" | psql -Aqt $DB
 
-echo -n "Testing inconsistency detection... "
+    audit_only
 
-AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < 
test-wire-audit.json`
-if test "x$AMOUNT" != "x$OLD_AMOUNT"
-then
-    exit_fail "Reported justified amount wrong: $AMOUNT"
-fi
-AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < 
test-wire-audit.json`
-if test "x$AMOUNT" != "x$NEW_AMOUNT"
-then
-    exit_fail "Reported wired amount wrong: $AMOUNT"
-fi
-TOTAL_AMOUNT=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
-if test "x$TOTAL_AMOUNT" != "x$OLD_AMOUNT"
-then
-    exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT (wanted 
$OLD_AMOUNT)"
-fi
-TOTAL_AMOUNT=`jq -r .total_wire_out_delta_plus < test-wire-audit.json`
-if test "x$TOTAL_AMOUNT" != "xTESTKUDOS:0"
-then
-    exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
-fi
-echo PASS
+    echo -n "Testing inconsistency detection... "
 
-post_audit
+    AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < 
test-wire-audit.json`
+    if test "x$AMOUNT" != "x$OLD_AMOUNT"
+    then
+        exit_fail "Reported justified amount wrong: $AMOUNT"
+    fi
+    AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < 
test-wire-audit.json`
+    if test "x$AMOUNT" != "x$NEW_AMOUNT"
+    then
+        exit_fail "Reported wired amount wrong: $AMOUNT"
+    fi
+    TOTAL_AMOUNT=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
+    if test "x$TOTAL_AMOUNT" != "x$OLD_AMOUNT"
+    then
+        exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT 
(wanted $OLD_AMOUNT)"
+    fi
+    TOTAL_AMOUNT=`jq -r .total_wire_out_delta_plus < test-wire-audit.json`
+    if test "x$TOTAL_AMOUNT" != "xTESTKUDOS:0"
+    then
+        exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
+    fi
+    echo PASS
 
+    post_audit
+
+    # cannot easily undo aggregator, hence full reload
+    echo -n "Reloading database ..."
+    full_reload
+    echo "DONE"
+else
+    echo "Test skipped (database too new)"
+fi
 
-# Undo
-echo "UPDATE app_banktransaction SET amount='${OLD_AMOUNT}' WHERE 
id='${OLD_ID}';" | psql -Aqt $DB
 }
 
 
@@ -948,38 +983,53 @@ echo "UPDATE app_banktransaction SET 
amount='${OLD_AMOUNT}' WHERE id='${OLD_ID}'
 function test_17() {
 echo "===========17: incorrect wire_out timestamp================="
 
-# First, we need to run the aggregator so we even
-# have a wire_out to modify.
-pre_audit aggregator
+# Check wire transfer lag reported (no aggregator!)
+# NOTE: This test is EXPECTED to fail for ~1h after
+# re-generating the test database as we do not
+# report lag of less than 1h (see GRACE_PERIOD in
+# taler-wire-auditor.c)
+if [ $DATABASE_AGE -gt 3600 ]
+then
 
-# Modify wire amount, such that it is inconsistent with 'aggregation'
-# (exchange account is #2, so the logic below should select the outgoing
-# wire transfer):
-OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 
ORDER BY id LIMIT 1;" | psql $DB -Aqt`
-OLD_DATE=`echo "SELECT date FROM app_banktransaction WHERE id='${OLD_ID}';" | 
psql $DB -Aqt`
-# Note: need - interval '1h' as "NOW()" may otherwise be exactly what is 
already in the DB
-# (due to rounding, if this machine is fast...)
-echo "UPDATE app_banktransaction SET date=NOW()- interval '1 hour' WHERE 
id='${OLD_ID}';" | psql -Aqt $DB
+    # First, we need to run the aggregator so we even
+    # have a wire_out to modify.
+    pre_audit aggregator
 
-audit_only
-post_audit
+    # Modify wire amount, such that it is inconsistent with 'aggregation'
+    # (exchange account is #2, so the logic below should select the outgoing
+    # wire transfer):
+    OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 
ORDER BY id LIMIT 1;" | psql $DB -Aqt`
+    OLD_DATE=`echo "SELECT date FROM app_banktransaction WHERE 
id='${OLD_ID}';" | psql $DB -Aqt`
+    # Note: need - interval '1h' as "NOW()" may otherwise be exactly what is 
already in the DB
+    # (due to rounding, if this machine is fast...)
+    echo "UPDATE app_banktransaction SET date=NOW()- interval '1 hour' WHERE 
id='${OLD_ID}';" | psql -Aqt $DB
 
-echo -n "Testing inconsistency detection... "
-TABLE=`jq -r .row_minor_inconsistencies[0].table < test-wire-audit.json`
-if test "x$TABLE" != "xwire_out"
-then
-    exit_fail "Reported table wrong: $TABLE"
-fi
-DIAG=`jq -r .row_minor_inconsistencies[0].diagnostic < test-wire-audit.json`
-DIAG=`echo "$DIAG" | awk '{print $1 " " $2 " " $3}'`
-if test "x$DIAG" != "xexecution date missmatch"
-then
-    exit_fail "Reported diagnostic wrong: $DIAG"
+    audit_only
+    post_audit
+
+    echo -n "Testing inconsistency detection... "
+    TABLE=`jq -r .row_minor_inconsistencies[0].table < test-wire-audit.json`
+    if test "x$TABLE" != "xwire_out"
+    then
+        exit_fail "Reported table wrong: $TABLE"
+    fi
+    DIAG=`jq -r .row_minor_inconsistencies[0].diagnostic < 
test-wire-audit.json`
+    DIAG=`echo "$DIAG" | awk '{print $1 " " $2 " " $3}'`
+    if test "x$DIAG" != "xexecution date missmatch"
+    then
+        exit_fail "Reported diagnostic wrong: $DIAG"
+    fi
+    echo PASS
+
+    # cannot easily undo aggregator, hence full reload
+    echo -n "Reloading database ..."
+    full_reload
+    echo "DONE"
+
+else
+    echo "Test skipped (database too new)"
 fi
-echo PASS
 
-# Undo
-echo "UPDATE app_banktransaction SET date='${OLD_DATE}' WHERE id='${OLD_ID}';" 
| psql -Aqt $DB
 }
 
 
@@ -1040,44 +1090,57 @@ echo "DONE"
 function test_19() {
 echo "===========19: outgoing wire subject malformed================="
 
-# Need to first run the aggregator so the outgoing transfer exists
-pre_audit aggregator
+# Check wire transfer lag reported (no aggregator!)
+# NOTE: This test is EXPECTED to fail for ~1h after
+# re-generating the test database as we do not
+# report lag of less than 1h (see GRACE_PERIOD in
+# taler-wire-auditor.c)
+if [ $DATABASE_AGE -gt 3600 ]
+then
 
-# Generate mal-formed wire transfer subject
-SUBJECT=YDVD2XBQT62553Z2TX8MM
-# Account #2 = exchange, pick outgoing transfer
-OLD_SUBJECT=`echo "SELECT subject FROM app_banktransaction WHERE 
debit_account_id=2;" | psql $DB -Aqt`
-echo "UPDATE app_banktransaction SET subject='${SUBJECT}' WHERE 
debit_account_id=2;" | psql -Aqt $DB
+    # Need to first run the aggregator so the outgoing transfer exists
+    pre_audit aggregator
 
-audit_only
-post_audit
+    # Generate mal-formed wire transfer subject
+    SUBJECT=YDVD2XBQT62553Z2TX8MM
+    # Account #2 = exchange, pick outgoing transfer
+    OLD_SUBJECT=`echo "SELECT subject FROM app_banktransaction WHERE 
debit_account_id=2;" | psql $DB -Aqt`
+    echo "UPDATE app_banktransaction SET subject='${SUBJECT}' WHERE 
debit_account_id=2;" | psql -Aqt $DB
 
+    audit_only
+    post_audit
 
-echo -n "Testing wire transfer subject malformed detection... "
 
-DIAGNOSTIC=`jq -r .wire_format_inconsistencies[0].diagnostic < 
test-wire-audit.json`
-WANT="malformed subject \`${SUBJECT}'"
-if test "x$DIAGNOSTIC" != "x$WANT"
-then
-    exit_fail "Reported diagnostic: $DIAGNOSTIC, wanted $WANT"
-fi
-jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null 
|| exit_fail "Falsly claimed wire transfer not detected"
+    echo -n "Testing wire transfer subject malformed detection... "
 
-DELTA=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
-if test $DELTA == "TESTKUDOS:0"
-then
-    exit_fail "Expected total wire delta minus wrong, got $DELTA"
-fi
-DELTA=`jq -r .total_wire_format_amount < test-wire-audit.json`
-if test $DELTA == "TESTKUDOS:0"
-then
-    exit_fail "Expected total format amount wrong, got $DELTA"
-fi
+    DIAGNOSTIC=`jq -r .wire_format_inconsistencies[0].diagnostic < 
test-wire-audit.json`
+    WANT="malformed subject \`${SUBJECT}'"
+    if test "x$DIAGNOSTIC" != "x$WANT"
+    then
+        exit_fail "Reported diagnostic: $DIAGNOSTIC, wanted $WANT"
+    fi
+    jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > 
/dev/null || exit_fail "Falsly claimed wire transfer not detected"
 
-echo "PASS"
+    DELTA=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
+    if test $DELTA == "TESTKUDOS:0"
+    then
+        exit_fail "Expected total wire delta minus wrong, got $DELTA"
+    fi
+    DELTA=`jq -r .total_wire_format_amount < test-wire-audit.json`
+    if test $DELTA == "TESTKUDOS:0"
+    then
+        exit_fail "Expected total format amount wrong, got $DELTA"
+    fi
 
-# Undo
-echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE 
debit_account_id=2;" | psql -Aqt $DB
+    echo "PASS"
+
+    # cannot easily undo aggregator, hence full reload
+    echo -n "Reloading database ..."
+    full_reload
+    echo "DONE"
+else
+    echo "Test skipped (database too new)"
+fi
 }
 
 
@@ -1085,34 +1148,46 @@ echo "UPDATE app_banktransaction SET 
subject='${OLD_SUBJECT}' WHERE debit_accoun
 function test_20() {
 echo "===========20: reserve closure done properly ================="
 
-OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
-OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
-RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
-OLD_EXP=`echo "SELECT expiration_date FROM reserves WHERE 
reserve_pub='${RES_PUB}';" | psql $DB -Aqt`
-VAL_DELTA=1
-NEW_TIME=`expr $OLD_TIME - 3024000000000`  # 5 weeks
-NEW_EXP=`expr $OLD_EXP - 3024000000000`  # 5 weeks
-NEW_CREDIT=`expr $OLD_VAL + $VAL_DELTA`
-echo "UPDATE reserves_in SET 
execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE 
reserve_in_serial_id=1;" | psql -Aqt $DB
-echo "UPDATE reserves SET 
current_balance_val=${VAL_DELTA}+current_balance_val,expiration_date='${NEW_EXP}'
 WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
+# NOTE: This test is EXPECTED to fail for ~1h after
+# re-generating the test database as we do not
+# report lag of less than 1h (see GRACE_PERIOD in
+# taler-wire-auditor.c)
+if [ $DATABASE_AGE -gt 3600 ]
+then
 
-# Need to run with the aggregator so the reserve closure happens
-run_audit aggregator
+    OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
+    OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
+    RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
+    OLD_EXP=`echo "SELECT expiration_date FROM reserves WHERE 
reserve_pub='${RES_PUB}';" | psql $DB -Aqt`
+    VAL_DELTA=1
+    NEW_TIME=`expr $OLD_TIME - 3024000000000`  # 5 weeks
+    NEW_EXP=`expr $OLD_EXP - 3024000000000`  # 5 weeks
+    NEW_CREDIT=`expr $OLD_VAL + $VAL_DELTA`
+    echo "UPDATE reserves_in SET 
execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE 
reserve_in_serial_id=1;" | psql -Aqt $DB
+    echo "UPDATE reserves SET 
current_balance_val=${VAL_DELTA}+current_balance_val,expiration_date='${NEW_EXP}'
 WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
 
-echo -n "Testing reserve closure was done correctly... "
+    # Need to run with the aggregator so the reserve closure happens
+    run_audit aggregator
 
-jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null && 
exit_fail "Unexpected reserve not closed inconsistency detected"
+    echo -n "Testing reserve closure was done correctly... "
 
-echo "PASS"
+    jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null 
&& exit_fail "Unexpected reserve not closed inconsistency detected"
 
-echo -n "Testing no bogus transfers detected... "
-jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null 
&& exit_fail "Unexpected wire out inconsistency detected in run with reserve 
closure"
+    echo "PASS"
 
-echo "PASS"
+    echo -n "Testing no bogus transfers detected... "
+    jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > 
/dev/null && exit_fail "Unexpected wire out inconsistency detected in run with 
reserve closure"
 
-# Undo
-echo "UPDATE reserves_in SET 
execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE 
reserve_in_serial_id=1;" | psql -Aqt $DB
-echo "UPDATE reserves SET 
expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA}
 WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
+    echo "PASS"
+
+    # cannot easily undo aggregator, hence full reload
+    echo -n "Reloading database ..."
+    full_reload
+    echo "DONE"
+
+else
+    echo "Test skipped (database too new)"
+fi
 }
 
 
@@ -1150,47 +1225,59 @@ echo "UPDATE reserves_in SET 
execution_date='${OLD_TIME}',credit_val=${OLD_VAL}
 function test_22() {
 echo "===========22: reserve closure missreported ================="
 
-OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
-OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
-RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
-OLD_EXP=`echo "SELECT expiration_date FROM reserves WHERE 
reserve_pub='${RES_PUB}';" | psql $DB -Aqt`
-VAL_DELTA=1
-NEW_TIME=`expr $OLD_TIME - 3024000000000`  # 5 weeks
-NEW_EXP=`expr $OLD_EXP - 3024000000000`  # 5 weeks
-NEW_CREDIT=`expr $OLD_VAL + $VAL_DELTA`
-echo "UPDATE reserves_in SET 
execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE 
reserve_in_serial_id=1;" | psql -Aqt $DB
-echo "UPDATE reserves SET 
current_balance_val=${VAL_DELTA}+current_balance_val,expiration_date='${NEW_EXP}'
 WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
+# Check wire transfer lag reported (no aggregator!)
+# NOTE: This test is EXPECTED to fail for ~1h after
+# re-generating the test database as we do not
+# report lag of less than 1h (see GRACE_PERIOD in
+# taler-wire-auditor.c)
+if [ $DATABASE_AGE -gt 3600 ]
+then
 
-# Need to first run the aggregator so the transfer is marked as done exists
-pre_audit aggregator
+    OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
+    OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
+    RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE 
reserve_in_serial_id=1;" | psql $DB -Aqt`
+    OLD_EXP=`echo "SELECT expiration_date FROM reserves WHERE 
reserve_pub='${RES_PUB}';" | psql $DB -Aqt`
+    VAL_DELTA=1
+    NEW_TIME=`expr $OLD_TIME - 3024000000000`  # 5 weeks
+    NEW_EXP=`expr $OLD_EXP - 3024000000000`  # 5 weeks
+    NEW_CREDIT=`expr $OLD_VAL + $VAL_DELTA`
+    echo "UPDATE reserves_in SET 
execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE 
reserve_in_serial_id=1;" | psql -Aqt $DB
+    echo "UPDATE reserves SET 
current_balance_val=${VAL_DELTA}+current_balance_val,expiration_date='${NEW_EXP}'
 WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
 
+    # Need to first run the aggregator so the transfer is marked as done exists
+    pre_audit aggregator
 
-# remove transaction from bank DB
-echo "DELETE FROM app_banktransaction WHERE debit_account_id=2 AND 
amount='TESTKUDOS:${VAL_DELTA}.00';" | psql -Aqt $DB
 
-audit_only
-post_audit
+    # remove transaction from bank DB
+    echo "DELETE FROM app_banktransaction WHERE debit_account_id=2 AND 
amount='TESTKUDOS:${VAL_DELTA}.00';" | psql -Aqt $DB
 
-echo -n "Testing lack of reserve closure transaction detected... "
+    audit_only
+    post_audit
 
-jq -e .reserve_lag_details[0] < test-wire-audit.json > /dev/null || exit_fail 
"Reserve closure lag not detected"
+    echo -n "Testing lack of reserve closure transaction detected... "
 
-AMOUNT=`jq -r .reserve_lag_details[0].amount < test-wire-audit.json`
-if test "x$AMOUNT" != "xTESTKUDOS:${VAL_DELTA}"
-then
-    exit_fail "Reported total amount wrong: $AMOUNT"
-fi
-AMOUNT=`jq -r .total_closure_amount_lag < test-wire-audit.json`
-if test "x$AMOUNT" != "xTESTKUDOS:${VAL_DELTA}"
-then
-    exit_fail "Reported total amount wrong: $AMOUNT"
-fi
+    jq -e .reserve_lag_details[0] < test-wire-audit.json > /dev/null || 
exit_fail "Reserve closure lag not detected"
 
-echo "PASS"
+    AMOUNT=`jq -r .reserve_lag_details[0].amount < test-wire-audit.json`
+    if test "x$AMOUNT" != "xTESTKUDOS:${VAL_DELTA}"
+    then
+        exit_fail "Reported total amount wrong: $AMOUNT"
+    fi
+    AMOUNT=`jq -r .total_closure_amount_lag < test-wire-audit.json`
+    if test "x$AMOUNT" != "xTESTKUDOS:${VAL_DELTA}"
+    then
+        exit_fail "Reported total amount wrong: $AMOUNT"
+    fi
 
-# Undo
-echo "UPDATE reserves_in SET 
execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE 
reserve_in_serial_id=1;" | psql -Aqt $DB
-echo "UPDATE reserves SET 
expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA}
 WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
+    echo "PASS"
+
+    # cannot easily undo aggregator, hence full reload
+    echo -n "Reloading database ..."
+    full_reload
+    echo "DONE"
+else
+    echo "Test skipped (database too new)"
+fi
 }
 
 
@@ -1206,24 +1293,62 @@ echo "UPDATE reserves SET 
expiration_date='${OLD_EXP}',current_balance_val=curre
 # **************************************************
 
 
+# *************** Main test loop starts here **************
+
+
+# Run all the tests against the database given in $1.
+# Sets $fail to 0 on success, non-zero on failure.
+check_with_database()
+{
+    BASEDB=$1
+    echo "Running test suite with database $BASEDB"
+
+    # Setup database-specific globals
+    MASTER_PUB=`cat ${BASEDB}.mpub`
+
+    # Where to store wire fee details for aggregator
+    WIRE_FEE_DIR=`taler-config -c $CONF -f -s exchangedb -o WIREFEE_BASE_DIR`
+    mkdir -p $WIRE_FEE_DIR
+    cp ${BASEDB}.fees $WIRE_FEE_DIR/x-taler-bank.fee
+
+    # Determine database age
+    AGE=`stat -c %Y ${BASEDB}.fees`
+    NOW=`date +%s`
+    DATABASE_AGE=`expr $NOW - $AGE`
+
+
+    # Load database
+    echo -n "Running initial database setup ..."
+    full_reload
+    echo " DONE"
+
+    # Run test suite
+    fail=0
+    for i in $TESTS
+    do
+        test_$i
+        if test 0 != $fail
+        then
+            break
+        fi
+    done
+    echo "Cleanup (disabled)"
+    # dropdb $DB
+    # rm -r $WIRE_FEE_DIR
+    # rm -f test-audit.log test-wire-audit.log
+}
+
+
 
 # *************** Main logic starts here **************
 
 # ####### Setup globals ######
 # Postgres database to use
 DB=taler-auditor-test
-# Prefix for the data resources to use
-BASEDB="auditor-basedb"
-MASTER_PUB=`cat ${BASEDB}.mpub`
+
 # Configuration file to use
 CONF=test-auditor.conf
 
-# Where to store wire fee details for aggregator
-WIRE_FEE_DIR=`taler-config -c $CONF -f -s exchangedb -o WIREFEE_BASE_DIR`
-mkdir -p $WIRE_FEE_DIR
-cp ${BASEDB}.fees $WIRE_FEE_DIR/x-taler-bank.fee
-
-
 # test required commands exist
 echo "Testing for jq"
 jq -h > /dev/null || exit_skip "jq required"
@@ -1232,25 +1357,34 @@ taler-bank-manage -h >/dev/null </dev/null || exit_skip 
"taler-bank-manage requi
 echo "Testing for pdflatex"
 which pdflatex > /dev/null </dev/null || exit_skip "pdflatex required"
 
-echo -n "Database setup ..."
-full_reload
-echo " DONE"
-
-# Run test suite
-fail=0
-for i in $TESTS
-do
-    test_$i
-    if test 0 != $fail
+# check if we should regenerate the database
+if test -n "${1:-}"
+then
+    echo "Custom run, will only run on existing DB."
+else
+    echo -n "Testing for taler-wallet-cli"
+    if taler-wallet-cli -h >/dev/null </dev/null 2>/dev/null
     then
-       break
+        MYDIR=`mktemp -d /tmp/taler-auditor-basedbXXXXXX`
+        echo " FOUND. Generating fresh database at $MYDIR"
+        if ./generate-auditor-basedb.sh $MYDIR/basedb
+        then
+            check_with_database $MYDIR/basedb
+            if test x$fail != x0
+            then
+                exit $fail
+            else
+                echo "Cleaning up $MYDIR..."
+                rm -rf $MYDIR || echo "Removing $MYDIR failed"
+            fi
+        else
+            echo "Generation failed, running only on existing DB"
+        fi
+    else
+        echo " NOT FOUND, running only on existing DB"
     fi
-done
-
+fi
 
-echo "Cleanup (disabled)"
-# dropdb $DB
-# rm -r $WIRE_FEE_DIR
-# rm -f test-audit.log test-wire-audit.log
+check_with_database "auditor-basedb"
 
 exit $fail
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index aedf93e3..bc0ae214 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -235,6 +235,20 @@
 #define TALER_SIGNATURE_EXCHANGE_TEST_EDDSA 1303
 
 
+/************************/
+/* Anastasis signatures */
+/************************/
+
+/**
+ * EdDSA signature for a policy upload.
+ */
+#define TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD 1400
+
+/**
+ * EdDSA signature for a policy download.
+ */
+#define TALER_SIGNATURE_ANASTASIS_POLICY_DOWNLOAD 1401
+
 
 GNUNET_NETWORK_STRUCT_BEGIN
 

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



reply via email to

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