From a98825675b37988c059576b5bfd98bac173bdc25 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 14 Feb 2019 14:23:16 +0100 Subject: add option to be selective about dropping the exchange list --- src/auditor-lib/.gitignore | 4 --- src/auditor/taler-auditor-dbinit.c | 3 ++- src/auditor/taler-auditor.c | 7 ++--- src/auditor/taler-wire-auditor.c | 3 ++- src/auditordb/plugin_auditordb_postgres.c | 13 +++++++-- src/include/taler_auditordb_plugin.h | 4 ++- src/lib/test_auditor_api.c | 45 +++++++------------------------ 7 files changed, 32 insertions(+), 47 deletions(-) delete mode 100644 src/auditor-lib/.gitignore diff --git a/src/auditor-lib/.gitignore b/src/auditor-lib/.gitignore deleted file mode 100644 index ce6edcc39..000000000 --- a/src/auditor-lib/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -test_auditor_api -test_exchange_api_home/.local/share/taler/auditors/ -test_exchange_api_home/.local/share/taler/exchange/live-keys/ -auditor.in diff --git a/src/auditor/taler-auditor-dbinit.c b/src/auditor/taler-auditor-dbinit.c index 185a39413..5031ed9f5 100644 --- a/src/auditor/taler-auditor-dbinit.c +++ b/src/auditor/taler-auditor-dbinit.c @@ -64,7 +64,8 @@ run (void *cls, return; } if (reset_db) - (void) plugin->drop_tables (plugin->cls); + (void) plugin->drop_tables (plugin->cls, + GNUNET_YES); if (GNUNET_OK != plugin->create_tables (plugin->cls)) { diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index dced807b1..d3afbb3d1 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -2489,7 +2489,7 @@ get_wire_fee (struct AggregationContext *ac, * @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration */ static int -check_wire_out_cb +check_wire_out_cb (void *cls, uint64_t rowid, struct GNUNET_TIME_Absolute date, @@ -4391,7 +4391,7 @@ test_master_present (void *cls, const char *exchange_url) { int *found = cls; - + (void) exchange_url; if (0 == memcmp (mpub, &master_pub, @@ -4529,7 +4529,8 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Full audit restart requested, dropping old audit data.\n"); GNUNET_break (GNUNET_OK == - adb->drop_tables (adb->cls)); + adb->drop_tables (adb->cls, + GNUNET_NO)); TALER_AUDITORDB_plugin_unload (adb); if (NULL == (adb = TALER_AUDITORDB_plugin_load (cfg))) diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c index 6e66ea99c..c903a4943 100644 --- a/src/auditor/taler-wire-auditor.c +++ b/src/auditor/taler-wire-auditor.c @@ -1605,7 +1605,8 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Full audit restart requested, dropping old audit data.\n"); GNUNET_break (GNUNET_OK == - adb->drop_tables (adb->cls)); + adb->drop_tables (adb->cls, + GNUNET_NO)); TALER_AUDITORDB_plugin_unload (adb); if (NULL == (adb = TALER_AUDITORDB_plugin_load (cfg))) diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index bd216a117..1ca5df3ae 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -131,10 +131,12 @@ connect_to_postgres (struct PostgresClosure *pc) * Drop all Taler tables. This should only be used by testcases. * * @param cls the `struct PostgresClosure` with the plugin-specific state + * @param drop_exchangelist should we also drop the exchange table? * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ static int -postgres_drop_tables (void *cls) +postgres_drop_tables (void *cls, + int drop_exchangelist) { struct PostgresClosure *pc = cls; struct GNUNET_PQ_ExecuteStatement es[] = { @@ -152,10 +154,13 @@ postgres_drop_tables (void *cls) GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_deposit_confirmation;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_coin;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_auditor_progress;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_exchanges CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS deposit_confirmations CASCADE;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; + struct GNUNET_PQ_ExecuteStatement esx[] = { + GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_exchanges CASCADE;"), + GNUNET_PQ_EXECUTE_STATEMENT_END + }; PGconn *conn; int ret; @@ -166,6 +171,10 @@ postgres_drop_tables (void *cls) "Dropping ALL tables\n"); ret = GNUNET_PQ_exec_statements (conn, es); + if ( (ret >= 0) && + (drop_exchangelist) ) + ret = GNUNET_PQ_exec_statements (conn, + esx); /* TODO: we probably need a bit more fine-grained control over drops for the '-r' option of taler-auditor; also, for the testcase, we currently fail to drop the diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index aa280b1bd..7f30d70e7 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -401,10 +401,12 @@ struct TALER_AUDITORDB_Plugin * Drop the Taler tables. This should only be used in testcases. * * @param cls the @e cls of this struct with the plugin-specific state + * @param drop_exchangelist should we also drop the list of audited exchanges * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ int - (*drop_tables) (void *cls); + (*drop_tables) (void *cls, + int drop_exchangelist); /** diff --git a/src/lib/test_auditor_api.c b/src/lib/test_auditor_api.c index 1794131ad..88548e805 100644 --- a/src/lib/test_auditor_api.c +++ b/src/lib/test_auditor_api.c @@ -292,77 +292,66 @@ run (void *cls, "EUR:10.10", 42, 2), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-1", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-2", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-3", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-4", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-5", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-6", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-7", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-8", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-9", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-10", exchange_url, "EUR:0.98", 2, 43), - TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), TALER_TESTING_cmd_end () }; @@ -559,9 +548,7 @@ run (void *cls, */ CMD_TRANSFER_TO_EXCHANGE ("massive-reserve", "EUR:10.10"), - CMD_EXEC_WIREWATCH ("massive-wirewatch"), - TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-1", "massive-reserve", "EUR:1", @@ -615,130 +602,118 @@ run (void *cls, ("massive-deposit-1", "massive-withdraw-1", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("massive-deposit-2", "massive-withdraw-2", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("massive-deposit-3", "massive-withdraw-3", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("massive-deposit-4", "massive-withdraw-4", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("massive-deposit-5", "massive-withdraw-5", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("massive-deposit-6", "massive-withdraw-6", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("massive-deposit-7", "massive-withdraw-7", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("massive-deposit-8", "massive-withdraw-8", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("massive-deposit-9", "massive-withdraw-9", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - - TALER_TESTING_cmd_deposit ("massive-deposit-10", "massive-withdraw-10", 0, - TALER_TESTING_make_wire_details + TALER_TESTING_make_wire_details (43, fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - CMD_RUN_AUDITOR("massive-auditor"), TALER_TESTING_cmd_end () }; struct TALER_TESTING_Command commands[] = { - CMD_RUN_AUDITOR ("virgin-auditor"), CMD_RUN_WIRE_AUDITOR ("virgin-wire-auditor"), TALER_TESTING_cmd_exchanges_with_url ("check-exchange", -- cgit v1.2.3