completing auditor split

This commit is contained in:
Christian Grothoff 2020-03-21 16:09:22 +01:00
parent a8b8258e12
commit 88fd81e5da
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
20 changed files with 230 additions and 5927 deletions

1
.gitignore vendored
View File

@ -34,7 +34,6 @@ GTAGS
*.swp *.swp
src/lib/test_exchange_api src/lib/test_exchange_api
doc/doxygen/doxygen_sqlite3.db doc/doxygen/doxygen_sqlite3.db
src/auditor/taler-auditor
src/auditor/taler-auditor-dbinit src/auditor/taler-auditor-dbinit
src/auditor/taler-auditor-sign src/auditor/taler-auditor-sign
src/bank-lib/taler-fakebank-run src/bank-lib/taler-fakebank-run

View File

@ -6,6 +6,8 @@ tosendir=$(pkgdatadir)/tos/en
# English (en) # English (en)
ppendir=$(pkgdatadir)/pp/en ppendir=$(pkgdatadir)/pp/en
rdatadir=$(pkgdatadir)
tosen_DATA = \ tosen_DATA = \
tos/en/0.txt \ tos/en/0.txt \
tos/en/0.pdf \ tos/en/0.pdf \
@ -20,6 +22,9 @@ ppen_DATA = \
pp/en/0.xml \ pp/en/0.xml \
pp/en/0.html pp/en/0.html
rdata_DATA = \
auditor-report.tex.j2
bin_SCRIPTS = \ bin_SCRIPTS = \
taler-bank-manage-testing \ taler-bank-manage-testing \
taler-exchange-revoke taler-exchange-revoke
@ -39,11 +44,10 @@ EXTRA_DIST = \
pp/tos.rst \ pp/tos.rst \
pp/conf.py \ pp/conf.py \
pp/locale/pp/LC_MESSAGES/pp.po \ pp/locale/pp/LC_MESSAGES/pp.po \
auditor-report.tex.j2 \ $(data_DATA) \
coverage.sh \ coverage.sh \
gnunet.tag \ gnunet.tag \
microhttpd.tag \ microhttpd.tag
render.py
# Change the set of supported languages here. You should # Change the set of supported languages here. You should
# also update tos'XX'data and EXTRA_DIST accordingly. # also update tos'XX'data and EXTRA_DIST accordingly.

View File

