aboutsummaryrefslogtreecommitdiff
path: root/src/auditor
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-08-29 07:34:44 +0200
committerChristian Grothoff <christian@grothoff.org>2024-08-29 07:34:51 +0200
commit9415aeda026b3af317e1324697478cc94a352f41 (patch)
tree675e3dc7cb33f370f842a0af8bb8a1ea4818d320 /src/auditor
parent74452ec34015cbb8a7eec2214f09e8d671e6ce92 (diff)
fix wire credit auditor reporting
Diffstat (limited to 'src/auditor')
-rw-r--r--src/auditor/taler-helper-auditor-wire-credit.c28
-rwxr-xr-xsrc/auditor/test-auditor.sh224
2 files changed, 129 insertions, 123 deletions
diff --git a/src/auditor/taler-helper-auditor-wire-credit.c b/src/auditor/taler-helper-auditor-wire-credit.c
index afdae8b37..5cf38a5b3 100644
--- a/src/auditor/taler-helper-auditor-wire-credit.c
+++ b/src/auditor/taler-helper-auditor-wire-credit.c
@@ -492,6 +492,8 @@ reserve_in_cb (void *cls,
};
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Duplicate wire offset\n");
qs = TALER_ARL_adb->insert_row_inconsistency (
TALER_ARL_adb->cls,
&ri);
@@ -536,6 +538,9 @@ complain_in_not_found (void *cls,
};
(void) key;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Incoming wire transfer #%llu claimed by exchange not found\n",
+ rii->rowid);
GNUNET_assert (TALER_BANK_CT_RESERVE ==
rii->credit_details.type);
qs = TALER_ARL_adb->insert_reserve_in_inconsistency (
@@ -625,13 +630,12 @@ analyze_credit (
&key);
if (NULL == rii)
{
- // FIXME: probably should instead add to
- // auditor DB and report missing! (& continue!)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Failed to find wire transfer at `%s' in exchange database. Audit ends at this point in time.\n",
+ // FIXME: add to auditor DB and report missing!
+ // (and modify balances!)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to find wire transfer at `%s' in exchange database.\n",
GNUNET_TIME_timestamp2s (credit_details->execution_date));
- process_credits (wa->next);
- return false; /* not an error, just end of processing */
+ return true;
}
/* Update offset */
@@ -651,6 +655,8 @@ analyze_credit (
};
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Reserve public key differs\n");
qs = TALER_ARL_adb->insert_reserve_in_inconsistency (
TALER_ARL_adb->cls,
&riiDb);
@@ -686,6 +692,8 @@ analyze_credit (
};
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Wire transfer amount differs\n");
qs = TALER_ARL_adb->insert_reserve_in_inconsistency (
TALER_ARL_adb->cls,
&riiDb);
@@ -736,6 +744,8 @@ analyze_credit (
};
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Origin bank account differs\n");
qs = TALER_ARL_adb->insert_misattribution_in_inconsistency (
TALER_ARL_adb->cls,
&mii);
@@ -763,6 +773,8 @@ analyze_credit (
};
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Execution date differs\n");
qs = TALER_ARL_adb->insert_row_minor_inconsistencies (
TALER_ARL_adb->cls,
&rmi);
@@ -775,6 +787,10 @@ analyze_credit (
return false;
}
}
+ GNUNET_assert (GNUNET_OK ==
+ free_rii (NULL,
+ &key,
+ rii));
return true;
}
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 588051526..a7283ce19 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -466,7 +466,18 @@ function check_balance() {
BAL=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/${1}.json")
if [ "$BAL" != "$2" ]
then
- exit_fail "$3"
+ exit_fail "$3 (got $BAL, wanted $2)"
+ fi
+ echo "PASS"
+}
+
+
+function check_not_balance() {
+ call_endpoint "balances" "$1"
+ BAL=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/${1}.json")
+ if [ "$BAL" = "$2" ]
+ then
+ exit_fail "$3 (got $BAL, wanted NOT $2)"
fi
echo "PASS"
}
@@ -502,98 +513,89 @@ function test_0() {
# Just to test the endpoint and for logging ...
call_endpoint "balances"
- echo -n "Testing loss balances... "
+ echo -n "Testing bad sig loss balance... "
check_balance \
"aggregation_total_bad_sig_loss" \
"TESTKUDOS:0" \
- "Wrong total bad sig loss from aggregation, got unexpected loss of '$LOSS'"
+ "Wrong total bad sig loss from aggregation, got unexpected loss"
- call_endpoint "balances" "aggregation_total_bad_sig_loss"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_bad_sig_loss.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong total bad sig loss from aggregation, got unexpected loss of '$LOSS'"
- fi
+ echo -n "Testing coin irregular loss balances... "
+ check_balance \
+ "coin_irregular_loss" \
+ "TESTKUDOS:0" \
+ "Wrong total bad sig loss from coins"
- call_endpoint "balances" "coin_irregular_loss"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/coin_irregular_loss.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong total bad sig loss from coins, got unexpected loss of '$LOSS'"
- fi
+ echo -n "Testing reserves bad sig loss balances... "
+ check_balance \
+ "reserves_total_bad_sig_loss" \
+ "TESTKUDOS:0" \
+ "Wrong total bad sig loss from reserves"
- call_endpoint "balances" "reserves_total_bad_sig_loss"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/reserves_total_bad_sig_loss.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong total bad sig loss from reserves, got unexpected loss of '$LOSS'"
- fi
- echo "PASS"
+ echo -n "Test for aggregation wire out delta plus... "
+ check_balance \
+ "aggregation_total_wire_out_delta_plus" \
+ "TESTKUDOS:0" \
+ "Expected total wire out delta plus wrong"
- echo -n "Test for aggregation wire out deltas... "
- call_endpoint "balances" "aggregation_total_wire_out_delta_plus"
- WIRED=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_wire_out_delta_plus.json")
- if [ "$WIRED" != "TESTKUDOS:0" ]
- then
- exit_fail "Expected total wire out delta plus wrong, got '$WIRED'"
- fi
- call_endpoint "balances" "aggregation_total_wire_out_delta_minus"
- WIRED=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_wire_out_delta_minus.json")
- if [ "$WIRED" != "TESTKUDOS:0" ]
- then
- exit_fail "Expected total wire out delta minus wrong, got '$WIRED'"
- fi
- call_endpoint "balances" "total_misattribution_in"
- echo "PASS"
+ echo -n "Test for aggregation wire out delta minus... "
+ check_balance \
+ "aggregation_total_wire_out_delta_minus" \
+ "TESTKUDOS:0" \
+ "Expected total wire out delta minus wrong"
+
+ echo -n "Test for bad incoming delta plus... "
+ check_balance \
+ "total_bad_amount_in_plus" \
+ "TESTKUDOS:0" \
+ "Expected total wire in delta plus wrong"
+
+ echo -n "Test for bad incoming delta minus... "
+ check_balance \
+ "total_bad_amount_in_minus" \
+ "TESTKUDOS:0" \
+ "Expected total wire in delta minus wrong"
echo -n "Test for misattribution amounts... "
+ check_balance \
+ "total_misattribution_in" \
+ "TESTKUDOS:0" \
+ "Expected total misattribution in wrong"
- WIRED=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/total_misattribution_in.json")
- if [ "$WIRED" != "TESTKUDOS:0" ]
- then
- exit_fail "Expected total misattribution in wrong, got $WIRED"
- fi
- echo "PASS"
+ echo -n "Checking for unexpected aggregation delta plus differences... "
+ check_balance \
+ "aggregation_total_arithmetic_delta_plus" \
+ "TESTKUDOS:0" \
+ "Wrong arithmetic delta plus from aggregations"
- echo -n "Checking for unexpected arithmetic differences... "
- call_endpoint "balances" "aggregation_total_arithmetic_delta_plus"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_arithmetic_delta_plus.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong arithmetic delta from aggregations, got unexpected plus of '$LOSS'"
- fi
- call_endpoint "balances" "aggregation_total_arithmetic_delta_minus"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_arithmetic_delta_minus.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong arithmetic delta from aggregation, got unexpected minus of '$LOSS'"
- fi
- call_endpoint "balances" "coins_total_arithmetic_delta_plus"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/coins_total_arithmetic_delta_plus.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong arithmetic delta from coins, got unexpected plus of $LOSS"
- fi
- call_endpoint "balances" "coins_total_arithmetic_delta_minus"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/coins_total_arithmetic_delta_minus.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong arithmetic delta from coins, got unexpected minus of $LOSS"
- fi
- call_endpoint "balances" "reserves_total_arithmetic_delta_plus"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/reserves_total_arithmetic_delta_plus.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong arithmetic delta from reserves, got unexpected plus of $LOSS"
- fi
+ echo -n "Checking for unexpected aggregation delta minus differences... "
+ check_balance \
+ "aggregation_total_arithmetic_delta_minus" \
+ "TESTKUDOS:0" \
+ "Wrong arithmetic delta minus from aggregations"
- call_endpoint "balances" "reserves_total_arithmetic_delta_minus"
- LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/reserves_total_arithmetic_delta_minus.json")
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong arithmetic delta from reserves, got unexpected minus of $LOSS"
- fi
- echo "PASS"
+ echo -n "Checking for unexpected coin delta plus differences... "
+ check_balance \
+ "coins_total_arithmetic_delta_plus" \
+ "TESTKUDOS:0" \
+ "Wrong arithmetic delta plus from coins"
+
+ echo -n "Checking for unexpected coin delta minus differences... "
+ check_balance \
+ "coins_total_arithmetic_delta_minus" \
+ "TESTKUDOS:0" \
+ "Wrong arithmetic delta minus from coins"
+
+ echo -n "Checking for unexpected reserves delta plus... "
+ check_balance \
+ "reserves_total_arithmetic_delta_plus" \
+ "TESTKUDOS:0" \
+ "Wrong arithmetic delta plus from reserves"
+
+ echo -n "Checking for unexpected reserves delta minus... "
+ check_balance \
+ "reserves_total_arithmetic_delta_minus" \
+ "TESTKUDOS:0" \
+ "Wrong arithmetic delta minus from reserves"
echo -n "Checking for unexpected wire out differences "
call_endpoint "wire-out-inconsistency"
@@ -617,15 +619,16 @@ function test_1() {
echo "Checking output"
# if an emergency was detected, that is a bug and we should fail
- call_endpoint "emergency"
- call_endpoint "emergency-by-count"
+ call_endpoint "balances"
echo -n "Test for emergencies... "
+ call_endpoint "emergency"
jq -e .emergency[0] \
< "${MY_TMP_DIR}/emergency.json" \
> /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo PASS
echo -n "Test for emergencies by count... "
+ call_endpoint "emergency-by-count"
jq -e .emergency_by_count[0] \
< "${MY_TMP_DIR}/emergency-by-count.json" \
> /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo PASS
@@ -640,41 +643,28 @@ function test_1() {
echo -n "Check for lag detection... "
# Check wire transfer lag reported (no aggregator!)
- call_endpoint "balances"
- call_endpoint "balances" "total_amount_lag"
- LAG=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/total_amount_lag.json")
- if [ "$LAG" = "TESTKUDOS:0" ]
- then
- exit_fail "Failed to detect lag"
- fi
- echo "PASS"
+ check_not_balance \
+ "total_amount_lag" \
+ "TESTKUDOS:0" \
+ "Failed to detect lag"
- #echo -n "Test for wire amounts... "
- #WIRED=$(jq -r .total_wire_in_delta_plus < test-audit-wire.json")
- #if [ "$WIRED" != "TESTKUDOS:0" ]
- #then
- # exit_fail "Expected total wire delta plus wrong, got $WIRED"
- #fi
- #WIRED=$(jq -r .total_wire_in_delta_minus < test-audit-wire.json")
- #if [ "$WIRED" != "TESTKUDOS:0" ]
- #then
- # exit_fail "Expected total wire delta minus wrong, got $WIRED"
- #fi
- #WIRED=$(jq -r .total_wire_out_delta_plus < test-audit-wire.json")
- #if [ "$WIRED" != "TESTKUDOS:0" ]
- #then
- # exit_fail "Expected total wire delta plus wrong, got $WIRED"
- #fi
- #WIRED=$(jq -r .total_wire_out_delta_minus < test-audit-wire.json")
- #if [ "$WIRED" != "TESTKUDOS:0" ]
- #then
- # exit_fail "Expected total wire delta minus wrong, got $WIRED"
- #fi
- #WIRED=$(jq -r .total_misattribution_in < test-audit-wire.json")
- #if [ "$WIRED" != "TESTKUDOS:0" ]
- #then
- # exit_fail "Expected total misattribution in wrong, got $WIRED"
- #fi
+ echo -n "Test for bad incoming delta plus... "
+ check_balance \
+ "total_bad_amount_in_plus" \
+ "TESTKUDOS:0" \
+ "Expected total wire in delta plus wrong"
+
+ echo -n "Test for bad incoming delta minus... "
+ check_balance \
+ "total_bad_amount_in_minus" \
+ "TESTKUDOS:0" \
+ "Expected total wire in delta minus wrong"
+
+ echo -n "Test for misattribution amounts... "
+ check_balance \
+ "total_misattribution_in" \
+ "TESTKUDOS:0" \
+ "Expected total misattribution in wrong"
# Database was unmodified, no need to undo
}