gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] branch master updated: add auditor test #2


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: add auditor test #24: wire out amount inconsistency detection
Date: Thu, 17 Oct 2019 21:52:56 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new bfb6306d add auditor test #24: wire out amount inconsistency detection
bfb6306d is described below

commit bfb6306d1896ed5e6eba0967307249dc5be88f2d
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Oct 17 21:52:54 2019 +0200

    add auditor test #24: wire out amount inconsistency detection
---
 contrib/auditor-report.tex.j2 |  2 +-
 src/auditor/test-auditor.sh   | 88 +++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 85 insertions(+), 5 deletions(-)

diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2
index 48ed2c65..29901c17 100644
--- a/contrib/auditor-report.tex.j2
+++ b/contrib/auditor-report.tex.j2
@@ -454,7 +454,7 @@ violations do not imply that the wire transfer was actually 
made (as
 that is a separate check).  Note that not making the wire transfer
 would be reported separately in Section~\ref{sec:wire_check_out}.
 
-% Table generation tested by testcase #XX in test-auditor.sh
+% Table generation tested by testcase #24 in test-auditor.sh
 
 {% if data.wire_out_inconsistencies|length() == 0 %}
   {\bf All aggregations matched up.}
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 83dcdcd9..2020ce64 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 22`
+ALL_TESTS=`seq 0 24`
 
 # $TESTS determines which tests we should run.
 # This construction is used to make it easy to
@@ -1295,8 +1295,6 @@ fi
 }
 
 
-
-
 # Test use of withdraw-expired denomination key
 function test_23() {
 echo "===========23: denomination key expired ================="
@@ -1325,10 +1323,92 @@ echo "UPDATE auditor_denominations SET 
expire_withdraw=${OLD_WEXP} WHERE denom_p
 }
 
 
+
+# Test calculation of wire-out amounts
+function test_24() {
+echo "===========24: wire out calculations ================="
+
+# 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
+# taler-wire-auditor.c)
+if [ $DATABASE_AGE -gt 3600 ]
+then
+
+    # Need to first run the aggregator so the transfer is marked as done exists
+    pre_audit aggregator
+
+    OLD_AMOUNT=`echo "SELECT amount_frac FROM wire_out WHERE wireout_uuid=1;" 
| psql $DB -Aqt`
+    NEW_AMOUNT=`expr $OLD_AMOUNT - 1000000`
+    echo "UPDATE wire_out SET amount_frac=${NEW_AMOUNT} WHERE wireout_uuid=1;" 
| psql -Aqt $DB
+
+    audit_only
+    post_audit
+
+    echo -n "Testing inconsistency detection... "
+
+    jq -e .wire_out_inconsistencies[0] < test-audit.json > /dev/null || 
exit_fail "Wire out inconsistency not detected"
+
+    ROW=`jq .wire_out_inconsistencies[0].rowid < test-audit.json`
+    if test $ROW != 1
+    then
+        exit_fail "Row wrong"
+    fi
+    AMOUNT=`jq -r .total_wire_out_delta_plus < test-audit.json`
+    if test "x$AMOUNT" != "xTESTKUDOS:0"
+    then
+        exit_fail "Reported amount wrong: $AMOUNT"
+    fi
+    AMOUNT=`jq -r .total_wire_out_delta_minus < test-audit.json`
+    if test "x$AMOUNT" != "xTESTKUDOS:0.01"
+    then
+        exit_fail "Reported total amount wrong: $AMOUNT"
+    fi
+    echo PASS
+
+    # Second pass, this time accounting is wrong in the OTHER direction
+    NEW_AMOUNT=`expr $OLD_AMOUNT + 1000000`
+    echo "UPDATE wire_out SET amount_frac=${NEW_AMOUNT} WHERE wireout_uuid=1;" 
| psql -Aqt $DB
+
+    audit_only
+    post_audit
+
+    echo -n "Testing inconsistency detection... "
+
+    jq -e .wire_out_inconsistencies[0] < test-audit.json > /dev/null || 
exit_fail "Wire out inconsistency not detected"
+
+    ROW=`jq .wire_out_inconsistencies[0].rowid < test-audit.json`
+    if test $ROW != 1
+    then
+        exit_fail "Row wrong"
+    fi
+    AMOUNT=`jq -r .total_wire_out_delta_minus < test-audit.json`
+    if test "x$AMOUNT" != "xTESTKUDOS:0"
+    then
+        exit_fail "Reported amount wrong: $AMOUNT"
+    fi
+    AMOUNT=`jq -r .total_wire_out_delta_plus < test-audit.json`
+    if test "x$AMOUNT" != "xTESTKUDOS:0.01"
+    then
+        exit_fail "Reported total amount wrong: $AMOUNT"
+    fi
+    echo PASS
+
+
+    # cannot easily undo aggregator, hence full reload
+    echo -n "Reloading database ..."
+    full_reload
+    echo "DONE"
+else
+    echo "Test skipped (database too new)"
+fi
+}
+
+
 # **************************************************
 # FIXME: Add more tests here! :-)
 # Specifically:
-# - reserve closure (or lack thereof)
 # - revocation (payback, accepting
 #   of coins despite denomination revocation)
 # - refunds

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]