@ -467,9 +467,16 @@ the financial damage done to the customer).
Note that the deltas only sum up the issues where $P \not= 0$ as only Note that the deltas only sum up the issues where $P \not= 0$ as only
then we can tell if the problem lead to a profit or loss. then we can tell if the problem lead to a profit or loss.
% Table generation tested by testcase #18 in test-auditor.sh The {\bf P} colum is set to "1" if the arithmetic problem was be determined to be
profitable for the exchange, "-1" if the problem resulted in a net loss for
the exchange, and "0" if this is unclear or at least the gain/loss is not
easily determined from the amounts and thus not included in the totals.
{% if data.amount_arithmetic_inconsistencies|length() == 0 %} \subsubsection{For aggregation}
% Table generation tested by testcase #XX in test-auditor.sh
{% if aggregation.amount_arithmetic_inconsistencies|length() == 0 %}
{\bf No arithmetic problems detected.} {\bf No arithmetic problems detected.}
{% else %} {% else %}
\begin{longtable}{p{3.5cm}|r|r|r|c} \begin{longtable}{p{3.5cm}|r|r|r|c}
@ -483,12 +490,12 @@ then we can tell if the problem lead to a profit or loss.
\endfoot \endfoot
\hline \hline \hline \hline
\multicolumn{2}{l|}{ {\bf $\sum$ Deltas (Auditor-Exchange)} } & \multicolumn{2}{l|}{ {\bf $\sum$ Deltas (Auditor-Exchange)} } &
+ {{ data.total_arithmetic_delta_plus }} & + {{ aggregation.total_arithmetic_delta_plus }} &
- {{ data.total_arithmetic_delta_minus }} & \\ - {{ aggregation.total_arithmetic_delta_minus }} & \\
\caption{Arithmetic inconsistencies.} \caption{Arithmetic inconsistencies.}
\label{table:amount:arithmetic:inconsistencies} \label{table:amount:arithmetic:inconsistencies:aggregation}
\endlastfoot \endlastfoot
{% for item in data.amount_arithmetic_inconsistencies %} {% for item in aggregation.amount_arithmetic_inconsistencies %}
\truncate{3.3cm}{ {\tiny {{ item.operation }} } } & \truncate{3.3cm}{ {\tiny {{ item.operation }} } } &
{{ item.rowid }} & {{ item.rowid }} &
{{ item.exchange }} & {{ item.exchange }} &
@ -496,11 +503,72 @@ then we can tell if the problem lead to a profit or loss.
{{ item.profitable }} \\ \hline {{ item.profitable }} \\ \hline
{% endfor %} {% endfor %}
\end{longtable} \end{longtable}
{% endif %}
The {\bf P} colum is set to "1" if the arithmetic problem was be determined to be \subsubsection{For coins}
profitable for the exchange, "-1" if the problem resulted in a net loss for
the exchange, and "0" if this is unclear or at least the gain/loss is not % Table generation tested by testcase #18 in test-auditor.sh
easily determined from the amounts and thus not included in the totals.
{% if coins.amount_arithmetic_inconsistencies|length() == 0 %}
{\bf No arithmetic problems detected.}
{% else %}
\begin{longtable}{p{3.5cm}|r|r|r|c}
{\bf Operation} & {\bf Row} & {\bf Exchange} & {\bf Auditor} & {\bf P} \\
\hline \hline
\endfirsthead
{\bf Operation} & {\bf Row} & {\bf Exchange} & {\bf Auditor} & {\bf P} \\ \hline \hline
\endhead
\hline \hline
{\bf Operation} & {\bf Row} & {\bf Exchange} & {\bf Auditor} & {\bf P} \\
\endfoot
\hline \hline
\multicolumn{2}{l|}{ {\bf $\sum$ Deltas (Auditor-Exchange)} } &
+ {{ coins.total_arithmetic_delta_plus }} &
- {{ coins.total_arithmetic_delta_minus }} & \\
\caption{Arithmetic inconsistencies.}
\label{table:amount:arithmetic:inconsistencies:coins}
\endlastfoot
{% for item in coins.amount_arithmetic_inconsistencies %}
\truncate{3.3cm}{ {\tiny {{ item.operation }} } } &
{{ item.rowid }} &
{{ item.exchange }} &
{{ item.auditor }} &
{{ item.profitable }} \\ \hline
{% endfor %}
\end{longtable}
{% endif %}
\subsubsection{For reserves}
% Table generation tested by testcase #XX in test-auditor.sh
{% if reserves.amount_arithmetic_inconsistencies|length() == 0 %}
{\bf No arithmetic problems detected.}
{% else %}
\begin{longtable}{p{3.5cm}|r|r|r|c}
{\bf Operation} & {\bf Row} & {\bf Exchange} & {\bf Auditor} & {\bf P} \\
\hline \hline
\endfirsthead
{\bf Operation} & {\bf Row} & {\bf Exchange} & {\bf Auditor} & {\bf P} \\ \hline \hline
\endhead
\hline \hline
{\bf Operation} & {\bf Row} & {\bf Exchange} & {\bf Auditor} & {\bf P} \\
\endfoot
\hline \hline
\multicolumn{2}{l|}{ {\bf $\sum$ Deltas (Auditor-Exchange)} } &
+ {{ reserves.total_arithmetic_delta_plus }} &
- {{ reserves.total_arithmetic_delta_minus }} & \\
\caption{Arithmetic inconsistencies.}
\label{table:amount:arithmetic:inconsistencies:reserves}
\endlastfoot
{% for item in reserves.amount_arithmetic_inconsistencies %}
\truncate{3.3cm}{ {\tiny {{ item.operation }} } } &
{{ item.rowid }} &
{{ item.exchange }} &
{{ item.auditor }} &
{{ item.profitable }} \\ \hline
{% endfor %}
\end{longtable}
{% endif %} {% endif %}

View File

@ -4,6 +4,7 @@ SUBDIRS = . doxygen
man_MANS = \ man_MANS = \
prebuilt/man/taler-auditor.1 \ prebuilt/man/taler-auditor.1 \
prebuilt/man/taler-auditor-dbinit.1 \
prebuilt/man/taler-auditor-exchange.1 \ prebuilt/man/taler-auditor-exchange.1 \
prebuilt/man/taler-auditor-sign.1 \ prebuilt/man/taler-auditor-sign.1 \
prebuilt/man/taler-bank-transfer.1 \ prebuilt/man/taler-bank-transfer.1 \

View File

@ -1,6 +1,5 @@
taler-auditor-httpd taler-auditor-httpd
taler-auditor taler-auditor
taler-wire-auditor
taler-auditor-exchange taler-auditor-exchange
test-report.aux test-report.aux
test-report.pdf test-report.pdf

View File

