diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-09-15 01:13:52 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-09-15 01:13:52 +0200 |
commit | f1c1569737585d703d0d201809ba7d1411c9603b (patch) | |
tree | a25da0c99c41d2381829b6ab3893b59a4622bb95 /src | |
parent | 6c7d87da66d0fef808496ad0cea944e6f3fa0c93 (diff) |
fix test_18
Diffstat (limited to 'src')
-rw-r--r-- | src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c | 18 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_emergency-get.c | 4 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c | 8 | ||||
-rwxr-xr-x | src/auditor/test-auditor.sh | 2 | ||||
-rw-r--r-- | src/auditordb/pg_get_amount_arithmetic_inconsistency.c | 48 | ||||
-rw-r--r-- | src/auditordb/pg_update_emergency.c | 10 | ||||
-rw-r--r-- | src/include/taler_auditordb_plugin.h | 3 |
7 files changed, 42 insertions, 51 deletions
diff --git a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c index e8e64e3d0..6b51b5acb 100644 --- a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c @@ -13,7 +13,6 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - #include "platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -30,30 +29,32 @@ * Add deposit confirmation to the list. * * @param[in,out] cls a `json_t *` array to extend - * @param serial_id location of the @a dc in the database * @param dc struct of inconsistencies * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating */ static enum GNUNET_GenericReturnValue add_amount_arithmetic_inconsistency ( void *cls, - uint64_t serial_id, const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc) { json_t *list = cls; json_t *obj; obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_int64 ("row_id", - serial_id), - GNUNET_JSON_pack_data_auto ("operation", - &dc->operation), + GNUNET_JSON_pack_uint64 ("row_id", + dc->row_id), + GNUNET_JSON_pack_uint64 ("problem_row_id", + dc->problem_row_id), + GNUNET_JSON_pack_string ("operation", + dc->operation), TALER_JSON_pack_amount ("exchange_amount", &dc->exchange_amount), TALER_JSON_pack_amount ("auditor_amount", &dc->auditor_amount), GNUNET_JSON_pack_bool ("profitable", - dc->profitable) + dc->profitable), + GNUNET_JSON_pack_bool ("suppressed", + dc->suppressed) ); GNUNET_break (0 == json_array_append_new (list, @@ -123,7 +124,6 @@ TAH_AMOUNT_ARITHMETIC_INCONSISTENCY_handler_get ( return_suppressed, &add_amount_arithmetic_inconsistency, ja); - if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); diff --git a/src/auditor/taler-auditor-httpd_emergency-get.c b/src/auditor/taler-auditor-httpd_emergency-get.c index 089de70ef..7bfee600f 100644 --- a/src/auditor/taler-auditor-httpd_emergency-get.c +++ b/src/auditor/taler-auditor-httpd_emergency-get.c @@ -42,7 +42,7 @@ process_emergency ( obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_uint64 ("row_id", - &dc->row_id), + dc->row_id), GNUNET_JSON_pack_data_auto ("denompub_h", &dc->denompub_h), TALER_JSON_pack_amount ("denom_risk", @@ -56,7 +56,7 @@ process_emergency ( TALER_JSON_pack_amount ("value", &dc->value), GNUNET_JSON_pack_bool ("suppressed", - &dc->suppressed) + dc->suppressed) ); GNUNET_break (0 == json_array_append_new (list, diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c index 4d8bbad3f..e9f4bf63b 100644 --- a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c @@ -41,16 +41,16 @@ process_reserve_not_closed_inconsistency ( json_t *obj; obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_int64 ("row_id", - dc->row_id), + GNUNET_JSON_pack_uint64 ("row_id", + dc->row_id), GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub), TALER_JSON_pack_amount ("balance", &dc->balance), TALER_JSON_pack_time_abs_human ("expiration_time", dc->expiration_time), - GNUNET_JSON_pack_data_auto ("diagnostic", - &dc->diagnostic), + GNUNET_JSON_pack_string ("diagnostic", + dc->diagnostic), GNUNET_JSON_pack_bool ("suppressed", dc->suppressed) ); diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index b773e59bc..3c49d8f1f 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -1513,7 +1513,7 @@ function test_18() { "suppressed" "false" echo -n "Testing emergency detection by count... " check_report \ - "emergency-by-count" + "emergency-by-count" \ "suppressed" "false" echo -n "Testing escrow balance calculation impossibility... " check_report \ diff --git a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c index 4b09ee39b..5bd9a284a 100644 --- a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c +++ b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c @@ -13,7 +13,6 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - #include "platform.h" #include "taler_error_codes.h" #include "taler_dbevents.h" @@ -68,14 +67,12 @@ amount_arithmetic_inconsistency_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { - uint64_t serial_id; - struct TALER_AUDITORDB_AmountArithmeticInconsistency dc; - struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("row_id", - &serial_id), - // TODO: what type is this exactly + &dc.row_id), + GNUNET_PQ_result_spec_uint64 ("problem_row_id", + &dc.problem_row_id), GNUNET_PQ_result_spec_string ("operation", &dc.operation), TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_amount", @@ -84,7 +81,8 @@ amount_arithmetic_inconsistency_cb (void *cls, &dc.auditor_amount), GNUNET_PQ_result_spec_bool ("profitable", &dc.profitable), - + GNUNET_PQ_result_spec_bool ("suppressed", + &dc.suppressed), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -98,11 +96,8 @@ amount_arithmetic_inconsistency_cb (void *cls, dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } - dcc->qs = i + 1; - rval = dcc->cb (dcc->cb_cls, - serial_id, &dc); GNUNET_PQ_cleanup_result (rs); if (GNUNET_OK != rval) @@ -116,13 +111,12 @@ TAH_PG_get_amount_arithmetic_inconsistency ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed + bool return_suppressed, TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, void *cb_cls) { - uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); - struct PostgresClosure *pg = cls; + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_bool (return_suppressed), @@ -140,13 +134,15 @@ TAH_PG_get_amount_arithmetic_inconsistency ( "auditor_amount_arithmetic_inconsistency_select_desc", "SELECT" " row_id" + ",problem_row_id" ",operation" ",exchange_amount" ",auditor_amount" ",profitable" + ",suppressed" " FROM auditor_amount_arithmetic_inconsistency" " WHERE (row_id<$1)" - " AND ($2 OR suppressed is false)" + " AND ($2 OR NOT suppressed)" " ORDER BY row_id DESC" " LIMIT $3" ); @@ -154,28 +150,28 @@ TAH_PG_get_amount_arithmetic_inconsistency ( "auditor_amount_arithmetic_inconsistency_select_asc", "SELECT" " row_id" + ",problem_row_id" ",operation" ",exchange_amount" ",auditor_amount" ",profitable" + ",suppressed" " FROM auditor_amount_arithmetic_inconsistency" " WHERE (row_id>$1)" - " AND ($2 OR suppressed is false)" + " AND ($2 OR NOT suppressed)" " ORDER BY row_id ASC" " LIMIT $3" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) ? - "auditor_amount_arithmetic_inconsistency_select_asc" - : - "auditor_amount_arithmetic_inconsistency_select_desc", - params, - &amount_arithmetic_inconsistency_cb, - &dcc); - - + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_amount_arithmetic_inconsistency_select_asc" + : "auditor_amount_arithmetic_inconsistency_select_desc", + params, + &amount_arithmetic_inconsistency_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); return qs; -}
\ No newline at end of file +} diff --git a/src/auditordb/pg_update_emergency.c b/src/auditordb/pg_update_emergency.c index 41956675d..a4d542c00 100644 --- a/src/auditordb/pg_update_emergency.c +++ b/src/auditordb/pg_update_emergency.c @@ -13,17 +13,14 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include "taler_pq_lib.h" #include "pg_helper.h" - #include "pg_update_emergency.h" -/* -Update a given resource – for now this only means suppressing -*/ +/** + * Update a given resource – for now this only means suppressing + */ enum GNUNET_DB_QueryStatus TAH_PG_update_emergency ( void *cls, @@ -36,7 +33,6 @@ TAH_PG_update_emergency ( GNUNET_PQ_query_param_end }; - PREPARE (pg, "update_emergency", "UPDATE auditor_emergency SET" diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index ad2eae980..4462f622b 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -222,6 +222,7 @@ struct TALER_AUDITORDB_AmountArithmeticInconsistency struct TALER_Amount exchange_amount; struct TALER_Amount auditor_amount; bool profitable; + bool suppressed; }; /** @@ -404,14 +405,12 @@ struct TALER_AUDITORDB_Balances * the auditor's database. * * @param cls closure - * @param serial_id location of the @a dc in the database * @param dc the structure itself * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating */ typedef enum GNUNET_GenericReturnValue (*TALER_AUDITORDB_AmountArithmeticInconsistencyCallback)( void *cls, - uint64_t serial_id, const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc); /** |