aboutsummaryrefslogtreecommitdiff
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.sh63
1 files changed, 57 insertions, 6 deletions
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index bac536ea1..aa8bcb0f1 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -68,15 +68,15 @@ function pre_audit () {
68function audit_only () { 68function audit_only () {
69 # Run the auditor! 69 # Run the auditor!
70 echo -n "Running audit(s) ..." 70 echo -n "Running audit(s) ..."
71 taler-auditor -r -c $CONF -m $MASTER_PUB > test-audit.json 2> test-audit.log || exit_fail "auditor failed" 71 taler-auditor -L INFO -r -c $CONF -m $MASTER_PUB > test-audit.json 2> test-audit.log || exit_fail "auditor failed"
72 echo -n "." 72 echo -n "."
73 # Also do incremental run 73 # Also do incremental run
74 taler-auditor -c $CONF -m $MASTER_PUB > test-audit-inc.json 2> test-audit-inc.log || exit_fail "auditor failed" 74 taler-auditor -L INFO -c $CONF -m $MASTER_PUB > test-audit-inc.json 2> test-audit-inc.log || exit_fail "auditor failed"
75 echo -n "." 75 echo -n "."
76 taler-wire-auditor -r -c $CONF -m $MASTER_PUB > test-wire-audit.json 2> test-wire-audit.log || exit_fail "wire auditor failed" 76 taler-wire-auditor -L INFO -r -c $CONF -m $MASTER_PUB > test-wire-audit.json 2> test-wire-audit.log || exit_fail "wire auditor failed"
77 # Also do incremental run 77 # Also do incremental run
78 echo -n "." 78 echo -n "."
79 taler-wire-auditor -c $CONF -m $MASTER_PUB > test-wire-audit-inc.json 2> test-wire-audit-inc.log || exit_fail "wire auditor failed" 79 taler-wire-auditor -L INFO -c $CONF -m $MASTER_PUB > test-wire-audit-inc.json 2> test-wire-audit-inc.log || exit_fail "wire auditor failed"
80 echo " DONE" 80 echo " DONE"
81} 81}
82 82
@@ -382,6 +382,10 @@ echo "UPDATE deposits SET wire='{\"url\":\"payto://x-taler-bank/localhost:8082/4
382 382
383run_audit 383run_audit
384 384
385echo -n "Testing inconsistency detection... "
386
387jq -e .bad_sig_losses[0] < test-audit.json > /dev/null || exit_fail "Bad signature not detected"
388
385ROW=`jq -e .bad_sig_losses[0].row < test-audit.json` 389ROW=`jq -e .bad_sig_losses[0].row < test-audit.json`
386if test $ROW != 1 390if test $ROW != 1
387then 391then
@@ -406,6 +410,7 @@ then
406 exit_fail "Wrong total bad sig loss, got $LOSS" 410 exit_fail "Wrong total bad sig loss, got $LOSS"
407fi 411fi
408 412
413echo PASS
409# Undo: 414# Undo:
410echo "UPDATE deposits SET wire='$OLD_WIRE' WHERE deposit_serial_id=1" | psql -Aqt $DB 415echo "UPDATE deposits SET wire='$OLD_WIRE' WHERE deposit_serial_id=1" | psql -Aqt $DB
411 416
@@ -1076,16 +1081,62 @@ echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE debit_accoun
1076} 1081}
1077 1082
1078 1083
1084# Test where reserve closure was done properly
1085function test_20() {
1086echo "===========20: reserve closure done properly ================="
1087
1088OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
1089OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
1090RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
1091NEW_TIME=`expr $OLD_TIME - 3024000000000` # 5 weeks
1092NEW_CREDIT=`expr $OLD_VAL + 100`
1093echo "UPDATE reserves_in SET execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
1094echo "UPDATE reserves SET current_balance_val=100+current_balance_val WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
1095
1096# Need to run with the aggregator so the reserve closure happens
1097run_audit aggregator
1079 1098
1099echo -n "Testing reserve closure was done correctly... "
1100
1101jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected reserve not closed inconsistency detected"
1102
1103echo "PASS"
1104
1105# Undo
1106echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
1107}
1108
1109
1110# Test where reserve closure was not done properly
1111function test_21() {
1112echo "===========21: reserve closure missing ================="
1113
1114OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
1115OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
1116RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
1117NEW_TIME=`expr $OLD_TIME - 3024000000000` # 5 weeks
1118NEW_CREDIT=`expr $OLD_VAL + 100`
1119echo "UPDATE reserves_in SET execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
1120echo "UPDATE reserves SET current_balance_val=100+current_balance_val WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
1121
1122# This time, run without the aggregator so the reserve closure is skipped!
1123run_audit
1124
1125echo -n "Testing reserve closure missing detected... "
1126jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null || exit_fail "Reserve not closed inconsistency not detected"
1127echo "PASS"
1128
1129# Undo
1130echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
1131}
1080 1132
1081# ************************************************** 1133# **************************************************
1082# FIXME: Add more tests here! :-) 1134# FIXME: Add more tests here! :-)
1083# Specifically: 1135# Specifically:
1084# - emergencies (detection) 1136# - reserve closure (or lack thereof)
1085# - revocation (payback, accepting 1137# - revocation (payback, accepting
1086# of coins despite denomination revocation) 1138# of coins despite denomination revocation)
1087# - refunds 1139# - refunds
1088# - reserve closure (or lack thereof)
1089# - arithmetic problems 1140# - arithmetic problems
1090# ************************************************** 1141# **************************************************
1091 1142