@ -12,16 +12,27 @@ pkgcfg_DATA = \
auditor.conf auditor.conf
bin_PROGRAMS = \ bin_PROGRAMS = \
taler-auditor \ taler-auditor-dbinit \
taler-helper-auditor-reserves \
taler-helper-auditor-coins \
taler-helper-auditor-aggregation \
taler-helper-auditor-deposits \
taler-helper-auditor-wire \
taler-auditor-exchange \ taler-auditor-exchange \
taler-auditor-httpd \ taler-auditor-httpd \
taler-auditor-sign \ taler-auditor-sign \
taler-auditor-dbinit taler-helper-auditor-aggregation \
taler-helper-auditor-coins \
taler-helper-auditor-deposits \
taler-helper-auditor-reserves \
taler-helper-auditor-wire
bin_SCRIPTS = \
taler-auditor \
taler-helper-auditor-render.py
edit_script = $(SED) -e 's,%pkgdatadir%,$(pkgdatadir),'g $(NULL)
taler-auditor: taler-auditor.in
rm -f $@ $@.tmp && \
$(edit_script) $< >$@.tmp && \
chmod a-w+x $@.tmp && \
mv $@.tmp $@
noinst_LIBRARIES = \ noinst_LIBRARIES = \
libauditor.a libauditor.a
@ -116,20 +127,6 @@ taler_helper_auditor_wire_LDADD = \
-lgnunetutil -lgnunetutil
taler_auditor_SOURCES = \
taler-auditor.c
taler_auditor_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
$(top_builddir)/src/auditordb/libtalerauditordb.la \
-ljansson \
-lgnunetjson \
-lgnunetutil
taler_auditor_httpd_SOURCES = \ taler_auditor_httpd_SOURCES = \
taler-auditor-httpd.c taler-auditor-httpd.h \ taler-auditor-httpd.c taler-auditor-httpd.h \
taler-auditor-httpd_deposit-confirmation.c taler-auditor-httpd_deposit-confirmation.h \ taler-auditor-httpd_deposit-confirmation.c taler-auditor-httpd_deposit-confirmation.h \

View File

@ -21,11 +21,6 @@
#include "platform.h" #include "platform.h"
#include "report-lib.h" #include "report-lib.h"
/**
* Command-line option "-r": TALER_ARL_restart audit from scratch
*/
int TALER_ARL_restart;
/** /**
* Handle to access the exchange's database. * Handle to access the exchange's database.
*/ */
@ -518,26 +513,6 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c)
TALER_EXCHANGEDB_plugin_unload (TALER_ARL_edb); TALER_EXCHANGEDB_plugin_unload (TALER_ARL_edb);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (TALER_ARL_restart)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Full audit TALER_ARL_restart requested, dropping old audit data.\n");
GNUNET_break (GNUNET_OK ==
TALER_ARL_adb->drop_tables (TALER_ARL_adb->cls,
GNUNET_NO));
TALER_AUDITORDB_plugin_unload (TALER_ARL_adb);
if (NULL ==
(TALER_ARL_adb = TALER_AUDITORDB_plugin_load (TALER_ARL_cfg)))
{
fprintf (stderr,
"Failed to initialize auditor database plugin after drop.\n");
TALER_EXCHANGEDB_plugin_unload (TALER_ARL_edb);
return GNUNET_SYSERR;
}
GNUNET_break (GNUNET_OK ==
TALER_ARL_adb->create_tables (TALER_ARL_adb->cls));
}
return GNUNET_OK; return GNUNET_OK;
} }

View File

