commit 7fbc615d24b79db9df13f2fc5be4437c364ae35a
parent 5e7136b6d261c4c05b693549261f59dacaccedbe
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 15 Sep 2024 18:03:36 +0200
fixes for auditor test #22
Diffstat:
4 files changed, 65 insertions(+), 74 deletions(-)
diff --git a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.c b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.c
@@ -13,8 +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>
@@ -28,28 +26,33 @@
"taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.h"
/**
-* Add denomination-key-validity-withdraw-inconsistency 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
-*/
+ * Add denomination-key-validity-withdraw-inconsistency to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate
+ */
static enum GNUNET_GenericReturnValue
process_denomination_key_validity_withdraw_inconsistency (
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- TALER_JSON_pack_time_abs_human ("execution_date", dc->execution_date),
- GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub),
- GNUNET_JSON_pack_data_auto ("denompub_h", &dc->denompub_h)
-
+ GNUNET_JSON_pack_uint64 ("row_id",
+ dc->row_id),
+ GNUNET_JSON_pack_uint64 ("problem_row_id",
+ dc->problem_row_id),
+ TALER_JSON_pack_time_abs_human ("execution_date",
+ dc->execution_date),
+ GNUNET_JSON_pack_data_auto ("reserve_pub",
+ &dc->reserve_pub),
+ GNUNET_JSON_pack_data_auto ("denompub_h",
+ &dc->denompub_h),
+ GNUNET_JSON_pack_bool ("suppressed",
+ dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
@@ -71,6 +74,9 @@ TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
(void) rh;
(void) connection_cls;
@@ -85,34 +91,28 @@ TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_get (
TALER_EC_GENERIC_DB_SETUP_FAILED,
NULL);
}
- ja = json_array ();
- GNUNET_break (NULL != ja);
- int64_t limit = -20;
- uint64_t offset;
-
TALER_MHD_parse_request_snumber (connection,
"limit",
&limit);
-
if (limit < 0)
offset = INT64_MAX;
else
offset = 0;
-
TALER_MHD_parse_request_number (connection,
"offset",
&offset);
-
- bool return_suppressed = false;
- const char *ret_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "return_suppressed");
- if (ret_s != NULL && strcmp (ret_s, "true") == 0)
{
- return_suppressed = true;
+ const char *ret_s
+ = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if (ret_s != NULL && strcmp (ret_s, "true") == 0)
+ {
+ return_suppressed = true;
+ }
}
-
-
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_denomination_key_validity_withdraw_inconsistency (
TAH_plugin->cls,
limit,
@@ -120,7 +120,6 @@ TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_get (
return_suppressed,
&process_denomination_key_validity_withdraw_inconsistency,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
@@ -1697,13 +1697,11 @@ function test_22() {
run_audit
check_auditor_running
- call_endpoint "denomination-key-validity-withdraw-inconsistency"
-
echo -n "Testing inconsistency detection... "
- jq -e .denomination_key_validity_withdraw_inconsistency[0] < "${MY_TMP_DIR}/denomination-key-validity-withdraw-inconsistency.json" \
- > /dev/null || exit_fail "Denomination key withdraw inconsistency for $S_DENOM not detected"
-
- echo "PASS"
+ check_report \
+ "denomination-key-validity-withdraw-inconsistency" \
+ "suppressed" "false"
+ call_endpoint "denomination-key-validity-withdraw-inconsistency"
# Undo modification
echo "UPDATE exchange.denominations SET expire_withdraw=${OLD_WEXP} WHERE denominations_serial='${S_DENOM}';" | psql -Aqt "$DB"
diff --git a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c
@@ -13,16 +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_error_codes.h"
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
#include "pg_helper.h"
-
#include "pg_get_denomination_key_validity_withdraw_inconsistency.h"
+
/**
* Closure for #denomination_key_validity_withdraw_inconsistency_cb().
*/
@@ -69,18 +67,20 @@ denomination_key_validity_withdraw_inconsistency_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
- uint64_t serial_id;
-
struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency dc;
-
struct GNUNET_PQ_ResultSpec rs[] = {
-
- GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &dc.row_id),
+ GNUNET_PQ_result_spec_uint64 ("problem_row_id",
+ &dc.problem_row_id),
GNUNET_PQ_result_spec_absolute_time ("execution_date",
&dc.execution_date),
- GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub),
- GNUNET_PQ_result_spec_auto_from_type ("denompub_h", &dc.denompub_h),
-
+ GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
+ &dc.reserve_pub),
+ GNUNET_PQ_result_spec_auto_from_type ("denompub_h",
+ &dc.denompub_h),
+ GNUNET_PQ_result_spec_bool ("suppressed",
+ &dc.suppressed),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -94,11 +94,8 @@ denomination_key_validity_withdraw_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)
@@ -112,15 +109,12 @@ TAH_PG_get_denomination_key_validity_withdraw_inconsistency (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
- TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback
- cb,
+ bool return_suppressed,
+ TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback 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),
@@ -138,12 +132,14 @@ TAH_PG_get_denomination_key_validity_withdraw_inconsistency (
"auditor_denomination_key_validity_withdraw_inconsistency_get_desc",
"SELECT"
" row_id"
+ ",problem_row_id"
",execution_date"
",reserve_pub"
",denompub_h"
+ ",suppressed"
" FROM auditor_denomination_key_validity_withdraw_inconsistency"
" WHERE (row_id < $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id DESC"
" LIMIT $3"
);
@@ -151,27 +147,27 @@ TAH_PG_get_denomination_key_validity_withdraw_inconsistency (
"auditor_denomination_key_validity_withdraw_inconsistency_get_asc",
"SELECT"
" row_id"
+ ",problem_row_id"
",execution_date"
",reserve_pub"
",denompub_h"
+ ",suppressed"
" FROM auditor_denomination_key_validity_withdraw_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_denomination_key_validity_withdraw_inconsistency_get_asc"
- :
- "auditor_denomination_key_validity_withdraw_inconsistency_get_desc",
- params,
- &
- denomination_key_validity_withdraw_inconsistency_cb,
- &dcc);
-
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_denomination_key_validity_withdraw_inconsistency_get_asc"
+ : "auditor_denomination_key_validity_withdraw_inconsistency_get_desc",
+ params,
+ &denomination_key_validity_withdraw_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/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
@@ -347,6 +347,7 @@ struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency
struct GNUNET_TIME_Absolute execution_date;
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_DenominationHashP denompub_h;
+ bool suppressed;
};
/**
@@ -531,14 +532,12 @@ typedef enum GNUNET_GenericReturnValue
* 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_DenominationKeyValidityWithdrawInconsistencyCallback)(
void *cls,
- uint64_t serial_id,
const struct
TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc);