diff options
Diffstat (limited to 'src/auditor/test-auditor.sh')
-rwxr-xr-x | src/auditor/test-auditor.sh | 63 |
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 () { | |||
68 | function audit_only () { | 68 | function 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 | ||
383 | run_audit | 383 | run_audit |
384 | 384 | ||
385 | echo -n "Testing inconsistency detection... " | ||
386 | |||
387 | jq -e .bad_sig_losses[0] < test-audit.json > /dev/null || exit_fail "Bad signature not detected" | ||
388 | |||
385 | ROW=`jq -e .bad_sig_losses[0].row < test-audit.json` | 389 | ROW=`jq -e .bad_sig_losses[0].row < test-audit.json` |
386 | if test $ROW != 1 | 390 | if test $ROW != 1 |
387 | then | 391 | then |
@@ -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" |
407 | fi | 411 | fi |
408 | 412 | ||
413 | echo PASS | ||
409 | # Undo: | 414 | # Undo: |
410 | echo "UPDATE deposits SET wire='$OLD_WIRE' WHERE deposit_serial_id=1" | psql -Aqt $DB | 415 | echo "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 | ||
1085 | function test_20() { | ||
1086 | echo "===========20: reserve closure done properly =================" | ||
1087 | |||
1088 | OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` | ||
1089 | OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` | ||
1090 | RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` | ||
1091 | NEW_TIME=`expr $OLD_TIME - 3024000000000` # 5 weeks | ||
1092 | NEW_CREDIT=`expr $OLD_VAL + 100` | ||
1093 | echo "UPDATE reserves_in SET execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB | ||
1094 | echo "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 | ||
1097 | run_audit aggregator | ||
1079 | 1098 | ||
1099 | echo -n "Testing reserve closure was done correctly... " | ||
1100 | |||
1101 | jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected reserve not closed inconsistency detected" | ||
1102 | |||
1103 | echo "PASS" | ||
1104 | |||
1105 | # Undo | ||
1106 | echo "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 | ||
1111 | function test_21() { | ||
1112 | echo "===========21: reserve closure missing =================" | ||
1113 | |||
1114 | OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` | ||
1115 | OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` | ||
1116 | RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` | ||
1117 | NEW_TIME=`expr $OLD_TIME - 3024000000000` # 5 weeks | ||
1118 | NEW_CREDIT=`expr $OLD_VAL + 100` | ||
1119 | echo "UPDATE reserves_in SET execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB | ||
1120 | echo "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! | ||
1123 | run_audit | ||
1124 | |||
1125 | echo -n "Testing reserve closure missing detected... " | ||
1126 | jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null || exit_fail "Reserve not closed inconsistency not detected" | ||
1127 | echo "PASS" | ||
1128 | |||
1129 | # Undo | ||
1130 | echo "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 | ||