@ -30,7 +30,12 @@
static int global_ret; static int global_ret;
/** /**
* -r option: do full DB reset * -r option: do restart audits
*/
static int restart_db;
/**
* -R option: do full DB reset
*/ */
static int reset_db; static int reset_db;
@ -71,6 +76,11 @@ run (void *cls,
(void) plugin->drop_tables (plugin->cls, (void) plugin->drop_tables (plugin->cls,
GNUNET_YES); GNUNET_YES);
} }
else if (restart_db)
{
(void) plugin->drop_tables (plugin->cls,
GNUNET_NO);
}
if (GNUNET_OK != if (GNUNET_OK !=
plugin->create_tables (plugin->cls)) plugin->create_tables (plugin->cls))
{ {
@ -104,6 +114,10 @@ main (int argc,
{ {
const struct GNUNET_GETOPT_CommandLineOption options[] = { const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_flag ('r', GNUNET_GETOPT_option_flag ('r',
"restart",
"restart audits (DANGEROUS: all audits resume from scratch)",
&restart_db),
GNUNET_GETOPT_option_flag ('R',
"reset", "reset",
"reset database (DANGEROUS: all existing data is lost!)", "reset database (DANGEROUS: all existing data is lost!)",
&reset_db), &reset_db),

View File

@ -197,12 +197,11 @@ main (int argc,
} }
if (0 == qs) if (0 == qs)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (
GNUNET_ERROR_TYPE_WARNING,
(remove_flag) (remove_flag)
? ? "Could not remove exchange from database: entry already absent\n"
"Could not remove exchange from auditor database: entry already absent\n" : "Could not add exchange to database: entry already exists\n");
:
"Could not add exchange to auditor database: entry already existed\n");
TALER_AUDITORDB_plugin_unload (adb); TALER_AUDITORDB_plugin_unload (adb);
return 4; return 4;
} }

File diff suppressed because it is too large Load Diff

23
src/auditor/taler-auditor.in Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
set -eu
DIR=`mktemp -d reportXXXXXX`
for n in aggregation coins deposits reserves wire
do
taler-helper-auditor-$n "$@" > ${DIR}/$n.json
done
taler-helper-auditor-render.py \
${DIR}/aggregation.json \
${DIR}/coins.json \
${DIR}/deposits.json \
${DIR}/reserves.json \
${DIR}/wire.json < %pkgdatadir%/auditor-report.tex.j2 > ${DIR}/auditor-report.tex
cd ${DIR}
pdflatex auditor-report.tex < /dev/null
pdflatex auditor-report.tex < /dev/null
pdflatex auditor-report.tex < /dev/null
cd ..
echo "Result is in ${DIR}/auditor-report.pdf"

View File

@ -1519,10 +1519,6 @@ main (int argc,
"KEY", "KEY",
"public key of the exchange (Crockford base32 encoded)", "public key of the exchange (Crockford base32 encoded)",
&TALER_ARL_master_pub), &TALER_ARL_master_pub),
GNUNET_GETOPT_option_flag ('r',
"TALER_ARL_restart",
"TALER_ARL_restart audit from the beginning (required on first run)",
&TALER_ARL_restart),
GNUNET_GETOPT_option_timetravel ('T', GNUNET_GETOPT_option_timetravel ('T',
"timetravel"), "timetravel"),
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
@ -1533,13 +1529,13 @@ main (int argc,
away and skip #TALER_OS_init(), which we do need */ away and skip #TALER_OS_init(), which we do need */
(void) TALER_project_data_default (); (void) TALER_project_data_default ();
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-auditor-aggregation", GNUNET_log_setup ("taler-helper-auditor-aggregation",
"MESSAGE", "MESSAGE",
NULL)); NULL));
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, GNUNET_PROGRAM_run (argc,
argv, argv,
"taler-auditor-aggregation", "taler-helper-auditor-aggregation",
"Audit Taler exchange aggregation activity", "Audit Taler exchange aggregation activity",
options, options,
&run, &run,
@ -1549,4 +1545,4 @@ main (int argc,
} }
/* end of taler-auditor-aggregation.c */ /* end of taler-helper-auditor-aggregation.c */

View File

