aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-09-16 23:13:31 +0200
committerChristian Grothoff <christian@grothoff.org>2024-09-16 23:13:31 +0200
commitb217d958aa2f0d65c31cebd4ed02a21e5288bbe3 (patch)
tree7d5cb80d1b7419235233810294c1d45dfc00f059 /src
parent264d92ee564668d67aee26fdf40cb7f80eabbd63 (diff)
fix test-10
Diffstat (limited to 'src')
-rw-r--r--src/auditor/taler-auditor-httpd_closure-lags-get.c4
-rw-r--r--src/auditor/taler-auditor-httpd_denomination-pending-get.c16
-rw-r--r--src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-get.c52
-rw-r--r--src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c2
-rw-r--r--src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c2
-rwxr-xr-xsrc/auditor/test-auditor.sh38
-rw-r--r--src/auditordb/0002-auditor_row_minor_inconsistencies.sql2
-rw-r--r--src/auditordb/pg_get_purse_not_closed_inconsistencies.c53
-rw-r--r--src/auditordb/pg_get_row_minor_inconsistencies.c22
-rw-r--r--src/auditordb/pg_insert_row_minor_inconsistencies.c2
-rw-r--r--src/include/taler_auditordb_plugin.h3
11 files changed, 94 insertions, 102 deletions
diff --git a/src/auditor/taler-auditor-httpd_closure-lags-get.c b/src/auditor/taler-auditor-httpd_closure-lags-get.c
index 4925a9253..2a226ce4a 100644
--- a/src/auditor/taler-auditor-httpd_closure-lags-get.c
+++ b/src/auditor/taler-auditor-httpd_closure-lags-get.c
@@ -127,11 +127,11 @@ TAH_CLOSURE_LAGS_handler_get (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
- "closure-lags");
+ "get_auditor_closure_lags");
}
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("closure-lags",
+ GNUNET_JSON_pack_array_steal ("closure_lags",
ja));
}
diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-get.c b/src/auditor/taler-auditor-httpd_denomination-pending-get.c
index b00437e54..e8e56f18e 100644
--- a/src/auditor/taler-auditor-httpd_denomination-pending-get.c
+++ b/src/auditor/taler-auditor-httpd_denomination-pending-get.c
@@ -25,13 +25,13 @@
#include "taler-auditor-httpd_denomination-pending-get.h"
/**
-* Add denomination-pending 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-pending 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
process_denomination_pending (
void *cls,
@@ -123,6 +123,6 @@ TAH_DENOMINATION_PENDING_handler_get (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("denomination-pending",
+ GNUNET_JSON_pack_array_steal ("denomination_pending",
ja));
}
diff --git a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-get.c b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-get.c
index 2d06456c1..58421caa4 100644
--- a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-get.c
+++ b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-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>
@@ -30,32 +28,32 @@
* Add purse-not-closed-inconsistencies 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
process_purse_not_closed_inconsistencies (
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_data_auto ("purse_pub", &dc->purse_pub),
- TALER_JSON_pack_amount ("amount", &dc->amount),
- TALER_JSON_pack_time_abs_human ("expiration_date", dc->expiration_date)
-
-
+ GNUNET_JSON_pack_uint64 ("row_id",
+ dc->row_id),
+ GNUNET_JSON_pack_data_auto ("purse_pub",
+ &dc->purse_pub),
+ TALER_JSON_pack_amount ("amount",
+ &dc->amount),
+ TALER_JSON_pack_time_abs_human ("expiration_date",
+ dc->expiration_date),
+ GNUNET_JSON_pack_bool ("suppressed",
+ dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -71,6 +69,9 @@ TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_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,28 +86,33 @@ TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_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 ( (NULL != ret_s) &&
+ (0 == strcmp (ret_s,
+ "true")) )
+ {
+ return_suppressed = true;
+ }
+ }
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_purse_not_closed_inconsistencies (
TAH_plugin->cls,
limit,
@@ -129,6 +135,6 @@ TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_get (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("purse-not-closed-inconsistencies",
+ GNUNET_JSON_pack_array_steal ("purse_not_closed_inconsistencies",
ja));
}
diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c
index e734e582c..44f2c0844 100644
--- a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c
+++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c
@@ -135,6 +135,6 @@ TAH_ROW_MINOR_INCONSISTENCIES_handler_get (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("row-minor-inconsistencies",
+ GNUNET_JSON_pack_array_steal ("row_minor_inconsistencies",
ja));
}
diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c
index e529ce593..ce9986f6b 100644
--- a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c
+++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c
@@ -133,6 +133,6 @@ TAH_WIRE_FORMAT_INCONSISTENCY_handler_get (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("wire-format-inconsistency",
+ GNUNET_JSON_pack_array_steal ("wire_format_inconsistency",
ja));
}
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 8ec49a986..a18897d89 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -1072,38 +1072,32 @@ function test_9() {
# Test wire_in timestamp disagreement!
-# FIXME: test-10 not implemented
function test_10() {
NOW_MS=$(date +%s)000
echo "===========10: wire-timestamp disagreement==========="
# Technically, this call shouldn't be needed, as libeufin should already be stopped here.
stop_libeufin
- #TODO: see fixme
- #echo "FIXME: test needs update to new libeufin-bank schema"
- #exit 0
- #OLD_ID=$(echo "SELECT id FROM NexusBankTransactions WHERE amount='10' AND currency='TESTKUDOS' ORDER BY id LIMIT 1;" | psql "${DB}" -Aqt)
- #OLD_DATE=$(echo "SELECT \"timestampMs\" FROM TalerIncomingPayments WHERE payment='$OLD_ID';" | psql "${DB}" -Aqt)
- #echo "UPDATE TalerIncomingPayments SET \"timestampMs\"=$NOW_MS WHERE payment=$OLD_ID;" | psql "${DB}" -q
+ OLD_ID=$(echo "SELECT bank_transaction FROM libeufin_bank.taler_exchange_incoming JOIN libeufin_bank.bank_account_transactions ON (bank_transaction=bank_transaction_id) WHERE (amount).val=10 ORDER BY exchange_incoming_id LIMIT 1;" | psql "${DB}" -Aqt) \
+ || exit_fail "Failed to SELECT FROM libeufin_bank.bank_account_transactions!"
+ OLD_DATE=$(echo "SELECT transaction_date FROM libeufin_bank.bank_account_transactions WHERE bank_transaction_id='$OLD_ID';" | psql "${DB}" -Aqt)
+ echo -n "Modifying $OLD_ID ..."
+ echo "UPDATE libeufin_bank.bank_account_transactions SET transaction_date=$NOW_MS WHERE bank_transaction_id=$OLD_ID;" \
+ | psql "${DB}" -At
run_audit
check_auditor_running
- #TODO: fix helper wire
- #echo -n "Testing inconsistency detection... "
- #DIAG=$(jq -r .row_minor_inconsistencies[0].diagnostic < test-audit-wire.json")
- #if test "x$DIAG" != "xexecution date mismatch"
- #then
- # exit_fail "Reported diagnostic wrong: $DIAG"
- #fi
- #TABLE=$(jq -r .row_minor_inconsistencies[0].table < test-audit-wire.json")
- #if test "x$TABLE" != "xreserves_in"
- #then
- # exit_fail "Reported table wrong: $TABLE"
- #fi
- #echo "PASS"
-
+ echo -n "Testing inconsistency detection diagnostic... "
+ check_report \
+ row-minor-inconsistencies \
+ "diagnostic" "execution date mismatch"
+ echo -n "Testing inconsistency detection table... "
+ check_report \
+ row-minor-inconsistencies \
+ "row_table" "reserves_in"
# Undo database modification
- #echo "UPDATE TalerIncomingPayments SET \"timestampMs\"='$OLD_DATE' WHERE payment=$OLD_ID;" | psql "${DB}" -q
+ echo "UPDATE libeufin_bank.bank_account_transactions SET transaction_date=$OLD_DATE WHERE bank_transaction_id=$OLD_ID;" \
+ | psql "${DB}" -Aqt
stop_auditor_httpd
full_reload
cleanup
diff --git a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql
index 0668ef973..b1ccf59b8 100644
--- a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql
+++ b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql
@@ -17,7 +17,7 @@
CREATE TABLE IF NOT EXISTS auditor_row_minor_inconsistencies
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- row_table BYTEA NOT NULL,
+ row_table TEXT NOT NULL,
problem_row BIGINT NOT NULL,
diagnostic TEXT NOT NULL,
suppressed BOOLEAN NOT NULL DEFAULT FALSE
diff --git a/src/auditordb/pg_get_purse_not_closed_inconsistencies.c b/src/auditordb/pg_get_purse_not_closed_inconsistencies.c
index c764292fe..34be2f6f7 100644
--- a/src/auditordb/pg_get_purse_not_closed_inconsistencies.c
+++ b/src/auditordb/pg_get_purse_not_closed_inconsistencies.c
@@ -13,15 +13,11 @@
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_purse_not_closed_inconsistencies.h"
@@ -72,18 +68,18 @@ purse_not_closed_inconsistencies_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
- uint64_t serial_id;
-
struct TALER_AUDITORDB_PurseNotClosedInconsistencies dc;
-
struct GNUNET_PQ_ResultSpec rs[] = {
-
- GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
- GNUNET_PQ_result_spec_auto_from_type ("purse_pub", &dc.purse_pub),
- TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &dc.amount),
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &dc.row_id),
+ GNUNET_PQ_result_spec_auto_from_type ("purse_pub",
+ &dc.purse_pub),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
+ &dc.amount),
GNUNET_PQ_result_spec_absolute_time ("expiration_date",
&dc.expiration_date),
-
+ GNUNET_PQ_result_spec_bool ("suppressed",
+ &dc.suppressed),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -97,11 +93,8 @@ purse_not_closed_inconsistencies_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)
@@ -115,14 +108,12 @@ TAH_PG_get_purse_not_closed_inconsistencies (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
+ bool return_suppressed,
TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback 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),
@@ -143,9 +134,10 @@ TAH_PG_get_purse_not_closed_inconsistencies (
",purse_pub"
",amount"
",expiration_date"
+ ",suppressed"
" FROM auditor_purse_not_closed_inconsistencies"
" WHERE (row_id < $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id DESC"
" LIMIT $3"
);
@@ -156,22 +148,21 @@ TAH_PG_get_purse_not_closed_inconsistencies (
",purse_pub"
",amount"
",expiration_date"
+ ",suppressed"
" FROM auditor_purse_not_closed_inconsistencies"
" 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_purse_not_closed_inconsistencies_get_asc"
- :
- "auditor_purse_not_closed_inconsistencies_get_desc",
- params,
- &
- purse_not_closed_inconsistencies_cb,
- &dcc);
-
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_purse_not_closed_inconsistencies_get_asc"
+ : "auditor_purse_not_closed_inconsistencies_get_desc",
+ params,
+ &purse_not_closed_inconsistencies_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
diff --git a/src/auditordb/pg_get_row_minor_inconsistencies.c b/src/auditordb/pg_get_row_minor_inconsistencies.c
index 641ea908f..cd92dcce6 100644
--- a/src/auditordb/pg_get_row_minor_inconsistencies.c
+++ b/src/auditordb/pg_get_row_minor_inconsistencies.c
@@ -68,8 +68,8 @@ row_minor_inconsistencies_cb (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("row_id",
&dc.row_id),
- GNUNET_PQ_result_spec_auto_from_type ("row_table",
- &dc.row_table),
+ GNUNET_PQ_result_spec_string ("row_table",
+ &dc.row_table),
GNUNET_PQ_result_spec_uint64 ("problem_row",
&dc.problem_row),
GNUNET_PQ_result_spec_string ("diagnostic",
@@ -126,10 +126,11 @@ TAH_PG_get_row_minor_inconsistencies (
PREPARE (pg,
"auditor_row_minor_inconsistencies_get_desc",
"SELECT"
- " row_id,"
- " row_table,"
- " diagnostic,"
- " suppressed"
+ " row_id"
+ ",problem_row"
+ ",row_table"
+ ",diagnostic"
+ ",suppressed"
" FROM auditor_row_minor_inconsistencies"
" WHERE (row_id < $1)"
" AND ($2 OR NOT suppressed)"
@@ -139,10 +140,11 @@ TAH_PG_get_row_minor_inconsistencies (
PREPARE (pg,
"auditor_row_minor_inconsistencies_get_asc",
"SELECT"
- " row_id,"
- " row_table,"
- " diagnostic,"
- " suppressed"
+ " row_id"
+ ",problem_row"
+ ",row_table"
+ ",diagnostic"
+ ",suppressed"
" FROM auditor_row_minor_inconsistencies"
" WHERE (row_id > $1)"
" AND ($2 OR NOT suppressed)"
diff --git a/src/auditordb/pg_insert_row_minor_inconsistencies.c b/src/auditordb/pg_insert_row_minor_inconsistencies.c
index ee2b22423..775216872 100644
--- a/src/auditordb/pg_insert_row_minor_inconsistencies.c
+++ b/src/auditordb/pg_insert_row_minor_inconsistencies.c
@@ -26,7 +26,7 @@ TAH_PG_insert_row_minor_inconsistencies (
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (&dc->row_table),
+ GNUNET_PQ_query_param_string (dc->row_table),
GNUNET_PQ_query_param_uint64 (&dc->problem_row),
GNUNET_PQ_query_param_string (dc->diagnostic),
GNUNET_PQ_query_param_end
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
index 94c2f34eb..febfe3dc0 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -367,6 +367,7 @@ struct TALER_AUDITORDB_PurseNotClosedInconsistencies
struct GNUNET_CRYPTO_EddsaPublicKey purse_pub;
struct TALER_Amount amount;
struct GNUNET_TIME_Absolute expiration_date;
+ bool suppressed;
};
/**
@@ -550,14 +551,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_PurseNotClosedInconsistenciesCallback)(
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc);
/**