commit eeefb19aa0ce4e67fcca08fdfe5ae94f85013540
parent 556e2f32041907aff139718433cefc4e42e1d691
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 15 Sep 2024 20:27:04 +0200
fix test 24
Diffstat:
6 files changed, 54 insertions(+), 63 deletions(-)
diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c
@@ -13,14 +13,12 @@
You should have received a copy of the GNU Affero General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-
/**
* @file taler-auditor-httpd_deposit-confirmation-get.c
* @brief Handle /deposit-confirmation requests; return list of deposit confirmations from merchant
* that were not received from the exchange, by auditor.
* @author Nic Eigel
*/
-
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
@@ -32,18 +30,17 @@
#include "taler-auditor-httpd.h"
#include "taler-auditor-httpd_deposit-confirmation-get.h"
+
/**
* 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 deposit confirmation
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
*/
static enum GNUNET_GenericReturnValue
add_deposit_confirmation (
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_DepositConfirmation *dc)
{
json_t *list = cls;
@@ -74,7 +71,7 @@ add_deposit_confirmation (
obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_int64 ("deposit_confirmation_serial_id",
- serial_id),
+ dc->row_id),
GNUNET_JSON_pack_data_auto ("h_contract_terms",
&dc->h_contract_terms),
GNUNET_JSON_pack_data_auto ("h_policy",
@@ -100,7 +97,9 @@ add_deposit_confirmation (
GNUNET_JSON_pack_data_auto ("exchange_pub",
&dc->exchange_pub),
GNUNET_JSON_pack_data_auto ("master_sig",
- &dc->master_sig)
+ &dc->master_sig),
+ GNUNET_JSON_pack_bool ("suppressed",
+ dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
@@ -167,7 +166,6 @@ TAH_DEPOSIT_CONFIRMATION_handler_get (
return_suppressed,
&add_deposit_confirmation,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
@@ -299,11 +299,9 @@ TAH_DEPOSIT_CONFIRMATION_handler (
NULL),
GNUNET_JSON_spec_timestamp ("wire_deadline",
&dc.wire_deadline),
-
TALER_JSON_spec_amount ("total_without_fee",
TAH_currency,
&dc.total_without_fee),
-
GNUNET_JSON_spec_array_const ("coin_pubs",
&jcoin_pubs),
GNUNET_JSON_spec_array_const ("coin_sigs",
@@ -344,6 +342,7 @@ TAH_DEPOSIT_CONFIRMATION_handler (
if ((GNUNET_NO == res) ||
(NULL == json))
return MHD_YES;
+ dc.master_sig = es.master_sig;
res = TALER_MHD_parse_json_data (connection,
json,
spec);
diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c
@@ -131,16 +131,19 @@ test_dc (void *cls,
return GNUNET_SYSERR;
}
}
- qs = TALER_ARL_adb->delete_deposit_confirmation (TALER_ARL_adb->cls,
- serial_id);
- if (qs < 0)
- {
- GNUNET_break (0); /* DB error, complain */
- eqs = qs;
- return GNUNET_SYSERR;
- }
if (! missing)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Deleting matching deposit confirmation %llu\n",
+ (unsigned long long) serial_id);
+ qs = TALER_ARL_adb->delete_deposit_confirmation (TALER_ARL_adb->cls,
+ serial_id);
+ if (qs < 0)
+ {
+ GNUNET_break (0); /* DB error, complain */
+ eqs = qs;
+ return GNUNET_SYSERR;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found deposit %s in exchange database\n",
GNUNET_h2s (&dc->h_contract_terms.hash));
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
@@ -1799,27 +1799,16 @@ function test_24() {
check_auditor_running
echo -n "Testing inconsistency detection... "
-
call_endpoint "balances"
-
- call_endpoint "deposit-confirmation"
- jq -e .deposit_confirmation_inconsistencies[0] \
- < test-audit-deposits.json \
- > /dev/null \
- || exit_fail "Deposit confirmation inconsistency NOT detected"
- AMOUNT=$(jq -er .missing_deposit_confirmation_total < "${MY_TMP_DIR}/test-audit-deposits.json")
- if [ "$AMOUNT" = "TESTKUDOS:0" ]
- then
- exit_fail "Expected non-zero total missing deposit confirmation amount"
- fi
- COUNT=$(jq -er .missing_deposit_confirmation_count < "${MY_TMP_DIR}/test-audit-deposits.json")
- if [ "$AMOUNT" = "0" ]
- then
- exit_fail "Expected non-zero total missing deposit confirmation count"
- fi
-
- echo "PASS"
-
+ # FIXME: this fails!
+ check_report \
+ "deposit-confirmation" \
+ "suppressed" "false"
+ echo -n "Testing inconsistency detection balance change ... "
+ check_not_balance \
+ "total_missed_deposit_confirmations" \
+ "TESTKUDOS:0" \
+ "Expected non-zero total missing deposit confirmation amount"
# cannot easily undo DELETE, hence full reload
full_reload
fi
diff --git a/src/auditordb/pg_get_deposit_confirmations.c b/src/auditordb/pg_get_deposit_confirmations.c
@@ -74,7 +74,6 @@ deposit_confirmation_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
- uint64_t serial_id;
struct TALER_AUDITORDB_DepositConfirmation dc = { 0 };
struct TALER_CoinSpendPublicKeyP *coin_pubs = NULL;
struct TALER_CoinSpendSignatureP *coin_sigs = NULL;
@@ -82,15 +81,13 @@ deposit_confirmation_cb (void *cls,
size_t num_sigs = 0;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("deposit_confirmation_serial_id",
- &serial_id),
-
+ &dc.row_id),
GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
&dc.h_contract_terms),
GNUNET_PQ_result_spec_auto_from_type ("h_policy",
&dc.h_policy),
GNUNET_PQ_result_spec_auto_from_type ("h_wire",
&dc.h_wire),
-
GNUNET_PQ_result_spec_timestamp ("exchange_timestamp",
&dc.exchange_timestamp),
GNUNET_PQ_result_spec_timestamp ("refund_deadline",
@@ -99,7 +96,6 @@ deposit_confirmation_cb (void *cls,
&dc.wire_deadline),
TALER_PQ_RESULT_SPEC_AMOUNT ("total_without_fee",
&dc.total_without_fee),
-
GNUNET_PQ_result_spec_auto_array_from_type (pg->conn,
"coin_pubs",
&num_pubs,
@@ -116,7 +112,8 @@ deposit_confirmation_cb (void *cls,
&dc.exchange_pub),
GNUNET_PQ_result_spec_auto_from_type ("master_sig",
&dc.master_sig),
-
+ GNUNET_PQ_result_spec_bool ("suppressed",
+ &dc.suppressed),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -142,7 +139,6 @@ deposit_confirmation_cb (void *cls,
dc.coin_sigs = coin_sigs;
dc.num_coins = num_sigs;
rval = dcc->cb (dcc->cb_cls,
- serial_id,
&dc);
GNUNET_PQ_cleanup_result (rs);
if (GNUNET_OK != rval)
@@ -160,10 +156,8 @@ TAH_PG_get_deposit_confirmations (
TALER_AUDITORDB_DepositConfirmationCallback 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),
@@ -194,9 +188,10 @@ TAH_PG_get_deposit_confirmations (
",exchange_sig"
",exchange_pub"
",master_sig"
+ ",suppressed"
" FROM auditor_deposit_confirmations"
" WHERE (deposit_confirmation_serial_id < $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY deposit_confirmation_serial_id DESC"
" LIMIT $3"
);
@@ -217,20 +212,21 @@ TAH_PG_get_deposit_confirmations (
",exchange_sig"
",exchange_pub"
",master_sig"
+ ",suppressed"
" FROM auditor_deposit_confirmations"
" WHERE (deposit_confirmation_serial_id > $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY deposit_confirmation_serial_id ASC"
" LIMIT $3"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0) ?
- "auditor_deposit_confirmation_select_asc"
- :
- "auditor_deposit_confirmation_select_desc",
- params,
- &deposit_confirmation_cb,
- &dcc);
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_deposit_confirmation_select_asc"
+ : "auditor_deposit_confirmation_select_desc",
+ params,
+ &deposit_confirmation_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
@@ -160,11 +160,6 @@ struct TALER_AUDITORDB_DepositConfirmation
struct TALER_Amount total_without_fee;
/**
- * Length of the @e coin_pubs and @e coin_sigs arrays.
- */
- unsigned int num_coins;
-
- /**
* Array of the coin public keys involved in the
* batch deposit operation.
*/
@@ -197,6 +192,18 @@ struct TALER_AUDITORDB_DepositConfirmation
*/
struct TALER_MasterSignatureP master_sig;
+ /**
+ * Row of this entry in the auditor database.
+ */
+ uint64_t row_id;
+
+ /**
+ * Length of the @e coin_pubs and @e coin_sigs arrays.
+ */
+ unsigned int num_coins;
+
+ bool suppressed;
+
};
// MARK: CRUD
@@ -817,7 +824,6 @@ struct TALER_AUDITORDB_ReserveNotClosedInconsistency
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_DepositConfirmationCallback)(
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_DepositConfirmation *dc);