@ -185,8 +185,8 @@ static struct TALER_Amount total_refresh_hanging;
* @param loss actual losses already (actualized before denomination was revoked) * @param loss actual losses already (actualized before denomination was revoked)
*/ */
static void static void
report_emergency_by_amount (const struct report_emergency_by_amount (
TALER_DenominationKeyValidityPS *issue, const struct TALER_DenominationKeyValidityPS *issue,
const struct TALER_Amount *risk, const struct TALER_Amount *risk,
const struct TALER_Amount *loss) const struct TALER_Amount *loss)
{ {
@ -232,8 +232,8 @@ report_emergency_by_amount (const struct
* @param risk amount that is at risk * @param risk amount that is at risk
*/ */
static void static void
report_emergency_by_count (const struct report_emergency_by_count (
TALER_DenominationKeyValidityPS *issue, const struct TALER_DenominationKeyValidityPS *issue,
uint64_t num_issued, uint64_t num_issued,
uint64_t num_known, uint64_t num_known,
const struct TALER_Amount *risk) const struct TALER_Amount *risk)
@ -288,12 +288,11 @@ report_emergency_by_count (const struct
* profitable for the exchange, and 0 if it is unclear * profitable for the exchange, and 0 if it is unclear
*/ */
static void static void
report_amount_arithmetic_inconsistency (const char *operation, report_amount_arithmetic_inconsistency (
const char *operation,
uint64_t rowid, uint64_t rowid,
const struct const struct TALER_Amount *exchange,
TALER_Amount *exchange, const struct TALER_Amount *auditor,
const struct
TALER_Amount *auditor,
int profitable) int profitable)
{ {
struct TALER_Amount delta; struct TALER_Amount delta;
@ -1427,6 +1426,9 @@ deposit_cb (void *cls,
dr.deposit_fee = issue->fee_deposit; dr.deposit_fee = issue->fee_deposit;
dr.merchant = *merchant_pub; dr.merchant = *merchant_pub;
dr.coin_pub = *coin_pub; dr.coin_pub = *coin_pub;
/* NOTE: This is one of the operations we might eventually
want to do in parallel in the background to improve
auditor performance! */
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_DEPOSIT, GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_DEPOSIT,
&dr.purpose, &dr.purpose,
@ -2032,10 +2034,8 @@ analyze_coins (void *cls)
(qs = TALER_ARL_edb->select_recoup_refresh_above_serial_id ( (qs = TALER_ARL_edb->select_recoup_refresh_above_serial_id (
TALER_ARL_edb->cls, TALER_ARL_edb->cls,
TALER_ARL_esession, TALER_ARL_esession,
ppc. ppc.last_recoup_refresh_serial_id,
last_recoup_refresh_serial_id, &recoup_refresh_cb,
&
recoup_refresh_cb,
&cc))) &cc)))
{ {
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@ -2342,10 +2342,6 @@ main (int argc,
"KEY", "KEY",
"public key of the exchange (Crockford base32 encoded)", "public key of the exchange (Crockford base32 encoded)",
&TALER_ARL_master_pub), &TALER_ARL_master_pub),
GNUNET_GETOPT_option_flag ('r',
"TALER_ARL_restart",
"TALER_ARL_restart audit from the beginning (required on first run)",
&TALER_ARL_restart),
GNUNET_GETOPT_option_timetravel ('T', GNUNET_GETOPT_option_timetravel ('T',
"timetravel"), "timetravel"),
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
@ -2356,14 +2352,14 @@ main (int argc,
away and skip #TALER_OS_init(), which we do need */ away and skip #TALER_OS_init(), which we do need */
(void) TALER_project_data_default (); (void) TALER_project_data_default ();
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-auditor", GNUNET_log_setup ("taler-helper-auditor-coins",
"MESSAGE", "MESSAGE",
NULL)); NULL));
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, GNUNET_PROGRAM_run (argc,
argv, argv,
"taler-auditor", "taler-helper-auditor-coins",
"Audit Taler exchange database", "Audit Taler coin processing",
options, options,
&run, &run,
NULL)) NULL))

View File

@ -342,10 +342,6 @@ main (int argc,
"KEY", "KEY",
"public key of the exchange (Crockford base32 encoded)", "public key of the exchange (Crockford base32 encoded)",
&TALER_ARL_master_pub), &TALER_ARL_master_pub),
GNUNET_GETOPT_option_flag ('r',
"TALER_ARL_restart",
"TALER_ARL_restart audit from the beginning (required on first run)",
&TALER_ARL_restart),
GNUNET_GETOPT_option_timetravel ('T', GNUNET_GETOPT_option_timetravel ('T',
"timetravel"), "timetravel"),
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
@ -356,13 +352,13 @@ main (int argc,
away and skip #TALER_OS_init(), which we do need */ away and skip #TALER_OS_init(), which we do need */
(void) TALER_project_data_default (); (void) TALER_project_data_default ();
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-auditor-deposits", GNUNET_log_setup ("taler-helper-auditor-deposits",
"MESSAGE", "MESSAGE",
NULL)); NULL));
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, GNUNET_PROGRAM_run (argc,
argv, argv,
"taler-auditor-deposits", "taler-helper-auditor-deposits",
"Audit Taler exchange database for deposit confirmation consistency", "Audit Taler exchange database for deposit confirmation consistency",
options, options,
&run, &run,
@ -372,4 +368,4 @@ main (int argc,
} }
/* end of taler-auditor-deposits.c */ /* end of taler-helper-auditor-deposits.c */

View File

