add test for hung refresh and wrong refresh sig, fix audit report formatting issue(s)

This commit is contained in:
Christian Grothoff 2019-09-05 06:30:36 +02:00
parent d4905d7e2c
commit f16a4c5b21
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 96 additions and 23 deletions

View File

@ -861,11 +861,12 @@ coin as spent from {\tt /refresh/melt} but where the
wallet did not yet complete {\tt /refresh/reveal}. This
may happen even if the exchange is correct.
% Table generation tested by testcase #12 in test-auditor.sh
{% if data.refresh_hanging|length() == 0 %}
{\bf All melted coins were refreshed.}
{% else %}
\begin{longtable}{p{1.5cm}|c|r}
\begin{longtable}{p{6.5cm}|c|r}
{\bf Key} & {\bf row} & {\bf Amount} \\
\hline \hline
\endfirsthead
@ -882,9 +883,7 @@ may happen even if the exchange is correct.
\label{table:refresh:hanging}
\endlastfoot
{% for item in data.refresh_hanging %}
\multicolumn{4}{l}{ {\tt \small {{ item.coin_pub }} } } \\
\nopagebreak
&
\truncate{6.2cm}{ {\tt \small {{ item.coin_pub }} } } &
{{ item.row }} &
{{ item.amount }} \\ \hline
{% endfor %}

View File

