summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNic Eigel <nic@eigel.ch>2024-04-09 22:52:04 +0200
committerCedric Zwahlen <cedric.zwahlen@students.bfh.ch>2024-04-19 20:47:32 +0200
commit7044ea85d76b91f2daaa077e5c352596a665b714 (patch)
treed933c81f14a2752a62c2aec66ed41048f857a4a0
parent7b07b544581a0854882058efbaa0b120e69ec836 (diff)
downloadexchange-7044ea85d76b91f2daaa077e5c352596a665b714.tar.gz
exchange-7044ea85d76b91f2daaa077e5c352596a665b714.tar.bz2
exchange-7044ea85d76b91f2daaa077e5c352596a665b714.zip
fixing test_auditor "running audits" errors
-rw-r--r--src/auditor/taler-helper-auditor-aggregation.c242
-rw-r--r--src/auditor/taler-helper-auditor-coins.c23
-rw-r--r--src/auditor/taler-helper-auditor-deposits.c79
-rw-r--r--src/auditor/taler-helper-auditor-purses.c21
-rw-r--r--src/auditor/taler-helper-auditor-reserves.c21
-rwxr-xr-xsrc/auditor/test-auditor.sh18
-rw-r--r--src/auditordb/pg_select_purse_expired.c2
-rw-r--r--src/include/taler_auditordb_plugin.h2
8 files changed, 349 insertions, 59 deletions
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c
index a0f2a190f..307c3758b 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -26,6 +26,7 @@
#include "taler_bank_service.h"
#include "taler_signatures.h"
#include "report-lib.h"
+#include <inttypes.h>
/**
@@ -51,7 +52,6 @@ static TALER_ARL_DEF_PP (aggregation_last_wire_out_serial_id);
*/
static TALER_ARL_DEF_AB (aggregation_total_wire_fee_revenue);
-
/**
* Array of reports about row inconsistencies.
*/
@@ -147,8 +147,12 @@ report_amount_arithmetic_inconsistency (
const struct TALER_Amount *auditor,
int profitable)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "getting into amount arithmetc cb\n");
struct TALER_Amount delta;
struct TALER_Amount *target;
+ enum GNUNET_DB_QueryStatus qs;
+ struct TALER_AUDITORDB_AmountArithmeticInconsistency aai;
if (0 < TALER_amount_cmp (exchange,
auditor))
@@ -166,6 +170,23 @@ report_amount_arithmetic_inconsistency (
auditor,
exchange);
}
+ aai.profitable = profitable;
+ aai.operation = (char*) operation;
+ aai.exchange_amount = *exchange;
+ aai.auditor_amount = *auditor;
+
+ qs = TALER_ARL_adb->insert_amount_arithmetic_inconsistency (
+ TALER_ARL_adb->cls,
+ &aai);
+
+ if (qs < 0)
+ {
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " storing amount arithmetic inconsisteny blablubbib\n");
+
+
TALER_ARL_report (report_amount_arithmetic_inconsistencies,
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
@@ -211,6 +232,8 @@ report_coin_arithmetic_inconsistency (
const struct TALER_Amount *auditor,
int profitable)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "getting into airthmetic incons\n");
struct TALER_Amount delta;
struct TALER_Amount *target;
@@ -266,6 +289,9 @@ report_row_inconsistency (const char *table,
uint64_t rowid,
const char *diagnostic)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "getting into report row incons\n");
+
TALER_ARL_report (report_row_inconsistencies,
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("table",
@@ -406,6 +432,9 @@ check_transaction_history_for_deposit (
struct TALER_Amount merchant_loss;
const struct TALER_Amount *deposit_fee;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "getting into check transac history for dep \n");
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking transaction history of coin %s\n",
TALER_B2S (coin_pub));
@@ -448,17 +477,17 @@ check_transaction_history_for_deposit (
GNUNET_JSON_pack_string ("diagnostic",
"multiple deposits of the same coin into the same contract detected")));
}
- deposited = &tl->details.deposit->amount_with_fee; /* according to exchange*/
- fee_claimed = &tl->details.deposit->deposit_fee; /* Fee according to exchange DB */
+ deposited = &tl->details.deposit->amount_with_fee; /* according to exchange*/
+ fee_claimed = &tl->details.deposit->deposit_fee; /* Fee according to exchange DB */
TALER_ARL_amount_add (&expenditures,
&expenditures,
deposited);
/* Check if this deposit is within the remit of the aggregation
we are investigating, if so, include it in the totals. */
- if ( (0 == GNUNET_memcmp (merchant_pub,
- &tl->details.deposit->merchant_pub)) &&
- (0 == GNUNET_memcmp (h_contract_terms,
- &tl->details.deposit->h_contract_terms)) )
+ if ((0 == GNUNET_memcmp (merchant_pub,
+ &tl->details.deposit->merchant_pub)) &&
+ (0 == GNUNET_memcmp (h_contract_terms,
+ &tl->details.deposit->h_contract_terms)))
{
struct TALER_Amount amount_without_fee;
@@ -471,7 +500,7 @@ check_transaction_history_for_deposit (
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Detected applicable deposit of %s\n",
TALER_amount2s (&amount_without_fee));
- deposit_fee = fee_claimed; /* We had a deposit, remember the fee, we may need it */
+ deposit_fee = fee_claimed; /* We had a deposit, remember the fee, we may need it */
}
/* Check that the fees given in the transaction list and in dki match */
if (0 !=
@@ -523,10 +552,10 @@ check_transaction_history_for_deposit (
fee_claimed);
/* Check if this refund is within the remit of the aggregation
we are investigating, if so, include it in the totals. */
- if ( (0 == GNUNET_memcmp (merchant_pub,
- &tl->details.refund->merchant_pub)) &&
- (0 == GNUNET_memcmp (h_contract_terms,
- &tl->details.refund->h_contract_terms)) )
+ if ((0 == GNUNET_memcmp (merchant_pub,
+ &tl->details.refund->merchant_pub)) &&
+ (0 == GNUNET_memcmp (h_contract_terms,
+ &tl->details.refund->h_contract_terms)))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Detected applicable refund of %s\n",
@@ -645,10 +674,10 @@ check_transaction_history_for_deposit (
"Aggregation loss due to refunds is %s\n",
TALER_amount2s (&merchant_loss));
*deposit_gain = *merchant_gain;
- if ( (NULL != deposited) &&
- (NULL != deposit_fee) &&
- (0 == TALER_amount_cmp (&refunds,
- deposited)) )
+ if ((NULL != deposited) &&
+ (NULL != deposit_fee) &&
+ (0 == TALER_amount_cmp (&refunds,
+ deposited)))
{
/* We had a /deposit operation AND /refund operations adding up to the
total deposited value including deposit fee. Thus, we should not
@@ -775,10 +804,14 @@ wire_transfer_information_cb (
TALER_payto_hash (account_pay_uri,
&hpt);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "getting into wire transfer imfo cb\n");
if (0 !=
GNUNET_memcmp (&hpt,
h_payto))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "found incons wire targets hpayto \n\n");
report_row_inconsistency ("wire_targets",
rowid,
"h-payto does not match payto URI");
@@ -791,7 +824,8 @@ wire_transfer_information_cb (
{
struct TALER_Amount balance;
struct TALER_DenominationHashP h_denom_pub;
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " err1\n");
qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls,
coin_pub,
0,
@@ -801,15 +835,19 @@ wire_transfer_information_cb (
&h_denom_pub,
&tl);
}
- if ( (qs < 0) ||
- (NULL == tl) )
+ if ((qs < 0) ||
+ (NULL == tl))
{
wcc->qs = qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "found incons no transca his\n\n");
report_row_inconsistency ("aggregation",
rowid,
"no transaction history for coin claimed in aggregation");
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 1\n");
qs = TALER_ARL_edb->get_known_coin (TALER_ARL_edb->cls,
coin_pub,
&coin);
@@ -825,7 +863,8 @@ wire_transfer_information_cb (
tl);
return;
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 2\n");
qs = TALER_ARL_get_denomination_info_by_hash (&coin.denom_pub_hash,
&issue);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
@@ -841,6 +880,8 @@ wire_transfer_information_cb (
wcc->qs = qs;
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 3\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Testing coin `%s' for validity\n",
TALER_B2S (&coin.coin_pub));
@@ -869,6 +910,8 @@ wire_transfer_information_cb (
"coin denomination signature invalid");
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 4\n");
TALER_denom_sig_free (&coin.denom_sig);
GNUNET_assert (NULL != issue); /* mostly to help static analysis */
/* Check transaction history to see if it supports aggregate
@@ -893,6 +936,8 @@ wire_transfer_information_cb (
"Coin contributes %s to aggregate (deposits after fees and refunds)\n",
TALER_amount2s (&computed_value));
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 6\n");
struct TALER_Amount coin_value_without_fee;
if (TALER_ARL_SR_INVALID_NEGATIVE ==
@@ -900,6 +945,8 @@ wire_transfer_information_cb (
coin_value,
deposit_fee))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 6\n");
wcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
report_amount_arithmetic_inconsistency (
"aggregation (fee structure)",
@@ -909,10 +956,14 @@ wire_transfer_information_cb (
-1);
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 7\n");
if (0 !=
TALER_amount_cmp (&total_deposit_without_refunds,
&coin_value_without_fee))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 8\n");
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Expected coin contribution of %s to aggregate\n",
TALER_amount2s (&coin_value_without_fee));
@@ -924,18 +975,24 @@ wire_transfer_information_cb (
-1);
}
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 9\n");
/* Check other details of wire transfer match */
if (0 != strcmp (account_pay_uri,
wcc->payto_uri))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 10\n");
report_row_inconsistency ("aggregation",
rowid,
"target of outgoing wire transfer do not match hash of wire from deposit");
}
if (GNUNET_TIME_timestamp_cmp (exec_time,
!=,
- wcc->date) )
+ wcc->date))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 11\n");
/* This should be impossible from database constraints */
GNUNET_break (0);
report_row_inconsistency ("aggregation",
@@ -945,12 +1002,16 @@ wire_transfer_information_cb (
/* Add coin's contribution to total aggregate value */
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 12\n");
struct TALER_Amount res;
TALER_ARL_amount_add (&res,
&wcc->total_deposits,
&computed_value);
wcc->total_deposits = res;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 13\n");
}
}
@@ -980,7 +1041,7 @@ get_wire_fee (struct AggregationContext *ac,
timestamp) &&
GNUNET_TIME_timestamp_cmp (pos->end_date,
>,
- timestamp) )
+ timestamp))
return &pos->fees.wire;
if (GNUNET_TIME_timestamp_cmp (pos->start_date,
>,
@@ -1028,8 +1089,8 @@ get_wire_fee (struct AggregationContext *ac,
"Wire fee is %s starting at %s\n",
TALER_amount2s (&wfi->fees.wire),
GNUNET_TIME_timestamp2s (wfi->start_date));
- if ( (NULL == pos) ||
- (NULL == pos->prev) )
+ if ((NULL == pos) ||
+ (NULL == pos->prev))
GNUNET_CONTAINER_DLL_insert (ac->fee_head,
ac->fee_tail,
wfi);
@@ -1039,10 +1100,10 @@ get_wire_fee (struct AggregationContext *ac,
pos->prev,
wfi);
/* Check non-overlaping fee invariant */
- if ( (NULL != wfi->prev) &&
- GNUNET_TIME_timestamp_cmp (wfi->prev->end_date,
- >,
- wfi->start_date) )
+ if ((NULL != wfi->prev) &&
+ GNUNET_TIME_timestamp_cmp (wfi->prev->end_date,
+ >,
+ wfi->start_date))
{
TALER_ARL_report (report_fee_time_inconsistencies,
GNUNET_JSON_PACK (
@@ -1053,10 +1114,10 @@ get_wire_fee (struct AggregationContext *ac,
TALER_JSON_pack_time_abs_human ("time",
wfi->start_date.abs_time)));
}
- if ( (NULL != wfi->next) &&
- GNUNET_TIME_timestamp_cmp (wfi->next->start_date,
- >=,
- wfi->end_date) )
+ if ((NULL != wfi->next) &&
+ GNUNET_TIME_timestamp_cmp (wfi->next->start_date,
+ >=,
+ wfi->end_date))
{
TALER_ARL_report (report_fee_time_inconsistencies,
GNUNET_JSON_PACK (
@@ -1097,19 +1158,31 @@ check_wire_out_cb (void *cls,
struct TALER_Amount exchange_gain;
enum GNUNET_DB_QueryStatus qs;
char *method;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 3checking agg wire fee revenue set zero %s\n\n",
+ TALER_amount_to_string (&TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "\n rowid in method %" PRIu64 "\n", rowid);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "rowidto assert %" PRIu64 "\n", TALER_ARL_USE_PP (
+ aggregation_last_wire_out_serial_id));
/* should be monotonically increasing */
GNUNET_assert (rowid >=
TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id));
TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id) = rowid + 1;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking wire transfer %s over %s performed on %s\n",
TALER_B2S (wtid),
TALER_amount2s (amount),
GNUNET_TIME_timestamp2s (date));
if (NULL == (method = TALER_payto_get_method (payto_uri)))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "found inconsistency\n\n");
report_row_inconsistency ("wire_out",
rowid,
"specified wire address lacks method");
@@ -1123,6 +1196,8 @@ check_wire_out_cb (void *cls,
TALER_amount_set_zero (amount->currency,
&wcc.total_deposits));
wcc.payto_uri = payto_uri;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "looking up wire transfer\n");
qs = TALER_ARL_edb->lookup_wire_transfer (TALER_ARL_edb->cls,
wtid,
&wire_transfer_information_cb,
@@ -1187,9 +1262,22 @@ check_wire_out_cb (void *cls,
TALER_ARL_amount_subtract (&exchange_gain,
&wcc.total_deposits,
&final_amount);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " taler amount to string 1%s\n\n",
+ TALER_amount_to_string (&TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " taler amount to string 2%s\n\n",
+ TALER_amount_to_string (&exchange_gain));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 4checking agg wire fee revenue set zero %s\n\n",
+ TALER_amount_to_string (&TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
+
+
/* Sum up aggregation fees (we simply include the rounding gains) */
- TALER_ARL_amount_add (&TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue),
- &TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue),
+ TALER_ARL_amount_add (&TAC_aggregation_total_wire_fee_revenue,
+ &TAC_aggregation_total_wire_fee_revenue,
&exchange_gain);
/* Check that calculated amount matches actual amount */
@@ -1257,6 +1345,12 @@ analyze_aggregations (void *cls)
enum GNUNET_DB_QueryStatus qsx;
enum GNUNET_DB_QueryStatus qs;
enum GNUNET_DB_QueryStatus qsp;
+ char progress_exists = 1;
+ char balance_exists = 1;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 2checking agg wire fee revenue set zero %s\n\n",
+ TALER_amount_to_string (&TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1277,6 +1371,10 @@ analyze_aggregations (void *cls)
}
else
{
+ if (TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id) == 0)
+ {
+ progress_exists = 0;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming aggregation audit at %llu\n",
(unsigned long long) TALER_ARL_USE_PP (
@@ -1290,11 +1388,40 @@ analyze_aggregations (void *cls)
TALER_ARL_adb->cls,
TALER_ARL_GET_AB (aggregation_total_wire_fee_revenue),
NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " fees %s: \n", TALER_amount_to_string (&TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " woo qsx = %d\n", qsx);
if (0 > qsx)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "in here error\n");
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
return qsx;
}
+
+ if (GNUNET_NO == TALER_amount_is_valid (&TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " woo found none adding some\n");
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
+ balance_exists = 0;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "here no error\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "same oold %" PRIu64 "\n", TALER_ARL_USE_PP (
+ aggregation_last_wire_out_serial_id));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 22checking agg wire fee revenue set zero %s\n\n",
+ TALER_amount_to_string (&TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
+
ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
qs = TALER_ARL_edb->select_wire_out_above_serial_id (
TALER_ARL_edb->cls,
@@ -1323,31 +1450,63 @@ analyze_aggregations (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == ac.qs);
return ac.qs;
}
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " test: %d\n", balance_exists);
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 0)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " no balance found\n");
ac.qs = TALER_ARL_adb->insert_balance (
TALER_ARL_adb->cls,
TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
NULL);
- else
+ }
+ else if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " update balance found\n");
ac.qs = TALER_ARL_adb->update_balance (
TALER_ARL_adb->cls,
TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
NULL);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " else\n");
+ }
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == ac.qs)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " no result, surprise..\n");
+
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != ac.qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == ac.qs);
return ac.qs;
}
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 222333same oold %" PRIu64 "\n", TALER_ARL_USE_PP (
+ aggregation_last_wire_out_serial_id));
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp && progress_exists == 1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " update progress found\n");
qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (aggregation_last_wire_out_serial_id),
NULL);
+ }
else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " insertprogress found\n");
qs = TALER_ARL_adb->insert_auditor_progress (
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (aggregation_last_wire_out_serial_id),
NULL);
+ }
+
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1395,6 +1554,10 @@ run (void *cls,
TALER_amount_set_zero (TALER_ARL_currency,
&TALER_ARL_USE_AB (
aggregation_total_wire_fee_revenue)));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 1checking agg wire fee revenue set zero %s\n\n",
+ TALER_amount_to_string (&TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&total_wire_out_delta_plus));
@@ -1506,6 +1669,9 @@ run (void *cls,
GNUNET_JSON_pack_array_steal (
"wire_fee_time_inconsistencies",
report_fee_time_inconsistencies)));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "done al capone\n");
}
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c
index f88f39eaf..4441a8c7a 100644
--- a/src/auditor/taler-helper-auditor-coins.c
+++ b/src/auditor/taler-helper-auditor-coins.c
@@ -2453,7 +2453,8 @@ analyze_coins (void *cls)
enum GNUNET_DB_QueryStatus qs;
enum GNUNET_DB_QueryStatus qsx;
enum GNUNET_DB_QueryStatus qsp;
-
+ char progress_exists = 1;
+ char balance_exists = 1;
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking denominations...\n");
@@ -2490,6 +2491,10 @@ analyze_coins (void *cls)
}
else
{
+ if (TALER_ARL_USE_PP (coins_withdraw_serial_id) == 0)
+ {
+ progress_exists = 0;
+ }
GNUNET_log (
GNUNET_ERROR_TYPE_INFO,
"Resuming coin audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
@@ -2528,7 +2533,17 @@ analyze_coins (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
return qsx;
}
-
+ if (GNUNET_NO == TALER_amount_is_valid (&TALER_ARL_USE_AB (
+ coin_balance_risk)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Found no balance, starting by 0.\n");
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ coin_balance_risk)));
+ balance_exists = 0;
+ }
/* process withdrawals */
if (0 >
(qs = TALER_ARL_edb->select_withdrawals_above_serial_id (
@@ -2651,7 +2666,7 @@ analyze_coins (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == cc.qs);
return cc.qs;
}
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx)
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 1)
qs = TALER_ARL_adb->update_balance (
TALER_ARL_adb->cls,
TALER_ARL_SET_AB (coin_balance_risk),
@@ -2679,7 +2694,7 @@ analyze_coins (void *cls)
return qs;
}
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp && progress_exists == 1)
qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (coins_withdraw_serial_id),
diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c
index 3dbce0183..f74129ba7 100644
--- a/src/auditor/taler-helper-auditor-deposits.c
+++ b/src/auditor/taler-helper-auditor-deposits.c
@@ -32,6 +32,7 @@
#include "report-lib.h"
#include "taler_dbevents.h"
#include <jansson.h>
+#include <inttypes.h>
/*
--
@@ -149,13 +150,24 @@ test_dc (void *cls,
uint64_t serial_id,
const struct TALER_AUDITORDB_DepositConfirmation *dc)
{
+ printf ("getting into testdc");
struct DepositConfirmationContext *dcc = cls;
bool missing = false;
+ (void) cls;
+ printf ("printing first_missed_coin_serial %lu %" PRId64 "\n",
+ dcc->first_missed_coin_serial, dcc->first_missed_coin_serial);
+ printf ("printing last_seen_coin_serial %lu\n", dcc->last_seen_coin_serial);
+ printf ("printing missed_count %llu\n", dcc->missed_count);
+ printf ("last seen coin serial%" PRId64 "\n", dcc->last_seen_coin_serial);
+ enum GNUNET_DB_QueryStatus qs;
dcc->last_seen_coin_serial = serial_id;
+ printf ("nach zuweisung : %" PRId64 "\n", dcc->last_seen_coin_serial);
+ printf (" num coins : %u\n", dc->num_coins);
for (unsigned int i = 0; i < dc->num_coins; i++)
{
- enum GNUNET_DB_QueryStatus qs;
+ printf ("cant print frmo here");
+
struct GNUNET_TIME_Timestamp exchange_timestamp;
struct TALER_Amount deposit_fee;
@@ -167,6 +179,7 @@ test_dc (void *cls,
dc->refund_deadline,
&deposit_fee,
&exchange_timestamp);
+ printf ("qs1 %d \n\n", qs);
missing |= (0 == qs);
if (qs < 0)
{
@@ -175,13 +188,37 @@ test_dc (void *cls,
return GNUNET_SYSERR;
}
}
+ qs = TALER_ARL_adb->delete_deposit_confirmation (TALER_ARL_adb->cls,
+ dcc->last_seen_coin_serial);
+ if (qs < 0)
+ {
+ printf ("failed");
+ GNUNET_break (0); /* DB error, complain */
+ dcc->qs = qs;
+ return GNUNET_SYSERR;
+ }
+ printf ("should have deleted");
+ if (dcc->qs == 1)
+ {
+ (void) cls;
+ printf ("qs=1\n");
+
+ }
+ printf ("qs2 %d \n\n", dcc->qs);
+ printf ("%s", missing ? "true\n\n" : "false \n\n");
if (! missing)
{
+ printf ("found : %" PRId64 "\n", dcc->last_seen_coin_serial);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found deposit %s in exchange database\n",
GNUNET_h2s (&dc->h_contract_terms.hash));
+
if (TALER_ARL_do_abort ())
+ {
+ printf (" 1aborting");
return GNUNET_SYSERR;
+ }
+
return GNUNET_OK; /* all coins found, all good */
}
/* deposit confirmation missing! report! */
@@ -203,7 +240,10 @@ test_dc (void *cls,
&dcc->missed_amount,
&dc->total_without_fee);
if (TALER_ARL_do_abort ())
+ {
+ printf (" 2aborting");
return GNUNET_SYSERR;
+ }
return GNUNET_OK;
}
@@ -229,7 +269,8 @@ analyze_deposit_confirmations (void *cls)
TALER_ARL_adb->cls,
TALER_ARL_GET_PP (deposit_confirmation_serial_id),
NULL);
-
+ printf ("last dep conf serial id %" PRId64 "\n", TALER_ARL_USE_PP (
+ deposit_confirmation_serial_id));
if (0 > qsp)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp);
@@ -237,11 +278,14 @@ analyze_deposit_confirmations (void *cls)
}
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp)
{
+ printf ("no progress found\n");
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"First analysis using deposit auditor, starting audit from scratch\n");
}
else
{
+ printf ("apparently found %llu\n", (unsigned long long) TALER_ARL_USE_PP (
+ deposit_confirmation_serial_id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming deposit confirmation audit at %llu\n",
(unsigned long long) TALER_ARL_USE_PP (
@@ -255,15 +299,28 @@ analyze_deposit_confirmations (void *cls)
dcc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
dcc.missed_count = 0LLU;
dcc.first_missed_coin_serial = UINT64_MAX;
+ printf ("printing lastdepconfserialid %lu\n",
+ TALER_ARL_USE_PP (deposit_confirmation_serial_id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"lastdepconfserialid %lu\n",
TALER_ARL_USE_PP (deposit_confirmation_serial_id));
+
+ printf ("printing first_missed_coin_serial %lu %" PRId64 "\n",
+ dcc.first_missed_coin_serial, dcc.first_missed_coin_serial);
+ printf ("printing last_seen_coin_serial %lu\n", dcc.last_seen_coin_serial);
+ printf ("printing missed_count %llu\n", dcc.missed_count);
+ printf ("last seen coin serial%" PRId64 "\n", dcc.last_seen_coin_serial);
+
qsx = TALER_ARL_adb->get_deposit_confirmations (
TALER_ARL_adb->cls,
TALER_ARL_USE_PP (deposit_confirmation_serial_id),
true, /* return suppressed */
&test_dc,
&dcc);
+
+ printf ("testing done");
+
+
if (0 > qsx)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
@@ -296,13 +353,12 @@ analyze_deposit_confirmations (void *cls)
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (deposit_confirmation_serial_id),
NULL);
- if (0 >= qs)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Failed to update auditor DB, not recording progress\n");
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
+ /* if (0 >= qs) {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Failed to update auditor DB, not recording progress\n");
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+ return qs;
+ }*/
number_missed_deposit_confirmations = (json_int_t) dcc.missed_count;
total_missed_deposit_confirmations = dcc.missed_amount;
@@ -344,7 +400,7 @@ db_notify (void *cls,
}
GNUNET_assert (NULL !=
(report_deposit_confirmation_inconsistencies = json_array ()));
-
+ printf ("received event");
if (GNUNET_OK !=
TALER_ARL_setup_sessions_and_run (&analyze_deposit_confirmations,
NULL))
@@ -352,7 +408,7 @@ db_notify (void *cls,
global_ret = EXIT_FAILURE;
return;
}
-
+ printf ("finished event");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deposit audit complete\n");
TALER_ARL_done (
@@ -454,6 +510,7 @@ run (void *cls,
global_ret = EXIT_FAILURE;
return;
}
+ printf ("Finished");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deposit audit complete\n");
TALER_ARL_done (
diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c
index 967ac13a7..6cc04092c 100644
--- a/src/auditor/taler-helper-auditor-purses.c
+++ b/src/auditor/taler-helper-auditor-purses.c
@@ -1088,6 +1088,8 @@ analyze_purses (void *cls)
enum GNUNET_DB_QueryStatus qsx;
enum GNUNET_DB_QueryStatus qs;
enum GNUNET_DB_QueryStatus qsp;
+ char progress_exists = 1;
+ char balance_exists = 1;
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1113,6 +1115,10 @@ analyze_purses (void *cls)
}
else
{
+ if (TALER_ARL_USE_PP (purse_account_merge_serial_id) == 0)
+ {
+ progress_exists = 0;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming purse audit at %llu/%llu/%llu/%llu/%llu\n",
(unsigned long long) TALER_ARL_USE_PP (
@@ -1136,6 +1142,17 @@ analyze_purses (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
return qsx;
}
+ if (GNUNET_NO == TALER_amount_is_valid (&TALER_ARL_USE_AB (
+ purse_global_balance)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Found no balance, starting by 0.\n");
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ purse_global_balance)));
+ balance_exists = 0;
+ }
pc.purses = GNUNET_CONTAINER_multihashmap_create (512,
GNUNET_NO);
@@ -1211,7 +1228,7 @@ analyze_purses (void *cls)
GNUNET_CONTAINER_multihashmap_destroy (pc.purses);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != pc.qs)
return qs;
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 0)
{
qs = TALER_ARL_adb->insert_balance (
TALER_ARL_adb->cls,
@@ -1230,7 +1247,7 @@ analyze_purses (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
return qs;
}
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp && progress_exists == 1)
qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (purse_account_merge_serial_id),
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c
index aa35c6a75..daba657cb 100644
--- a/src/auditor/taler-helper-auditor-reserves.c
+++ b/src/auditor/taler-helper-auditor-reserves.c
@@ -1602,6 +1602,8 @@ analyze_reserves (void *cls)
enum GNUNET_DB_QueryStatus qsx;
enum GNUNET_DB_QueryStatus qs;
enum GNUNET_DB_QueryStatus qsp;
+ char progress_exists = 1;
+ char balance_exists = 1;
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1629,6 +1631,10 @@ analyze_reserves (void *cls)
}
else
{
+ if (TALER_ARL_USE_PP (reserves_reserve_in_serial_id) == 0)
+ {
+ progress_exists = 0;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming reserve audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
(unsigned long long) TALER_ARL_USE_PP (
@@ -1664,6 +1670,17 @@ analyze_reserves (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
return qsx;
}
+ if (GNUNET_NO == TALER_amount_is_valid (&TALER_ARL_USE_AB (
+ reserves_reserve_total_balance)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Found no balance, starting by 0.\n");
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ reserves_reserve_total_balance)));
+ balance_exists = 0;
+ }
rc.reserves = GNUNET_CONTAINER_multihashmap_create (512,
GNUNET_NO);
rc.revoked = GNUNET_CONTAINER_multihashmap_create (4,
@@ -1752,7 +1769,7 @@ analyze_reserves (void *cls)
GNUNET_CONTAINER_multihashmap_destroy (rc.revoked);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != rc.qs)
return qs;
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 0)
{
qs = TALER_ARL_adb->insert_balance (
TALER_ARL_adb->cls,
@@ -1783,7 +1800,7 @@ analyze_reserves (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
return qs;
}
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp && progress_exists == 1)
qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (reserves_reserve_in_serial_id),
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 2cfea0532..da2316ca1 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -244,6 +244,24 @@ function audit_only () {
2> "${MY_TMP_DIR}/test-audit-wire-inc.err" \
|| exit_fail "wire audit inc failed (see ${MY_TMP_DIR}/test-audit-wire-inc.*)"
echo -n "."
+ $VALGRIND taler-helper-auditor-purses \
+ -i \
+ -L DEBUG \
+ -c "$CONF" \
+ -t \
+ > "${MY_TMP_DIR}/test-audit-purses.out" \
+ 2> "${MY_TMP_DIR}/test-audit-purses.err" \
+ || exit_fail "audit purses failed"
+ echo -n "."
+ $VALGRIND taler-helper-auditor-purses \
+ -i \
+ -L DEBUG \
+ -c "$CONF" \
+ -t \
+ > "${MY_TMP_DIR}/test-audit-purses-inc.out" \
+ 2> "${MY_TMP_DIR}/test-audit-purses-inc.err" \
+ || exit_fail "audit purses inc failed"
+ echo -n "."
echo " DONE"
}
diff --git a/src/auditordb/pg_select_purse_expired.c b/src/auditordb/pg_select_purse_expired.c
index 77c6d3b26..5fda60103 100644
--- a/src/auditordb/pg_select_purse_expired.c
+++ b/src/auditordb/pg_select_purse_expired.c
@@ -133,7 +133,7 @@ TAH_PG_select_purse_expired (
",expiration_date"
",balance"
" FROM auditor_purses"
- " AND expiration_date<$1;");
+ " WHERE expiration_date<$1;");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"auditor_select_expired_purses",
params,
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
index 2beb3e0e0..8bd501480 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -213,7 +213,7 @@ struct TALER_AUDITORDB_Generic_Update
struct TALER_AUDITORDB_AmountArithmeticInconsistency
{
unsigned int row_id;
- struct GNUNET_HashCode operation;
+ char*operation;
struct TALER_Amount exchange_amount;
struct TALER_Amount auditor_amount;
bool profitable;