@ -45,8 +45,6 @@ jsonData4 = json.load(jsonFile4)
jsonFile5 = open (sys.argv[5], 'r') jsonFile5 = open (sys.argv[5], 'r')
jsonData5 = json.load(jsonFile5) jsonData5 = json.load(jsonFile5)
jsonFile6 = open (sys.argv[6], 'r')
jsonData6 = json.load(jsonFile6)
jinjaEnv = jinja2.Environment(loader=StdinLoader(), jinjaEnv = jinja2.Environment(loader=StdinLoader(),
lstrip_blocks=True, lstrip_blocks=True,
@ -55,4 +53,4 @@ jinjaEnv = jinja2.Environment(loader=StdinLoader(),
autoescape=False) autoescape=False)
tmpl = jinjaEnv.get_template('stdin'); tmpl = jinjaEnv.get_template('stdin');
print(tmpl.render(data = jsonData1, wire = jsonData2, aggregation = jsonData3, coins = jsonData4, deposits = jsonData5, reserves = jsonData6)) print(tmpl.render(aggregation = jsonData1, coins = jsonData2, deposits = jsonData3, reserves = jsonData4, wire = jsonData5))

View File

@ -529,7 +529,7 @@ handle_reserve_out (void *cls,
/* check that execution date is within withdraw range for denom_pub */ /* check that execution date is within withdraw range for denom_pub */
valid_start = GNUNET_TIME_absolute_ntoh (issue->start); valid_start = GNUNET_TIME_absolute_ntoh (issue->start);
expire_withdraw = GNUNET_TIME_absolute_ntoh (issue->expire_withdraw); expire_withdraw = GNUNET_TIME_absolute_ntoh (issue->expire_withdraw);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking withdraw timing: %llu, expire: %llu, timing: %llu\n", "Checking withdraw timing: %llu, expire: %llu, timing: %llu\n",
(unsigned long long) valid_start.abs_value_us, (unsigned long long) valid_start.abs_value_us,
(unsigned long long) expire_withdraw.abs_value_us, (unsigned long long) expire_withdraw.abs_value_us,
@ -1641,10 +1641,6 @@ main (int argc,
"KEY", "KEY",
"public key of the exchange (Crockford base32 encoded)", "public key of the exchange (Crockford base32 encoded)",
&TALER_ARL_master_pub), &TALER_ARL_master_pub),
GNUNET_GETOPT_option_flag ('r',
"TALER_ARL_restart",
"TALER_ARL_restart audit from the beginning (required on first run)",
&TALER_ARL_restart),
GNUNET_GETOPT_option_timetravel ('T', GNUNET_GETOPT_option_timetravel ('T',
"timetravel"), "timetravel"),
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
@ -1655,13 +1651,13 @@ main (int argc,
away and skip #TALER_OS_init(), which we do need */ away and skip #TALER_OS_init(), which we do need */
(void) TALER_project_data_default (); (void) TALER_project_data_default ();
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-auditor-reserves", GNUNET_log_setup ("taler-helper-auditor-reserves",
"MESSAGE", "MESSAGE",
NULL)); NULL));
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, GNUNET_PROGRAM_run (argc,
argv, argv,
"taler-auditor-reserves", "taler-helper-auditor-reserves",
"Audit Taler exchange reserve handling", "Audit Taler exchange reserve handling",
options, options,
&run, &run,

View File

@ -451,17 +451,6 @@ do_shutdown (void *cls)
struct WireAccount *wa; struct WireAccount *wa;
(void) cls; (void) cls;
if (NULL != ctx)
{
GNUNET_CURL_fini (ctx);
ctx = NULL;
}
if (NULL != rc)
{
GNUNET_CURL_gnunet_rc_destroy (rc);
rc = NULL;
}
if (NULL != report_row_inconsistencies) if (NULL != report_row_inconsistencies)
{ {
json_t *report; json_t *report;
@ -608,6 +597,16 @@ do_shutdown (void *cls)
GNUNET_free (wa->section_name); GNUNET_free (wa->section_name);
GNUNET_free (wa); GNUNET_free (wa);
} }
if (NULL != ctx)
{
GNUNET_CURL_fini (ctx);
ctx = NULL;
}
if (NULL != rc)
{
GNUNET_CURL_gnunet_rc_destroy (rc);
rc = NULL;
}
} }
@ -874,7 +873,7 @@ wire_missing_cb (void *cls,
* (based on deposits) have indeed happened. * (based on deposits) have indeed happened.
*/ */
static void static void
check_for_required_transfers () check_for_required_transfers (void)
{ {
struct GNUNET_TIME_Absolute next_timestamp; struct GNUNET_TIME_Absolute next_timestamp;
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
@ -1932,11 +1931,24 @@ reserve_closed_cb (void *cls,
* @return transaction status code * @return transaction status code
*/ */
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
begin_transaction (void *cls) begin_transaction (void)
{ {
int ret; int ret;
(void) cls; TALER_ARL_esession = TALER_ARL_edb->get_session (TALER_ARL_edb->cls);
if (NULL == TALER_ARL_esession)
{
fprintf (stderr,
"Failed to initialize exchange session.\n");
return GNUNET_SYSERR;
}
TALER_ARL_asession = TALER_ARL_adb->get_session (TALER_ARL_adb->cls);
if (NULL == TALER_ARL_asession)
{
fprintf (stderr,
"Failed to initialize auditor session.\n");
return GNUNET_SYSERR;
}
ret = TALER_ARL_adb->start (TALER_ARL_adb->cls, ret = TALER_ARL_adb->start (TALER_ARL_adb->cls,
TALER_ARL_asession); TALER_ARL_asession);
if (GNUNET_OK != ret) if (GNUNET_OK != ret)
@ -1987,14 +1999,13 @@ begin_transaction (void *cls)
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx_gwap) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx_gwap)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
_ ( "First analysis of with wire auditor, starting audit from scratch\n");
"First analysis using this auditor, starting audit from scratch\n"));
} }
else else
{ {
start_pp = pp; start_pp = pp;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming audit at %s / %llu\n", "Resuming wire audit at %s / %llu\n",
GNUNET_STRINGS_absolute_time_to_string (pp.last_timestamp), GNUNET_STRINGS_absolute_time_to_string (pp.last_timestamp),
(unsigned long long) pp.last_reserve_close_uuid); (unsigned long long) pp.last_reserve_close_uuid);
} }
@ -2168,9 +2179,8 @@ run (void *cls,
TALER_EXCHANGEDB_find_accounts (TALER_ARL_cfg, TALER_EXCHANGEDB_find_accounts (TALER_ARL_cfg,
&process_account_cb, &process_account_cb,
NULL); NULL);
if (GNUNET_OK != if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
TALER_ARL_setup_sessions_and_run (&begin_transaction, begin_transaction ())
NULL))
{ {
global_ret = 1; global_ret = 1;
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
@ -2179,8 +2189,9 @@ run (void *cls,
/** /**
* The main function of the database initialization tool. * The main function of the wire auditing tool. Checks that
* Used to initialize the Taler Exchange's database. * the exchange's records of wire transfers match that of
* the wire gateway.
* *
* @param argc number of arguments from the command line * @param argc number of arguments from the command line
* @param argv command line arguments * @param argv command line arguments
@ -2196,10 +2207,6 @@ main (int argc,
"KEY", "KEY",
"public key of the exchange (Crockford base32 encoded)", "public key of the exchange (Crockford base32 encoded)",
&TALER_ARL_master_pub), &TALER_ARL_master_pub),
GNUNET_GETOPT_option_flag ('r',
"TALER_ARL_restart",
"TALER_ARL_restart audit from the beginning (required on first run)",
&TALER_ARL_restart),
GNUNET_GETOPT_option_timetravel ('T', GNUNET_GETOPT_option_timetravel ('T',
"timetravel"), "timetravel"),
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
@ -2210,13 +2217,13 @@ main (int argc,
away and skip #TALER_OS_init(), which we do need */ away and skip #TALER_OS_init(), which we do need */
(void) TALER_project_data_default (); (void) TALER_project_data_default ();
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-wire-auditor", GNUNET_log_setup ("taler-helper-auditor-wire",
"MESSAGE", "MESSAGE",
NULL)); NULL));
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, GNUNET_PROGRAM_run (argc,
argv, argv,
"taler-wire-auditor", "taler-helper-auditor-wire",
"Audit exchange database for consistency with the bank's wire transfers", "Audit exchange database for consistency with the bank's wire transfers",
options, options,
&run, &run,

View File

@ -80,30 +80,25 @@ function audit_only () {
# Run the auditor! # Run the auditor!
echo -n "Running audit(s) ..." echo -n "Running audit(s) ..."
# NOTE: this should be removed soon... # Restart so that first run is always fresh, and second one is incremental
$VALGRIND taler-auditor -L DEBUG -r -c $CONF -m $MASTER_PUB > test-audit.json 2> test-audit.log || exit_fail "auditor failed" taler-auditor-dbinit -r -c $CONF
echo -n "." $VALGRIND taler-helper-auditor-aggregation -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-aggregation.json 2> test-audit-aggregation.log || exit_fail "aggregation audit failed"
# Also do incremental run
$VALGRIND taler-auditor -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-inc.json 2> test-audit-inc.log || exit_fail "auditor failed"
echo -n "."
$VALGRIND taler-helper-auditor-aggregation -L DEBUG -r -c $CONF -m $MASTER_PUB > test-audit-aggregation.json 2> test-audit-aggregation.log || exit_fail "aggregation audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-aggregation -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-aggregation-inc.json 2> test-audit-aggregation-inc.log || exit_fail "incremental aggregation audit failed" $VALGRIND taler-helper-auditor-aggregation -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-aggregation-inc.json 2> test-audit-aggregation-inc.log || exit_fail "incremental aggregation audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-coins -L DEBUG -r -c $CONF -m $MASTER_PUB > test-audit-coins.json 2> test-audit-coins.log || exit_fail "coin audit failed" $VALGRIND taler-helper-auditor-coins -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-coins.json 2> test-audit-coins.log || exit_fail "coin audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-coins -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-coins-inc.json 2> test-audit-coins-inc.log || exit_fail "incremental coin audit failed" $VALGRIND taler-helper-auditor-coins -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-coins-inc.json 2> test-audit-coins-inc.log || exit_fail "incremental coin audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-deposits -L DEBUG -r -c $CONF -m $MASTER_PUB > test-audit-deposits.json 2> test-audit-deposits.log || exit_fail "deposits audit failed" $VALGRIND taler-helper-auditor-deposits -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-deposits.json 2> test-audit-deposits.log || exit_fail "deposits audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-deposits -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-deposits-inc.json 2> test-audit-deposits-inc.log || exit_fail "incremental deposits audit failed" $VALGRIND taler-helper-auditor-deposits -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-deposits-inc.json 2> test-audit-deposits-inc.log || exit_fail "incremental deposits audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-reserves -L DEBUG -r -c $CONF -m $MASTER_PUB > test-audit-reserves.json 2> test-audit-reserves.log || exit_fail "reserves audit failed" $VALGRIND taler-helper-auditor-reserves -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-reserves.json 2> test-audit-reserves.log || exit_fail "reserves audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-reserves -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-reserves-inc.json 2> test-audit-reserves-inc.log || exit_fail "incremental reserves audit failed" $VALGRIND taler-helper-auditor-reserves -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-reserves-inc.json 2> test-audit-reserves-inc.log || exit_fail "incremental reserves audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-wire -L DEBUG -r -c $CONF -m $MASTER_PUB > test-audit-wire.json 2> test-wire-audit.log || exit_fail "wire audit failed" $VALGRIND taler-helper-auditor-wire -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire.json 2> test-wire-audit.log || exit_fail "wire audit failed"
echo -n "." echo -n "."
$VALGRIND taler-helper-auditor-wire -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire-inc.json 2> test-wire-audit-inc.log || exit_fail "wire audit failed" $VALGRIND taler-helper-auditor-wire -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire-inc.json 2> test-wire-audit-inc.log || exit_fail "wire audit failed"
echo -n "." echo -n "."
@ -119,7 +114,7 @@ function post_audit () {
wait wait
echo "DONE" echo "DONE"
echo -n "TeXing ." echo -n "TeXing ."
../../contrib/render.py test-audit.json test-audit-wire.json test-audit-aggregation.json test-audit-coins.json test-audit-deposits.json test-audit-reserves.json < ../../contrib/auditor-report.tex.j2 > test-report.tex || exit_fail "Renderer failed" taler-helper-auditor-render.py test-audit-aggregation.json test-audit-coins.json test-audit-deposits.json test-audit-reserves.json test-audit-wire.json < ../../contrib/auditor-report.tex.j2 > test-report.tex || exit_fail "Renderer failed"
echo -n "." echo -n "."
timeout 10 pdflatex test-report.tex >/dev/null || exit_fail "pdflatex failed" timeout 10 pdflatex test-report.tex >/dev/null || exit_fail "pdflatex failed"

View File

@ -152,7 +152,6 @@ handle_credit_history_finished (void *cls,
switch (response_code) switch (response_code)
{ {
case 0: case 0:
GNUNET_break_op (0);
ec = TALER_EC_INVALID_RESPONSE; ec = TALER_EC_INVALID_RESPONSE;
break; break;
case MHD_HTTP_OK: case MHD_HTTP_OK:

View File

@ -7,6 +7,9 @@ TALER_TEST_HOME = test_taler_exchange_httpd_home/
CURRENCY = EUR CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01 CURRENCY_ROUND_UNIT = EUR:0.01
[auditor]
TINY_AMOUNT = EUR:0.01
[exchange] [exchange]
# Directory with our terms of service. # Directory with our terms of service.
@ -65,7 +68,10 @@ PAYTO_URI = "payto://x-taler-bank/localhost:8082/3"
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json
ENABLE_DEBIT = YES ENABLE_DEBIT = YES
ENABLE_CREDIT = YES ENABLE_CREDIT = YES
TALER_BANK_AUTH_METHOD = NONE WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange
PASSWORD = x
WIRE_GATEWAY_URL = "http://localhost:8082/3/"
# Wire fees are specified by wire method # Wire fees are specified by wire method