[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 03/08: expand test suite
From: |
gnunet |
Subject: |
[taler-exchange] 03/08: expand test suite |
Date: |
Fri, 27 Mar 2020 11:26:40 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit 8a90c8fbcb7c274cfed3f379f92a00da45313787
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Mar 27 09:35:48 2020 +0100
expand test suite
---
contrib/auditor-report.tex.j2 | 14 +++---
src/auditor/test-auditor.sh | 37 ++++++++++++++--
src/auditor/test-revocation.sh | 96 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 137 insertions(+), 10 deletions(-)
diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2
index a8514aed..16b53e20 100644
--- a/contrib/auditor-report.tex.j2
+++ b/contrib/auditor-report.tex.j2
@@ -509,6 +509,7 @@ easily determined from the amounts and thus not included in
the totals.
\subsubsection{For coins}
% Table generation tested by testcase #18 in test-auditor.sh
+% Table generation tested by testcase #3 in test-revocation.sh
{% if coins.amount_arithmetic_inconsistencies|length() == 0 %}
{\bf No arithmetic problems detected.}
@@ -541,7 +542,7 @@ easily determined from the amounts and thus not included in
the totals.
\subsubsection{For reserves}
-% Table generation tested by testcase #XX in test-auditor.sh
+% Table generation tested by testcase #2 in test-auditor.sh
{% if reserves.amount_arithmetic_inconsistencies|length() == 0 %}
{\bf No arithmetic problems detected.}
@@ -752,6 +753,7 @@ public key for ``recoup-master'' operations.
\subsubsection{For coins}
% Table generation tested by testcase #4/#5/#6/#13 in test-auditor.sh
+% Table generation tested by testcase #4 in test-revocation.sh
{% if coins.bad_sig_losses|length() == 0 %}
{\bf All signatures were valid.}
@@ -775,7 +777,7 @@ public key for ``recoup-master'' operations.
\label{table:bad_signature_losses}
\endlastfoot
{% for item in coins.bad_sig_losses %}
- \multicolumn{3}{l}{ {\tt \small \truncate{0.9\textwidth}{ {{ item.key_pub }}
} } } \\
+ \multicolumn{3}{l}{ {\tt \small \truncate{0.9\textwidth}{ {{ item.coin_pub
}} } } } \\
\nopagebreak
{{ item.operation }} &
{{ item.row }} &
@@ -974,6 +976,7 @@ Deltas may indicate a corrupt database, but do not
necessarily
translate into a financial loss (yet).
% Table generation tested by testcase #3 in test-auditor.sh
+% Table generation tested by testcase #4 in test-revocation.sh
{% if reserves.reserve_balance_summary_wrong_inconsistencies|length() == 0 %}
{\bf All balances matched up.}
@@ -1065,8 +1068,7 @@ have a clear financial impact.
This section describes issues found by the wire auditor that
relate to outgoing wire transfers subjects being duplicated.
-% Table generation tested by testcase #XX in test-auditor.sh
-% TODO: test this! #6054
+% Table generation tested by testcase #27 in test-auditor.sh
{% if wire.wire_format_inconsistencies|length() == 0 %}
{\bf No wire format inconsistencies found.}
@@ -1081,7 +1083,7 @@ relate to outgoing wire transfers subjects being
duplicated.
\hline \hline
\endhead
\hline
- \multicolumn{2}{c}{ {\bf Row (base32)} } \\
+ \multicolumn{2}{c}{ {\bf Diagnostic} } \\
{\bf Row (base32)} & {\bf Amount} \\
\endfoot
\hline
@@ -1200,7 +1202,7 @@ impact.
\subsubsection{For reserves}
-% Table generation tested by testcase #XX in test-auditor.sh
+% Table generation tested by testcase #4 in test-revocation.sh
{% if reserves.row_inconsistencies|length() == 0 %}
{\bf No row inconsistencies found.}
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index ac498e17..9b986733 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -352,7 +352,7 @@ echo "OK"
# Change amount of wire transfer reported by exchange
function test_2() {
-echo "===========2: reserves_in inconsitency==========="
+echo "===========2: reserves_in inconsistency==========="
echo "UPDATE reserves_in SET credit_val=5 WHERE reserve_in_serial_id=1" | psql
-Aqt $DB
run_audit
@@ -396,7 +396,7 @@ echo "UPDATE reserves_in SET credit_val=10 WHERE
reserve_in_serial_id=1" | psql
# lower than what exchange claims to have received.
function test_3() {
-echo "===========3: reserves_in inconsitency==========="
+echo "===========3: reserves_in inconsistency==========="
echo "UPDATE reserves_in SET credit_val=15 WHERE reserve_in_serial_id=1" |
psql -Aqt $DB
run_audit
@@ -1443,7 +1443,6 @@ function test_25() {
echo "=========25: inconsistent coin history========="
-# 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
@@ -1729,6 +1728,38 @@ fi
}
+
+
+
+# Test where denom_sig in known_coins table is wrong
+# (=> bad signature)
+function test_32() {
+
+# 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-helper-auditor-wire.c)
+if [ $DATABASE_AGE -gt 3600 ]
+then
+
+ echo "===========32: known_coins signature wrong w.
aggregation================="
+ # Modify denom_sig, so it is wrong
+ OLD_SIG=`echo 'SELECT denom_sig FROM known_coins LIMIT 1;' | psql $DB -Aqt`
+ COIN_PUB=`echo "SELECT coin_pub FROM known_coins WHERE
denom_sig='$OLD_SIG';" | psql $DB -Aqt`
+ echo "UPDATE known_coins SET
denom_sig='\x287369672d76616c200a2028727361200a2020287320233542383731423743393036444643303442424430453039353246413642464132463537303139374131313437353746324632323332394644443146324643333445393939413336363430334233413133324444464239413833353833464536354442374335434445304441453035374438363336434541423834463843323843344446304144363030343430413038353435363039373833434431333239393736423642433437313041324632414132414435413833303432434346314139464635394244434346
[...]
+
+ run_audit aggregation
+
+ # FIXME: test incomplete...
+
+ # Cannot undo aggregation, do full reload
+ full_reload
+
+fi
+}
+
+
+
# *************** Main test loop starts here **************
diff --git a/src/auditor/test-revocation.sh b/src/auditor/test-revocation.sh
index 7f9412af..81844b7a 100755
--- a/src/auditor/test-revocation.sh
+++ b/src/auditor/test-revocation.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 1`
+ALL_TESTS=`seq 0 4`
# $TESTS determines which tests we should run.
# This construction is used to make it easy to
@@ -344,12 +344,106 @@ if test $WIRED != "TESTKUDOS:0"
then
exit_fail "Expected total missattribution in wrong, got $WIRED"
fi
+
# Database was unmodified, no need to undo
echo "OK"
}
+# Change recoup amount
+function test_2() {
+
+echo "===========2: recoup amount inconsistency==========="
+echo "UPDATE recoup SET amount_val=5 WHERE recoup_uuid=1" | psql -Aqt $DB
+
+run_audit
+
+# Reserve balance is now wrong
+echo -n "Testing inconsistency detection... "
+AMOUNT=`jq -r .reserve_balance_summary_wrong_inconsistencies[0].auditor <
test-audit-reserves.json`
+if test $AMOUNT != "TESTKUDOS:3"
+then
+ exit_fail "Auditor amount $AMOUNT is wrong"
+fi
+AMOUNT=`jq -r .reserve_balance_summary_wrong_inconsistencies[0].exchange <
test-audit-reserves.json`
+if test $AMOUNT != "TESTKUDOS:0"
+then
+ exit_fail "Exchange amount $AMOUNT is wrong"
+fi
+# Coin spent exceeded coin's value
+AMOUNT=`jq -r .amount_arithmetic_inconsistencies[0].auditor <
test-audit-coins.json`
+if test $AMOUNT != "TESTKUDOS:2"
+then
+ exit_fail "Auditor amount $AMOUNT is wrong"
+fi
+AMOUNT=`jq -r .amount_arithmetic_inconsistencies[0].exchange <
test-audit-coins.json`
+if test $AMOUNT != "TESTKUDOS:5"
+then
+ exit_fail "Exchange amount $AMOUNT is wrong"
+fi
+echo OK
+
+# Undo database modification
+echo "UPDATE recoup SET amount_val=2 WHERE recoup_uuid=1" | psql -Aqt $DB
+
+}
+
+
+# Change recoup-refresh amount
+function test_3() {
+
+echo "===========3: recoup-refresh amount inconsistency==========="
+echo "UPDATE recoup_refresh SET amount_val=5 WHERE recoup_refresh_uuid=1" |
psql -Aqt $DB
+
+run_audit
+
+echo -n "Testing inconsistency detection... "
+# Coin spent exceeded coin's value
+AMOUNT=`jq -r .total_arithmetic_delta_minus < test-audit-coins.json`
+if test $AMOUNT != "TESTKUDOS:5"
+then
+ exit_fail "Arithmetic delta minus amount $AMOUNT is wrong"
+fi
+AMOUNT=`jq -r .total_arithmetic_delta_plus < test-audit-coins.json`
+if test $AMOUNT != "TESTKUDOS:0"
+then
+ exit_fail "Arithmetic delta plus amount $AMOUNT is wrong"
+fi
+echo OK
+
+# Undo database modification
+echo "UPDATE recoup_refresh SET amount_val=0 WHERE recoup_refresh_uuid=1" |
psql -Aqt $DB
+
+}
+
+
+# Void recoup-refresh entry by 'unrevoking' denomination
+function test_4() {
+
+echo "===========4: invalid recoup==========="
+echo "DELETE FROM denomination_revocations;" | psql -Aqt $DB
+
+run_audit
+
+echo -n "Testing inconsistency detection... "
+# Coin spent exceeded coin's value
+jq -e .bad_sig_losses[0] < test-audit-coins.json > /dev/null || exit_fail "Bad
recoup not detected"
+AMOUNT=`jq -r .total_bad_sig_losses < test-audit-coins.json`
+if test $AMOUNT == "TESTKUDOS:0"
+then
+ exit_fail "Total bad sig losses are wrong"
+fi
+echo OK
+
+# Undo database modification (can't easily undo DELETE, so full reload)
+full_reload
+
+}
+
+
+
+
# *************** Main test loop starts here **************
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-exchange] branch master updated (f052527e -> 13bbcef8), gnunet, 2020/03/27
- [taler-exchange] 04/08: missing break, gnunet, 2020/03/27
- [taler-exchange] 02/08: check coin history consistency, gnunet, 2020/03/27
- [taler-exchange] 08/08: adjust test to code changes, gnunet, 2020/03/27
- [taler-exchange] 06/08: improve error logging, gnunet, 2020/03/27
- [taler-exchange] 01/08: consider that deposit fee is discounted when refund fee is applied, gnunet, 2020/03/27
- [taler-exchange] 03/08: expand test suite,
gnunet <=
- [taler-exchange] 07/08: fix inconsistency in field naming, gnunet, 2020/03/27
- [taler-exchange] 05/08: improve coin audit logic, gnunet, 2020/03/27