summaryrefslogtreecommitdiff
path: root/src/auditor/test-auditor.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditor/test-auditor.sh')
-rwxr-xr-xsrc/auditor/test-auditor.sh54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 83de1f6c..d56497a9 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -83,7 +83,7 @@ function audit_only () {
# Cleanup to run after the auditor
function post_audit () {
- kill -9 `jobs -p` >/dev/null 2>/dev/null || true
+ kill -TERM `jobs -p` >/dev/null 2>/dev/null || true
echo -n "TeXing ."
../../contrib/render.py test-audit.json test-wire-audit.json < ../../contrib/auditor-report.tex.j2 > test-report.tex || exit_fail "Renderer failed"
@@ -980,6 +980,58 @@ echo "UPDATE app_banktransaction SET date='${OLD_DATE}' WHERE id='${OLD_ID}';" |
+# Test where we trigger an emergency.
+function test_18() {
+echo "===========18: emergency================="
+
+echo "DELETE FROM reserves_out;" | psql -Aqt $DB
+
+run_audit
+
+echo -n "Testing emergency detection... "
+
+jq -e .reserve_balance_summary_wrong_inconsistencies[0] < test-audit.json > /dev/null || exit_fail "Reserve balance inconsistency not detected"
+
+jq -e .emergencies[0] < test-audit.json > /dev/null || exit_fail "Emergency not detected"
+jq -e .emergencies_by_count[0] < test-audit.json > /dev/null || exit_fail "Emergency by count not detected"
+jq -e .amount_arithmetic_inconsistencies[0] < test-audit.json > /dev/null || exit_fail "Escrow balance calculation impossibility not detected"
+
+echo PASS
+
+echo -n "Testing risk/loss calculation... "
+
+AMOUNT=`jq -r .emergencies_risk_by_amount < test-audit.json`
+if test "x$AMOUNT" == "xTESTKUDOS:0"
+then
+ exit_fail "Reported amount wrong: $AMOUNT"
+fi
+AMOUNT=`jq -r .emergencies_risk_by_count < test-audit.json`
+if test "x$AMOUNT" == "xTESTKUDOS:0"
+then
+ exit_fail "Reported amount wrong: $AMOUNT"
+fi
+AMOUNT=`jq -r .emergencies_loss < test-audit.json`
+if test "x$AMOUNT" == "xTESTKUDOS:0"
+then
+ exit_fail "Reported amount wrong: $AMOUNT"
+fi
+AMOUNT=`jq -r .emergencies_loss_by_count < test-audit.json`
+if test "x$AMOUNT" == "xTESTKUDOS:0"
+then
+ exit_fail "Reported amount wrong: $AMOUNT"
+fi
+
+echo PASS
+
+
+# cannot easily undo broad DELETE operation, hence full reload
+echo -n "Reloading database ..."
+full_reload
+echo "DONE"
+}
+
+
+
# **************************************************
# FIXME: Add more tests here! :-)
# Specifically: