indentation, discuss logic flaw, discuss todo in test-auditor.sh script

This commit is contained in:
Christian Grothoff 2019-08-23 21:14:50 +02:00
parent 89bb407b4c
commit b5dd2bcdbb
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 119 additions and 76 deletions

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER This file is part of TALER
Copyright (C) 2017-2018 Taler Systems SA Copyright (C) 2017-2019 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software terms of the GNU General Public License as published by the Free Software
@ -628,6 +628,11 @@ wire_out_cb (void *cls,
struct GNUNET_HashCode key; struct GNUNET_HashCode key;
struct ReserveOutInfo *roi; struct ReserveOutInfo *roi;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Exchange wire OUT at %s of %s with WTID %s\n",
GNUNET_STRINGS_absolute_time_to_string (date),
TALER_amount2s (amount),
TALER_B2S (wtid));
GNUNET_CRYPTO_hash (wtid, GNUNET_CRYPTO_hash (wtid,
sizeof (struct TALER_WireTransferIdentifierRawP), sizeof (struct TALER_WireTransferIdentifierRawP),
&key); &key);
@ -861,6 +866,8 @@ check_exchange_wire_out ()
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
struct GNUNET_TIME_Absolute next_timestamp; struct GNUNET_TIME_Absolute next_timestamp;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzing exchange's wire OUT table\n");
qs = edb->select_wire_out_above_serial_id_by_account (edb->cls, qs = edb->select_wire_out_above_serial_id_by_account (edb->cls,
esession, esession,
wp_section_name, wp_section_name,
@ -891,6 +898,8 @@ check_exchange_wire_out ()
without immediately raising undue concern */ without immediately raising undue concern */
next_timestamp = GNUNET_TIME_absolute_subtract (next_timestamp, next_timestamp = GNUNET_TIME_absolute_subtract (next_timestamp,
GRACE_PERIOD); GRACE_PERIOD);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzing exchange's unfinished deposits\n");
qs = edb->select_deposits_missing_wire (edb->cls, qs = edb->select_deposits_missing_wire (edb->cls,
esession, esession,
pp.last_timestamp, pp.last_timestamp,
@ -935,6 +944,7 @@ history_debit_cb (void *cls,
struct ReserveOutInfo *roi; struct ReserveOutInfo *roi;
struct GNUNET_HashCode rowh; struct GNUNET_HashCode rowh;
if (TALER_BANK_DIRECTION_NONE == dir) if (TALER_BANK_DIRECTION_NONE == dir)
{ {
if (TALER_EC_NONE != ec) if (TALER_EC_NONE != ec)
@ -950,6 +960,11 @@ history_debit_cb (void *cls,
check_exchange_wire_out (); check_exchange_wire_out ();
return GNUNET_OK; return GNUNET_OK;
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzing bank DEBIT at %s of %s with WTID %s\n",
GNUNET_STRINGS_absolute_time_to_string (details->execution_date),
TALER_amount2s (&details->amount),
TALER_B2S (&details->wtid));
if (NULL != details->wtid_s) if (NULL != details->wtid_s)
{ {
char *diagnostic; char *diagnostic;
@ -1019,6 +1034,8 @@ history_debit_cb (void *cls,
static void static void
process_debits () process_debits ()
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking bank DEBIT records\n");
GNUNET_assert (NULL == hh); GNUNET_assert (NULL == hh);
out_map = GNUNET_CONTAINER_multihashmap_create (1024, out_map = GNUNET_CONTAINER_multihashmap_create (1024,
GNUNET_YES); GNUNET_YES);
@ -1068,10 +1085,14 @@ reserve_in_cb (void *cls,
const void *wire_reference, const void *wire_reference,
size_t wire_reference_size, size_t wire_reference_size,
struct GNUNET_TIME_Absolute execution_date) struct GNUNET_TIME_Absolute execution_date)
{ {
struct ReserveInInfo *rii; struct ReserveInInfo *rii;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzing exchange wire IN at %s of %s with reserve_pub %s\n",
GNUNET_STRINGS_absolute_time_to_string (execution_date),
TALER_amount2s (credit),
TALER_B2S (reserve_pub));
rii = GNUNET_new (struct ReserveInInfo); rii = GNUNET_new (struct ReserveInInfo);
GNUNET_CRYPTO_hash (wire_reference, GNUNET_CRYPTO_hash (wire_reference,
wire_reference_size, wire_reference_size,
@ -1199,6 +1220,11 @@ history_credit_cb (void *cls,
conclude_credit_history (); conclude_credit_history ();
return GNUNET_OK; return GNUNET_OK;
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzing bank CREDIT at %s of %s with WTID %s\n",
GNUNET_STRINGS_absolute_time_to_string (details->execution_date),
TALER_amount2s (&details->amount),
TALER_B2S (&details->wtid));
GNUNET_CRYPTO_hash (row_off, GNUNET_CRYPTO_hash (row_off,
row_off_size, row_off_size,
&key); &key);
@ -1368,8 +1394,15 @@ process_next_account (void *cls)
int ret; int ret;
(void) cls; (void) cls;
// FIXME: this logic is broken at a high level,
// as it iterates over the exchange's incoming
// transactions once PER bank account, so for
// multiple bank accounts this cannot work!
if (NULL == (wa = wa_head)) if (NULL == (wa = wa_head))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Finished with all accounts, shutting down\n");
if (NULL != wp)
commit (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT); commit (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT);
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
@ -1437,6 +1470,8 @@ process_next_account (void *cls)
(unsigned long long) pp.last_wire_out_serial_id); (unsigned long long) pp.last_wire_out_serial_id);
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzing exchange's wire IN table\n");
in_map = GNUNET_CONTAINER_multihashmap_create (1024, in_map = GNUNET_CONTAINER_multihashmap_create (1024,
GNUNET_YES); GNUNET_YES);
qs = edb->select_reserves_in_above_serial_id_by_account (edb->cls, qs = edb->select_reserves_in_above_serial_id_by_account (edb->cls,
@ -1459,6 +1494,8 @@ process_next_account (void *cls)
process_debits (); process_debits ();
return; return;
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking bank CREDIT records\n");
hh = wp->get_history (wp->cls, hh = wp->get_history (wp->cls,
wp_section_name, wp_section_name,
TALER_BANK_DIRECTION_CREDIT, TALER_BANK_DIRECTION_CREDIT,
@ -1679,6 +1716,7 @@ run (void *cls,
TALER_EXCHANGEDB_find_accounts (cfg, TALER_EXCHANGEDB_find_accounts (cfg,
&process_account_cb, &process_account_cb,
NULL); NULL);
process_next_account (NULL);
} }

View File

@ -32,6 +32,10 @@ taler-bank-manage -c test-auditor.conf serve-http 2>/dev/null >/dev/null &
# Run the auditor! # Run the auditor!
echo "Running audit(s)" echo "Running audit(s)"
taler-auditor -c test-auditor.conf -m $MASTER_PUB > test-audit.json taler-auditor -c test-auditor.conf -m $MASTER_PUB > test-audit.json
# TODO:
# - need to configure exchange's bank accounts in test-auditor.conf,
# otherwise the auditor cannot find them!
taler-wire-auditor -c test-auditor.conf -m $MASTER_PUB > test-wire-audit.json taler-wire-auditor -c test-auditor.conf -m $MASTER_PUB > test-wire-audit.json
echo "Shutting down services" echo "Shutting down services"
@ -51,6 +55,7 @@ echo -n "Test for emergencies... "
jq -e .emergencies[0] < test-audit.json > /dev/null && (echo Failed; fail=1) || echo OK jq -e .emergencies[0] < test-audit.json > /dev/null && (echo Failed; fail=1) || echo OK
# TODO: Add more checks to ensure test-audit.json matches expectations # TODO: Add more checks to ensure test-audit.json matches expectations
echo "UPDATE reserves_in SET credit_val=5 WHERE reserve_in_serial_id=1" | psql $DB
echo "Cleanup" echo "Cleanup"