commit caa557857326d2f03236bbbe6d07ff3858bed21f
parent fc8a45b6ca574a69af384ca18cb4734fba02c282
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 29 May 2025 11:10:12 +0200
fix #9900: test-sync.sh now passes again
Diffstat:
5 files changed, 133 insertions(+), 80 deletions(-)
diff --git a/src/auditor/Makefile.am b/src/auditor/Makefile.am
@@ -254,9 +254,9 @@ check_SCRIPTS = \
AM_TESTS_ENVIRONMENT=export TALER_EXCHANGE_PREFIX=$${TALER_EXCHANGE_PREFIX:-@libdir@};export PATH=$${TALER_EXCHANGE_PREFIX:-@prefix@}/bin:$$PATH;export TALER_AUDITOR_PREFIX=$${TALER_AUDITOR_PREFIX:-@libdir@};
-#TESTS = \
-# test-sync.sh \
-# test-auditor.sh
+TESTS = \
+ test-sync.sh \
+ test-auditor.sh
EXTRA_DIST = \
taler-helper-auditor-render.py \
diff --git a/src/auditor/test-sync.sh b/src/auditor/test-sync.sh
@@ -117,7 +117,7 @@ function check_with_database()
-d test-sync-out.conf -t
# cs_nonce_locks excluded: no point
- for table in denominations denomination_revocations kyc_targets wire_targets reserves reserves_in reserves_close reserves_open_requests reserves_open_deposits withdraw auditors auditor_denom_sigs exchange_sign_keys signkey_revocations known_coins refresh_commitments refresh_revealed_coins refresh_transfer_keys batch_deposits coin_deposits refunds wire_out aggregation_tracking wire_fee recoup recoup_refresh extensions policy_details policy_fulfillments purse_requests purse_decision purse_merges purse_deposits account_merges history_requests close_requests wads_out wad_out_entries wads_in wad_in_entries profit_drains aml_staff purse_deletion age_withdraw legitimization_measures legitimization_outcomes legitimization_processes kyc_attributes aml_history kyc_events kycauths_in
+ for table in denominations denomination_revocations kyc_targets wire_targets reserves reserves_in reserves_close reserves_open_requests reserves_open_deposits auditors auditor_denom_sigs exchange_sign_keys signkey_revocations known_coins refresh batch_deposits coin_deposits refunds wire_out aggregation_tracking wire_fee global_fee recoup recoup_refresh extensions policy_details policy_fulfillments purse_requests purse_decision purse_merges purse_deposits account_merges history_requests close_requests wads_out wad_out_entries wads_in wad_in_entries profit_drains aml_staff purse_deletion withdraw legitimization_measures legitimization_outcomes legitimization_processes kyc_attributes aml_history kyc_events kycauths_in
do
echo -n "."
CIN=$(echo "SELECT COUNT(*) FROM exchange.$table" | psql talercheck-in -Aqt)
diff --git a/src/exchangedb/pg_insert_records_by_table.c b/src/exchangedb/pg_insert_records_by_table.c
@@ -930,11 +930,17 @@ irbt_cb_table_batch_deposits (struct PostgresClosure *pg,
&td->details.batch_deposits.wire_salt),
GNUNET_PQ_query_param_auto_from_type (
&td->details.batch_deposits.wire_target_h_payto),
- GNUNET_PQ_query_param_bool (td->details.batch_deposits.policy_blocked),
td->details.batch_deposits.no_policy_details
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_uint64 (
&td->details.batch_deposits.policy_details_serial_id),
+ GNUNET_PQ_query_param_bool (td->details.batch_deposits.policy_blocked),
+ TALER_PQ_query_param_amount (
+ pg->conn,
+ &td->details.batch_deposits.total_amount),
+ GNUNET_PQ_query_param_auto_from_type (
+ &td->details.batch_deposits.merchant_sig),
+ GNUNET_PQ_query_param_bool (td->details.batch_deposits.done),
GNUNET_PQ_query_param_end
};
@@ -952,11 +958,14 @@ irbt_cb_table_batch_deposits (struct PostgresClosure *pg,
",wallet_data_hash"
",wire_salt"
",wire_target_h_payto"
- ",policy_blocked"
",policy_details_serial_id"
+ ",policy_blocked"
+ ",total_amount"
+ ",merchant_sig"
+ ",done"
") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
- " $11, $12, $13);");
+ " $11, $12, $13, $14, $15, $16);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_into_table_batch_deposits",
params);
@@ -2194,56 +2203,78 @@ irbt_cb_table_withdraw (
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (
- &td->details.withdraw.h_planchets),
+ &td->details.withdraw.planchets_h),
+ GNUNET_PQ_query_param_timestamp (
+ &td->details.withdraw.execution_date),
TALER_PQ_query_param_amount (
pg->conn,
&td->details.withdraw.amount_with_fee),
- td->details.withdraw.age_proof_required
- ? GNUNET_PQ_query_param_uint16 (
- &td->details.withdraw.max_age)
- : GNUNET_PQ_query_param_null (),
- td->details.withdraw.age_proof_required
- ? GNUNET_PQ_query_param_uint32 (
- &td->details.withdraw.noreveal_index)
- : GNUNET_PQ_query_param_null (),
GNUNET_PQ_query_param_auto_from_type (
&td->details.withdraw.reserve_pub),
GNUNET_PQ_query_param_auto_from_type (
&td->details.withdraw.reserve_sig),
- GNUNET_PQ_query_param_timestamp (
- &td->details.withdraw.execution_date),
+ td->details.withdraw.age_proof_required
+ ? GNUNET_PQ_query_param_uint16 (
+ &td->details.withdraw.max_age)
+ : GNUNET_PQ_query_param_null (),
+ td->details.withdraw.age_proof_required
+ ? GNUNET_PQ_query_param_uint16 (
+ &td->details.withdraw.noreveal_index)
+ : GNUNET_PQ_query_param_null (),
+ td->details.withdraw.age_proof_required
+ ? GNUNET_PQ_query_param_auto_from_type (
+ &td->details.withdraw.selected_h)
+ : GNUNET_PQ_query_param_null (),
td->details.withdraw.no_blinding_seed
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_auto_from_type (
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_auto_from_type (
&td->details.withdraw.blinding_seed),
- (0 < td->details.withdraw.num_cs_r_pubs)
- ? TALER_PQ_query_param_array_cs_r_pub (
- td->details.withdraw.num_cs_r_pubs,
- td->details.withdraw.cs_r_pubs,
+ (0 < td->details.withdraw.num_cs_r_values)
+ ? TALER_PQ_query_param_array_cs_r_pub (
+ td->details.withdraw.num_cs_r_values,
+ td->details.withdraw.cs_r_values,
pg->conn)
- : GNUNET_PQ_query_param_null (),
+ : GNUNET_PQ_query_param_null (),
+ (0 < td->details.withdraw.num_cs_r_values)
+ ? GNUNET_PQ_query_param_uint64 (
+ &td->details.withdraw.cs_r_choices)
+ : GNUNET_PQ_query_param_null (),
+ GNUNET_PQ_query_param_array_uint64 (
+ td->details.withdraw.num_coins,
+ td->details.withdraw.denom_serials,
+ pg->conn),
+ TALER_PQ_query_param_array_blinded_denom_sig (
+ td->details.withdraw.num_coins,
+ td->details.withdraw.denom_sigs,
+ pg->conn),
GNUNET_PQ_query_param_end
};
+ enum GNUNET_DB_QueryStatus qs;
- // FIXME: rather wrong, misses fields, etc.
PREPARE (pg,
"insert_into_table_withdraw",
"INSERT INTO withdraw"
"(withdraw_id"
",planchets_h"
+ ",execution_date"
",amount_with_fee"
- ",max_age"
- ",noreveal_index"
",reserve_pub"
",reserve_sig"
- ",execution_date"
+ ",max_age"
+ ",noreveal_index"
+ ",selected_h"
",blinding_seed"
- ",cs_r_pubs" // FIXME: cs_r_values, ...
+ ",cs_r_values"
+ ",cs_r_choices"
+ ",denom_serials"
+ ",denom_sigs"
") VALUES "
- "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_into_table_withdraw",
- params);
+ "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);");
+ qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "insert_into_table_withdraw",
+ params);
+ GNUNET_PQ_cleanup_query_params_closures (params);
+ return qs;
}
diff --git a/src/exchangedb/pg_lookup_records_by_table.c b/src/exchangedb/pg_lookup_records_by_table.c
@@ -1007,6 +1007,7 @@ lrbt_cb_table_batch_deposits (void *cls,
unsigned int num_results)
{
struct LookupRecordsByTableContext *ctx = cls;
+ struct PostgresClosure *pg = ctx->pg;
struct TALER_EXCHANGEDB_TableData td = {
.table = TALER_EXCHANGEDB_RT_BATCH_DEPOSITS
};
@@ -1049,14 +1050,23 @@ lrbt_cb_table_batch_deposits (void *cls,
GNUNET_PQ_result_spec_auto_from_type (
"wire_target_h_payto",
&td.details.batch_deposits.wire_target_h_payto),
- GNUNET_PQ_result_spec_auto_from_type (
- "policy_blocked",
- &td.details.batch_deposits.policy_blocked),
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_uint64 (
"policy_details_serial_id",
&td.details.batch_deposits.policy_details_serial_id),
&td.details.batch_deposits.no_policy_details),
+ GNUNET_PQ_result_spec_bool (
+ "policy_blocked",
+ &td.details.batch_deposits.policy_blocked),
+ TALER_PQ_RESULT_SPEC_AMOUNT (
+ "total_amount",
+ &td.details.batch_deposits.total_amount),
+ GNUNET_PQ_result_spec_auto_from_type (
+ "merchant_sig",
+ &td.details.batch_deposits.merchant_sig),
+ GNUNET_PQ_result_spec_bool (
+ "done",
+ &td.details.batch_deposits.done),
GNUNET_PQ_result_spec_end
};
@@ -2560,16 +2570,17 @@ lrbt_cb_table_withdraw (void *cls,
{
bool no_max_age;
bool no_noreveal_index;
- bool no_cs_r_pubs;
- uint64_t num_h_coin_evs;
- uint64_t num_sigs;
+ bool no_selected_h;
+ bool no_cs_r_values;
+ bool no_cs_r_choices;
+ size_t num_sigs;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 (
"withdraw_id",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type (
"planchets_h",
- &td.details.withdraw.h_planchets),
+ &td.details.withdraw.planchets_h),
GNUNET_PQ_result_spec_timestamp (
"execution_date",
&td.details.withdraw.execution_date),
@@ -2588,45 +2599,37 @@ lrbt_cb_table_withdraw (void *cls,
&td.details.withdraw.max_age),
&no_max_age),
GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_uint32 (
+ GNUNET_PQ_result_spec_uint16 (
"noreveal_index",
&td.details.withdraw.noreveal_index),
&no_noreveal_index),
-
-#if FIXME_9900
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type (
"selected_h",
&td.details.withdraw.selected_h),
- &td.details.withdraw.no_selected_h),
-#endif
-
+ &no_selected_h),
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type (
"blinding_seed",
&td.details.withdraw.blinding_seed),
&td.details.withdraw.no_blinding_seed),
-
- // FIXME: gone...
- TALER_PQ_result_spec_array_blinded_coin_hash (
- pg->conn,
- "h_blind_evs",
- &num_h_coin_evs,
- &td.details.withdraw.h_coin_evs),
-
GNUNET_PQ_result_spec_allow_null (
TALER_PQ_result_spec_array_cs_r_pub (
pg->conn,
- "cs_r_pubs", // FIXME: cs_r_values!
- &td.details.withdraw.num_cs_r_pubs,
- &td.details.withdraw.cs_r_pubs),
- &no_cs_r_pubs),
- // FIXME: cs_r_choices missing!
+ "cs_r_values",
+ &td.details.withdraw.num_cs_r_values,
+ &td.details.withdraw.cs_r_values),
+ &no_cs_r_values),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_uint64 (
+ "cs_r_choices",
+ &td.details.withdraw.cs_r_choices),
+ &no_cs_r_choices),
GNUNET_PQ_result_spec_array_uint64 (
pg->conn,
"denom_serials",
&td.details.withdraw.num_coins,
- &td.details.withdraw.denominations_serials),
+ &td.details.withdraw.denom_serials),
TALER_PQ_result_spec_array_blinded_denom_sig (
pg->conn,
"denom_sigs",
@@ -2645,8 +2648,7 @@ lrbt_cb_table_withdraw (void *cls,
GNUNET_PQ_cleanup_result (rs);
return;
}
- if ((num_h_coin_evs != td.details.withdraw.num_coins) ||
- (num_h_coin_evs != num_sigs))
+ if (num_sigs != td.details.withdraw.num_coins)
{
GNUNET_break (0);
ctx->error = true;
@@ -2660,7 +2662,21 @@ lrbt_cb_table_withdraw (void *cls,
GNUNET_PQ_cleanup_result (rs);
return;
}
- if (no_cs_r_pubs != td.details.withdraw.no_blinding_seed)
+ if (no_max_age != no_selected_h)
+ {
+ GNUNET_break (0);
+ ctx->error = true;
+ GNUNET_PQ_cleanup_result (rs);
+ return;
+ }
+ if (no_cs_r_values != no_cs_r_choices)
+ {
+ GNUNET_break (0);
+ ctx->error = true;
+ GNUNET_PQ_cleanup_result (rs);
+ return;
+ }
+ if (no_cs_r_values != td.details.withdraw.no_blinding_seed)
{
GNUNET_break (0);
ctx->error = true;
@@ -3297,9 +3313,11 @@ TEH_PG_lookup_records_by_table (void *cls,
",wallet_data_hash"
",wire_salt"
",wire_target_h_payto"
- ",done"
- ",policy_blocked"
",policy_details_serial_id"
+ ",policy_blocked"
+ ",total_amount"
+ ",merchant_sig"
+ ",done"
" FROM batch_deposits"
" WHERE batch_deposit_serial_id > $1"
" ORDER BY batch_deposit_serial_id ASC;");
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
@@ -579,13 +579,16 @@ struct TALER_EXCHANGEDB_TableData
struct GNUNET_TIME_Timestamp refund_deadline;
struct GNUNET_TIME_Timestamp wire_deadline;
struct TALER_PrivateContractHashP h_contract_terms;
- struct GNUNET_HashCode wallet_data_hash;
bool no_wallet_data_hash;
+ struct GNUNET_HashCode wallet_data_hash;
struct TALER_WireSaltP wire_salt;
struct TALER_FullPaytoHashP wire_target_h_payto;
- bool policy_blocked;
- uint64_t policy_details_serial_id;
bool no_policy_details;
+ uint64_t policy_details_serial_id;
+ bool policy_blocked;
+ struct TALER_Amount total_amount;
+ struct TALER_MerchantSignatureP merchant_sig;
+ bool done;
} batch_deposits;
struct
@@ -820,22 +823,23 @@ struct TALER_EXCHANGEDB_TableData
struct
{
- struct TALER_HashBlindedPlanchetsP h_planchets;
- struct TALER_Amount amount_with_fee;
+ struct TALER_HashBlindedPlanchetsP planchets_h;
struct GNUNET_TIME_Timestamp execution_date;
- bool age_proof_required;
- uint16_t max_age;
- uint32_t noreveal_index;
+ struct TALER_Amount amount_with_fee;
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_ReserveSignatureP reserve_sig;
- uint64_t num_coins;
- uint64_t *denominations_serials;
- struct TALER_BlindedCoinHashP *h_coin_evs;
- struct TALER_BlindedDenominationSignature *denom_sigs;
+ bool age_proof_required;
+ uint16_t max_age;
+ uint16_t noreveal_index;
+ struct TALER_HashBlindedPlanchetsP selected_h;
bool no_blinding_seed;
struct TALER_BlindingMasterSeedP blinding_seed;
- uint64_t num_cs_r_pubs;
- struct GNUNET_CRYPTO_CSPublicRPairP *cs_r_pubs;
+ uint64_t num_cs_r_values;
+ struct GNUNET_CRYPTO_CSPublicRPairP *cs_r_values;
+ uint64_t cs_r_choices;
+ size_t num_coins;
+ uint64_t *denom_serials;
+ struct TALER_BlindedDenominationSignature *denom_sigs;
} withdraw;
} details;