add test for missing wire transfer for reserve closure
This commit is contained in:
parent
c776a5f51e
commit
d585c40996
@ -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.
|
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 %}
|
{% if wire.reserve_lag_details|length() == 0 %}
|
||||||
{\bf No closure transfers that are lagging behind detected.}
|
{\bf No closure transfers that are lagging behind detected.}
|
||||||
{% else %}
|
{% 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
|
\multicolumn{3}{l}{\bf Target account} \\ \hline \hline
|
||||||
\endfirsthead
|
\endfirsthead
|
||||||
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
|
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
|
||||||
\multicolumn{3}{l}{\bf Coin} \\
|
\multicolumn{3}{l}{\bf WTID} \\
|
||||||
\multicolumn{3}{l}{\bf Target account} \\ \hline \hline
|
\multicolumn{3}{l}{\bf Target account} \\ \hline \hline
|
||||||
\endhead
|
\endhead
|
||||||
\hline \hline
|
\hline \hline
|
||||||
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
|
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
|
||||||
\multicolumn{3}{l}{\bf Coin} \\
|
\multicolumn{3}{l}{\bf WTID} \\
|
||||||
\multicolumn{3}{l}{\bf Target account} \\
|
\multicolumn{3}{l}{\bf Target account} \\
|
||||||
\endfoot
|
\endfoot
|
||||||
\hline \hline
|
\hline \hline
|
||||||
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
|
{\bf Deadline} & {\bf Amount} & {\bf Row} \\
|
||||||
\multicolumn{3}{l}{\bf Coin} \\
|
\multicolumn{3}{l}{\bf WTID} \\
|
||||||
\multicolumn{3}{l}{\bf Target account} \\
|
\multicolumn{3}{l}{\bf Target account} \\
|
||||||
\caption{Lagging reserve closure transactions.}
|
\caption{Lagging reserve closure transactions.}
|
||||||
\label{table:lag}
|
\label{table:lag}
|
||||||
|
@ -521,13 +521,17 @@ do_shutdown (void *cls)
|
|||||||
/* Tested in test-auditor.sh #19 */
|
/* Tested in test-auditor.sh #19 */
|
||||||
"wire_format_inconsistencies",
|
"wire_format_inconsistencies",
|
||||||
report_wire_format_inconsistencies,
|
report_wire_format_inconsistencies,
|
||||||
|
/* Tested in test-auditor.sh #1 */
|
||||||
"total_amount_lag",
|
"total_amount_lag",
|
||||||
TALER_JSON_from_amount (&total_amount_lag),
|
TALER_JSON_from_amount (&total_amount_lag),
|
||||||
|
/* Tested in test-auditor.sh #1 */
|
||||||
"lag_details",
|
"lag_details",
|
||||||
report_lags,
|
report_lags,
|
||||||
|
/* Tested in test-auditor.sh #22 */
|
||||||
"total_closure_amount_lag",
|
"total_closure_amount_lag",
|
||||||
TALER_JSON_from_amount (&total_closure_amount_lag),
|
TALER_JSON_from_amount (&total_closure_amount_lag),
|
||||||
/* blocks of 5 */
|
/* blocks of 5 */
|
||||||
|
/* Tested in test-auditor.sh #22 */
|
||||||
"reserve_lag_details",
|
"reserve_lag_details",
|
||||||
report_closure_lags);
|
report_closure_lags);
|
||||||
GNUNET_break (NULL != report);
|
GNUNET_break (NULL != report);
|
||||||
|
@ -9,7 +9,7 @@ set -eu
|
|||||||
|
|
||||||
# Set of numbers for all the testcases.
|
# Set of numbers for all the testcases.
|
||||||
# When adding new tests, increase the last number:
|
# 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.
|
# $TESTS determines which tests we should run.
|
||||||
# This construction is used to make it easy to
|
# 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
|
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! :-)
|
# FIXME: Add more tests here! :-)
|
||||||
# Specifically:
|
# Specifically:
|
||||||
|
Loading…
Reference in New Issue
Block a user