@ -5269,11 +5269,11 @@ run (void *cls,
TALER_JSON_from_amount (&total_wire_out_delta_plus),
"total_wire_out_delta_minus",
TALER_JSON_from_amount (&total_wire_out_delta_minus),
/* Tested in test-auditor.sh #4/#5/#6/#7 */
/* Tested in test-auditor.sh #4/#5/#6/#7/#13 */
"bad_sig_losses",
report_bad_sig_losses,
/* block */
/* Tested in test-auditor.sh #4/#5/#6/#7 */
/* Tested in test-auditor.sh #4/#5/#6/#7/#13 */
"total_bad_sig_loss",
TALER_JSON_from_amount (&total_bad_sig_loss),
"row_inconsistencies",
@ -5298,8 +5298,10 @@ run (void *cls,
/* block */
"wire_fee_time_inconsistencies",
report_fee_time_inconsistencies,
/* Tested in test-auditor.sh #12 */
"total_refresh_hanging",
TALER_JSON_from_amount (&total_refresh_hanging),
/* Tested in test-auditor.sh #12 */
"refresh_hanging",
report_refreshs_hanging,
"deposit_confirmation_inconsistencies",

View File

@ -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 11`
ALL_TESTS=`seq 0 13`
# $TESTS determines which tests we should run.
# This construction is used to make it easy to
@ -95,9 +95,9 @@ run_audit aggregator
echo "Checking output"
# if an emergency was detected, that is a bug and we should fail
echo -n "Test for emergencies... "
jq -e .emergencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo OK
jq -e .emergencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo PASS
echo -n "Test for emergencies by count... "
jq -e .emergencies_by_count[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo OK
jq -e .emergencies_by_count[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo PASS
echo -n "Test for wire inconsistencies... "
jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in ordinary run"
@ -111,7 +111,7 @@ jq -e .wire_format_inconsistencies[0] < test-wire-audit.json > /dev/null && exit
# FIXME: check operation balances are correct (once we have more transaction types)
# FIXME: check revenue summaries are correct (once we have more transaction types)
echo OK
echo PASS
echo -n "Test for wire amounts... "
WIRED=`jq -r .total_wire_in_delta_plus < test-wire-audit.json`
@ -161,9 +161,9 @@ run_audit
echo "Checking output"
# if an emergency was detected, that is a bug and we should fail
echo -n "Test for emergencies... "
jq -e .emergencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo OK
jq -e .emergencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo PASS
echo -n "Test for emergencies by count... "
jq -e .emergencies_by_count[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo OK
jq -e .emergencies_by_count[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo PASS
echo -n "Test for wire inconsistencies... "
jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in ordinary run"
@ -177,7 +177,7 @@ jq -e .wire_format_inconsistencies[0] < test-wire-audit.json > /dev/null && exit
# FIXME: check operation balances are correct (once we have more transaction types)
# FIXME: check revenue summaries are correct (once we have more transaction types)
echo OK
echo PASS
# FIXME: check wire transfer lag reported (no aggregator!)
@ -220,7 +220,7 @@ echo "UPDATE reserves_in SET credit_val=5 WHERE reserve_in_serial_id=1" | psql -
run_audit
echo -n "Test for inconsistency detection... "
echo -n "Testing inconsistency detection... "
ROW=`jq .reserve_in_amount_inconsistencies[0].row < test-wire-audit.json`
if test $ROW != 1
then
@ -247,7 +247,7 @@ if test $DELTA != "TESTKUDOS:5"
then
exit_fail "Expected total wire delta plus wrong, got $DELTA"
fi
echo OK
echo PASS
# Undo database modification
echo "UPDATE reserves_in SET credit_val=10 WHERE reserve_in_serial_id=1" | psql -Aqt $DB
@ -504,7 +504,7 @@ echo "UPDATE app_banktransaction SET subject='$NEW_WTID' WHERE id='$OLD_ID';" |
run_audit
echo -n "Test for inconsistency detection... "
echo -n "Testing inconsistency detection... "
DIAG=`jq -r .reserve_in_amount_inconsistencies[0].diagnostic < test-wire-audit.json`
if test "x$DIAG" != "xwire subject does not match"
then
@ -554,7 +554,7 @@ if test $DELTA != "TESTKUDOS:10"
then
exit_fail "Expected total wire delta plus wrong, got $DELTA"
fi
echo OK
echo PASS
# Undo database modification
echo "UPDATE app_banktransaction SET subject='$OLD_WTID' WHERE id='$OLD_ID';" | psql -Aqt $DB
@ -573,7 +573,7 @@ echo "UPDATE app_banktransaction SET debit_account_id=1;" | psql -Aqt $DB
run_audit
echo -n "Test for inconsistency detection... "
echo -n "Testing inconsistency detection... "
AMOUNT=`jq -r .missattribution_in_inconsistencies[0].amount < test-wire-audit.json`
if test "x$AMOUNT" != "xTESTKUDOS:10"
then
@ -584,7 +584,7 @@ if test "x$AMOUNT" != "xTESTKUDOS:10"
then
exit_fail "Reported total amount wrong: $AMOUNT"
fi
echo OK
echo PASS
# Undo database modification
echo "UPDATE app_banktransaction SET debit_account_id=$OLD_ACC;" | psql -Aqt $DB
@ -602,7 +602,7 @@ echo "UPDATE app_banktransaction SET date=NOW() WHERE id=$OLD_ID;" | psql -Aqt $
run_audit
echo -n "Test for inconsistency detection... "
echo -n "Testing inconsistency detection... "
DIAG=`jq -r .row_minor_inconsistencies[0].diagnostic < test-wire-audit.json`
if test "x$DIAG" != "xexecution date missmatch"
then
@ -613,7 +613,7 @@ if test "x$TABLE" != "xreserves_in"
then
exit_fail "Reported table wrong: $TABLE"
fi
echo OK
echo PASS
# Undo database modification
echo "UPDATE app_banktransaction SET date='$OLD_DATE' WHERE id=$OLD_ID;" | psql -Aqt $DB
@ -636,7 +636,7 @@ echo "UPDATE app_banktransaction SET debit_account_id=2,credit_account_id=1 WHER
run_audit
echo -n "Test for inconsistency detection... "
echo -n "Testing inconsistency detection... "
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < test-wire-audit.json`
if test "x$AMOUNT" != "xTESTKUDOS:10"
then
@ -662,7 +662,7 @@ if test "x$DIAG" != "xjustification for wire transfer not found"
then
exit_fail "Reported diagnostic wrong: $DIAG"
fi
echo OK
echo PASS
# Undo database modification (exchange always has account #2)
echo "UPDATE app_banktransaction SET debit_account_id=$OLD_ACC,credit_account_id=2 WHERE id=$OLD_ID;" | psql -Aqt $DB
@ -670,6 +670,78 @@ echo "UPDATE app_banktransaction SET debit_account_id=$OLD_ACC,credit_account_id
}
# Test for hanging/pending refresh.
test_12() {
echo "===========12: incomplete refresh ==========="
OLD_ACC=`echo "DELETE FROM refresh_revealed_coins;" | psql $DB -Aqt`
run_audit
echo -n "Testing hung refresh detection... "
HANG=`jq -er .refresh_hanging[0].amount < test-audit.json`
TOTAL_HANG=`jq -e .total_refresh_hanging < test-audit.json`
if test x$HANG != x$TOTAL_HANG
then
exit_fail "Hanging amount inconsistent, got $HANG and $TOTAL_HANG"
fi
if test x$TOTAL_HANG = TESTKUDOS:0
then
exit_fail "Hanging amount zero"
fi
echo PASS
# cannot easily undo DELETE, hence full reload
echo -n "Reloading database ..."
full_reload
echo "DONE"
}
# Test for wrong signature on refresh.
test_13() {
echo "===========13: wrong melt signature ==========="
# Modify denom_sig, so it is wrong
COIN_PUB=`echo "SELECT old_coin_pub FROM refresh_commitments LIMIT 1;" | psql $DB -Aqt`
OLD_SIG=`echo "SELECT old_coin_sig FROM refresh_commitments WHERE old_coin_pub='$COIN_PUB';" | psql $DB -Aqt`
NEW_SIG="\xba588af7c13c477dca1ac458f65cc484db8fba53b969b873f4353ecbd815e6b4c03f42c0cb63a2b609c2d726e612fd8e0c084906a41f409b6a23a08a83c89a02"
echo "UPDATE refresh_commitments SET old_coin_sig='$NEW_SIG' WHERE old_coin_pub='$COIN_PUB'" | psql -Aqt $DB
run_audit
echo -n "Testing inconsistency detection... "
OP=`jq -er .bad_sig_losses[0].operation < test-audit.json`
if test x$OP != xmelt
then
exit_fail "Operation wrong, got $OP"
fi
LOSS=`jq -er .bad_sig_losses[0].loss < test-audit.json`
TOTAL_LOSS=`jq -e .total_bad_sig_loss < test-audit.json`
if test x$LOSS != x$TOTAL_LOSS
then
exit_fail "Loss inconsistent, got $LOSS and $TOTAL_LOSS"
fi
if test x$TOTAL_LOSS = TESTKUDOS:0
then
exit_fail "Loss zero"
fi
echo PASS
# cannot easily undo DELETE, hence full reload
echo -n "Reloading database ..."
full_reload
echo "DONE"
}
# FIXME: Test for wire fee disagreement
test_98() {