another test, more fixes in auditor-report template

This commit is contained in:
Christian Grothoff 2019-09-03 03:14:23 +02:00
parent 67aeb85a13
commit 736927f05a
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 74 additions and 13 deletions

View File

@ -446,26 +446,30 @@ public key for ``payback-master'' operations.
{% if data.bad_sig_losses|length() == 0 %} {% if data.bad_sig_losses|length() == 0 %}
{\bf All signatures were valid.} {\bf All signatures were valid.}
{% else %} {% else %}
\begin{longtable}{p{1.5cm}|c|l|r} \begin{longtable}{c|r|r}
{\bf Public key} & {\bf Operation type} & Database row & {\bf Loss amount} \\ \multicolumn{3}{l}{ {\bf Public key} }\\
{\bf Operation type} & Database row & {\bf Loss amount} \\
\hline \hline \hline \hline
\endfirsthead \endfirsthead
{\bf Public key} & {\bf Operation type} & Database row & {\bf Loss amount} \\ \hline \hline \multicolumn{3}{l}{ {\bf Public key} }\\
{\bf Operation type} & Database row & {\bf Loss amount} \\ \hline \hline
\endhead \endhead
\hline \hline \hline \hline
{\bf Public key} & {\bf Operation type} & Database row & {\bf Loss amount} \\ \multicolumn{3}{l}{ {\bf Public key} }\\
{\bf Operation type} & Database row & {\bf Loss amount} \\
\endfoot \endfoot
\hline \hline
{\bf Total losses} & & & {\bf Total losses} & &
{{ data.total_bad_sig_loss}} \\ {\bf {{ data.total_bad_sig_loss}} } \\
\caption{Losses from operations performed on coins without proper signatures.} \caption{Losses from operations performed on coins without proper signatures.}
\label{table:bad_signature_losses} \label{table:bad_signature_losses}
\endlastfoot \endlastfoot
{% for item in data.bad_sig_losses %} {% for item in data.bad_sig_losses %}
\multicolumn{5}{l}{ {\tt \small {{ item.key_pub }} } } \\ \multicolumn{3}{l}{ {\tt \small {{ item.key_pub }} } } \\
\nopagebreak \nopagebreak
& {{ item.operation }} & {{ item.rowid }} & {{ item.operation }} &
{{ item.loss }} \\ \hline {{ item.row }} &
{{ item.loss }} \\ \hline
{% endfor %} {% endfor %}
\end{longtable} \end{longtable}
{% endif %} {% endif %}

View File

@ -7,25 +7,37 @@
# Requires 'jq' tool and Postgres superuser rights! # Requires 'jq' tool and Postgres superuser rights!
set -eu set -eu
# Which tests should we run, used to make it easy to # Set of numbers for all the testcases.
# When adding new tests, increase the last number:
ALL_TESTS=`seq 1 4`
# $TESTS determines which tests we should run.
# This construction is used to make it easy to
# only run a subset of the tests. To only run a subset, # only run a subset of the tests. To only run a subset,
# pass the numbers of the tests to run as the FIRST # pass the numbers of the tests to run as the FIRST
# argument to test-auditor.sh # argument to test-auditor.sh, i.e.:
ALL_TESTS=`seq 1 3` #
# $ test-auditor.sh "1 3"
#
# to run tests 1 and 3 only. By default, all tests are run.
#
TESTS=${1:-$ALL_TESTS} TESTS=${1:-$ALL_TESTS}
# Exit, with status code "skip" (no 'real' failure)
function exit_skip() { function exit_skip() {
echo $1 echo $1
exit 77 exit 77
} }
# Exit, with error message (hard failure)
function exit_fail() { function exit_fail() {
echo $1 echo $1
kill `jobs -p` kill `jobs -p`
exit 1 exit 1
} }
# Run audit process on current database, including report
# generation.
function run_audit () { function run_audit () {
# Launch bank # Launch bank
echo "Launching bank" echo "Launching bank"
@ -234,6 +246,51 @@ echo "UPDATE reserves_in SET credit_val=10 WHERE reserve_in_serial_id=1" | psql
} }
# Check for incoming wire transfer amount given being
# lower than what exchange claims to have received.
test_4() {
echo "===========4: deposit wire target wrong================="
# Original target bank account was 43, changing to 44
echo "UPDATE deposits SET wire='{\"url\":\"payto://x-taler-bank/localhost:8082/44\",\"salt\":\"test-salt (must be constant for aggregation tests)\"}' WHERE deposit_serial_id=1" | psql $DB
run_audit
ROW=`jq -e .bad_sig_losses[0].row < test-audit.json`
if test $ROW != 1
then
exit_fail "Row wrong, got $ROW"
fi
LOSS=`jq -r .bad_sig_losses[0].loss < test-audit.json`
if test $LOSS != "TESTKUDOS:0.1"
then
exit_fail "Wrong deposit bad signature loss, got $LOSS"
fi
OP=`jq -r .bad_sig_losses[0].operation < test-audit.json`
if test $OP != "deposit"
then
exit_fail "Wrong operation, got $OP"
fi
LOSS=`jq -r .total_bad_sig_loss < test-audit.json`
if test $LOSS != "TESTKUDOS:0.1"
then
exit_fail "Wrong total bad sig loss, got $LOSS"
fi
# Undo:
echo "UPDATE deposits SET wire='{\"url\":\"payto://x-taler-bank/localhost:8082/43\",\"salt\":\"test-salt (must be constant for aggregation tests)\"}' WHERE deposit_serial_id=1" | psql $DB
}
# Add more tests here! :-)
fail=0 fail=0
for i in $TESTS for i in $TESTS
do do