add test to check deposit inconsistency detection logic

This commit is contained in:
Christian Grothoff 2019-10-26 22:36:40 +02:00
parent 7b1d8024db
commit c308e89eaa
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 48 additions and 2 deletions

View File

@ -224,7 +224,7 @@ The total amount the exchange currently lags behind is
Note that some lag is perfectly normal. Note that some lag is perfectly normal.
Below, we report {\em all} deposit confirmations that are lagging behind. Below, we report {\em all} deposit confirmations that are lagging behind.
% Table generation tested by testcase #XX in test-auditor.sh % Table generation tested by testcase #25 in test-auditor.sh
{% if data.deposit_confirmation_inconsistencies|length() == 0 %} {% if data.deposit_confirmation_inconsistencies|length() == 0 %}
{\bf No deposit confirmations that are lagging behind detected.} {\bf No deposit confirmations that are lagging behind detected.}

View File

@ -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 24` ALL_TESTS=`seq 0 25`
# $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
@ -138,6 +138,7 @@ echo "Checking output"
# if an emergency was detected, that is a bug and we should fail # if an emergency was detected, that is a bug and we should fail
echo -n "Test for emergencies... " echo -n "Test for emergencies... "
jq -e .emergencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo PASS jq -e .emergencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo PASS
jq -e .deposit_confirmation_inconsistencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected deposit confirmation inconsistency detected" || echo PASS
echo -n "Test for emergencies by count... " 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 PASS jq -e .emergencies_by_count[0] < test-audit.json > /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo PASS
@ -1406,6 +1407,48 @@ fi
} }
# Test for missing deposits in exchange database.
function test_25() {
echo "===========25: deposits missing ==========="
# Modify denom_sig, so it is wrong
echo "DELETE FROM deposits;" | psql -Aqt $DB
echo "DELETE FROM deposits WHERE deposit_serial_id=1;" | psql -Aqt $DB
run_audit
echo -n "Testing inconsistency detection... "
jq -e .deposit_confirmation_inconsistencies[0] < test-audit.json > /dev/null || exit_fail "Deposit confirmation inconsistency NOT detected"
#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 -er .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: Add more tests here! :-) # FIXME: Add more tests here! :-)
# Specifically: # Specifically:
@ -1463,6 +1506,9 @@ check_with_database()
# *************** Main logic starts here ************** # *************** Main logic starts here **************
# ####### Setup globals ###### # ####### Setup globals ######