aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/auditor-report.tex.j28
-rw-r--r--src/auditor/taler-wire-auditor.c4
-rwxr-xr-xsrc/auditor/test-auditor.sh52
3 files changed, 60 insertions, 4 deletions
diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2
index 57ec01de7..52b3675dc 100644
--- a/contrib/auditor-report.tex.j2
+++ b/contrib/auditor-report.tex.j2
@@ -165,6 +165,8 @@ The total amount the exchange currently lags behind in reserve closures is
Note that some minimal lag may be normal as transactions may be in-flight.
+% Table generation tested by testcase #22 in test-auditor.sh
+
{% if wire.reserve_lag_details|length() == 0 %}
{\bf No closure transfers that are lagging behind detected.}
{% else %}
@@ -174,17 +176,17 @@ Note that some minimal lag may be normal as transactions may be in-flight.
\multicolumn{3}{l}{\bf Target account} \\ \hline \hline
\endfirsthead
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
- \multicolumn{3}{l}{\bf Coin} \\
+ \multicolumn{3}{l}{\bf WTID} \\
\multicolumn{3}{l}{\bf Target account} \\ \hline \hline
\endhead
\hline \hline
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
- \multicolumn{3}{l}{\bf Coin} \\
+ \multicolumn{3}{l}{\bf WTID} \\
\multicolumn{3}{l}{\bf Target account} \\
\endfoot
\hline \hline
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
- \multicolumn{3}{l}{\bf Coin} \\
+ \multicolumn{3}{l}{\bf WTID} \\
\multicolumn{3}{l}{\bf Target account} \\
\caption{Lagging reserve closure transactions.}
\label{table:lag}
diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c
index 330942805..a945f9df2 100644
--- a/src/auditor/taler-wire-auditor.c
+++ b/src/auditor/taler-wire-auditor.c
@@ -521,13 +521,17 @@ do_shutdown (void *cls)
/* Tested in test-auditor.sh #19 */
"wire_format_inconsistencies",
report_wire_format_inconsistencies,
+ /* Tested in test-auditor.sh #1 */
"total_amount_lag",
TALER_JSON_from_amount (&total_amount_lag),
+ /* Tested in test-auditor.sh #1 */
"lag_details",
report_lags,
+ /* Tested in test-auditor.sh #22 */
"total_closure_amount_lag",
TALER_JSON_from_amount (&total_closure_amount_lag),
/* blocks of 5 */
+ /* Tested in test-auditor.sh #22 */
"reserve_lag_details",
report_closure_lags);
GNUNET_break (NULL != report);
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 67ed901f8..23c2fafe5 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -9,7 +9,7 @@ set -eu
# Set of numbers for all the testcases.
# When adding new tests, increase the last number:
-ALL_TESTS=`seq 0 21`
+ALL_TESTS=`seq 0 22`
# $TESTS determines which tests we should run.
# This construction is used to make it easy to
@@ -1145,6 +1145,56 @@ fi
echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
}
+
+# Test reserve closure reported but wire transfer missing detection
+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
+
+# 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
+
+echo -n "Testing lack of reserve closure transaction detected... "
+
+jq -e .reserve_lag_details[0] < test-wire-audit.json > /dev/null || exit_fail "Reserve closure lag not 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
+
+echo "PASS"
+
+# 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
+}
+
+
+
# **************************************************
# FIXME: Add more tests here! :-)
# Specifically: