exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 3d7704a6b198c597af84d435b7ff0f192efa327e
parent f99b95c094774f1941ee16f1e8afedab45da5fb4
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue,  8 Oct 2024 16:38:08 +0200

implement auditor test_21

Diffstat:
Msrc/auditor/taler-helper-auditor-wire-debit.c | 30+++++++++++++++++-------------
Msrc/auditor/test-auditor.sh | 64++++++++++++++++++++++++++++++----------------------------------
Msrc/exchangedb/pg_select_reserve_closed_above_serial_id.c | 2--
3 files changed, 47 insertions(+), 49 deletions(-)

diff --git a/src/auditor/taler-helper-auditor-wire-debit.c b/src/auditor/taler-helper-auditor-wire-debit.c @@ -444,9 +444,9 @@ check_pending_rc (void *cls, (void) cls; (void) key; - TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_closure_amount_lag), - &TALER_ARL_USE_AB (total_closure_amount_lag), - &rc->amount); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Missing wire transfer for closed reserve with balance %s\n", + TALER_amount2s (&rc->amount)); if (! TALER_amount_is_zero (&rc->amount)) { struct TALER_AUDITORDB_ClosureLags cl = { @@ -458,6 +458,8 @@ check_pending_rc (void *cls, }; enum GNUNET_DB_QueryStatus qs; + /* FIXME: where do we *undo* this if the wire transfer is + found later? */ qs = TALER_ARL_adb->insert_auditor_closure_lags ( TALER_ARL_adb->cls, &cl); @@ -467,10 +469,12 @@ check_pending_rc (void *cls, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return GNUNET_SYSERR; } + /* FIXME: where do we *undo* this if the wire transfer is + found later? */ + TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_closure_amount_lag), + &TALER_ARL_USE_AB (total_closure_amount_lag), + &rc->amount); } - TALER_ARL_USE_PP (wire_reserve_close_id) - = GNUNET_MIN (TALER_ARL_USE_PP (wire_reserve_close_id), - rc->rowid); return GNUNET_OK; } @@ -520,6 +524,9 @@ begin_transaction (void); static void commit (enum GNUNET_DB_QueryStatus qs) { + GNUNET_CONTAINER_multihashmap_iterate (reserve_closures, + &check_pending_rc, + NULL); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Transaction logic ended with status %d\n", qs); @@ -581,9 +588,6 @@ commit (enum GNUNET_DB_QueryStatus qs) (unsigned long long) wa->last_wire_out_serial_id, wa->ai->section_name); } - GNUNET_CONTAINER_multihashmap_iterate (reserve_closures, - &check_pending_rc, - NULL); qs = TALER_ARL_adb->update_auditor_progress ( TALER_ARL_adb->cls, TALER_ARL_SET_PP (wire_reserve_close_id), @@ -1527,6 +1531,8 @@ reserve_closed_cb ( (void) cls; (void) close_request_row; + GNUNET_assert (TALER_ARL_USE_PP (wire_reserve_close_id) <= rowid); + TALER_ARL_USE_PP (wire_reserve_close_id) = rowid + 1; rc = GNUNET_new (struct ReserveClosure); if (TALER_ARL_SR_INVALID_NEGATIVE == TALER_ARL_amount_subtract_neg (&rc->amount, @@ -1552,9 +1558,6 @@ reserve_closed_cb ( GNUNET_free (rc); return GNUNET_OK; } - TALER_ARL_USE_PP (wire_reserve_close_id) - = GNUNET_MAX (TALER_ARL_USE_PP (wire_reserve_close_id), - rowid + 1); rc->receiver_account = TALER_payto_normalize (receiver_account); rc->wtid = *wtid; rc->execution_date = execution_date; @@ -1690,7 +1693,8 @@ begin_transaction (void) (unsigned long long) TALER_ARL_USE_PP (wire_reserve_close_id)); } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Iterating over reserve closures\n"); + "Iterating over reserve closures from %llu\n", + (unsigned long long) TALER_ARL_USE_PP (wire_reserve_close_id)); qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( TALER_ARL_edb->cls, TALER_ARL_USE_PP (wire_reserve_close_id), diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh @@ -1548,42 +1548,38 @@ function test_21() { | psql -Aqt "$DB" echo "UPDATE exchange.reserves SET current_balance.val=${VAL_DELTA}+(current_balance).val,expiration_date='${NEW_EXP}' WHERE reserve_pub='${RES_PUB}';" \ | psql -Aqt "$DB" -#TODO FIX AUDITOR wire - # Need to first run the aggregator so the transfer is marked as done exists -# pre_audit aggregator -# stop_libeufin -# # remove transaction from bank DB -# # Currently emulating this (to be deleted): -# echo "DELETE FROM TalerRequestedPayments WHERE amount='TESTKUDOS:${VAL_DELTA}'" \ -# | psql "${DB}" -q -# launch_libeufin -# audit_only -# post_audit -# check_auditor_running -# -# call_endpoint "reserve-not-closed-inconsistency" -# -# -# echo -n "Testing lack of reserve closure transaction detected... " -# -# jq -e .reserve_lag_details[0] \ -# < test-audit-wire.json" \ -# > /dev/null \ -# || exit_fail "Reserve closure lag not detected" -# -# AMOUNT=$(jq -r .reserve_lag_details[0].amount < test-audit-wire.json") -# if [ "$AMOUNT" != "TESTKUDOS:${VAL_DELTA}" ] -# then -# exit_fail "Reported total amount wrong: $AMOUNT" -# fi -# AMOUNT=$(jq -r .total_closure_amount_lag < test-audit-wire.json") -# if [ "$AMOUNT" != "TESTKUDOS:${VAL_DELTA}" ] -# then -# exit_fail "Reported total amount wrong: $AMOUNT" -# fi - echo "PASS" + # Need to first run the aggregator so the transfer is marked as done + pre_audit aggregator + stop_libeufin + # remove wire transfer from bank DB + echo "DELETE FROM libeufin_bank.bank_account_transactions WHERE debtor_name='Exchange Company';" \ + | psql "${DB}" -q + + launch_libeufin + audit_only + post_audit + check_auditor_running + + echo -n "Testing reserve_in inconsistency detection... " + check_report \ + row-minor-inconsistencies \ + "row_table" "reserves_in" + + echo -n "Testing lack of reserve closure transaction detected... " + check_report \ + "closure-lags" \ + "suppressed" "false" + echo -n "Checking closure lag amount ..." + check_report \ + "closure-lags" \ + "amount" "TESTKUDOS:${VAL_DELTA}" + echo -n "Checking closure lag total balance ..." + check_balance \ + "total_closure_amount_lag" \ + "TESTKUDOS:${VAL_DELTA}" \ + "Reported total_closure_amount_lag wrong" # cannot easily undo aggregator, hence full reload full_reload } diff --git a/src/exchangedb/pg_select_reserve_closed_above_serial_id.c b/src/exchangedb/pg_select_reserve_closed_above_serial_id.c @@ -146,8 +146,6 @@ TEH_PG_select_reserve_closed_above_serial_id ( }; enum GNUNET_DB_QueryStatus qs; - /* Used in #postgres_select_reserve_closed_above_serial_id() to - obtain information about closed reserves */ PREPARE ( pg, "reserves_close_get_incr",