diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/taler_wire_plugin.h | 25 | ||||
-rw-r--r-- | src/wire-plugins/Makefile.am | 14 | ||||
-rw-r--r-- | src/wire-plugins/plugin_wire_taler-bank.c | 86 | ||||
-rw-r--r-- | src/wire-plugins/test_wire_plugin_legacy_taler-bank.c | 373 | ||||
-rw-r--r-- | src/wire-plugins/test_wire_plugin_legacy_taler-bank.conf | 12 |
5 files changed, 1 insertions, 509 deletions
diff --git a/src/include/taler_wire_plugin.h b/src/include/taler_wire_plugin.h index 1ee1b6b49..eb43f2277 100644 --- a/src/include/taler_wire_plugin.h +++ b/src/include/taler_wire_plugin.h @@ -314,31 +314,6 @@ struct TALER_WIRE_Plugin void *hres_cb_cls); /** - * Query transfer history of an account. The query is based on - * the dates where the wire transfers got settled at the bank. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param account_section specifies the configuration section which - * identifies the account for which we should get the history - * @param direction what kinds of wire transfers should be returned - * @param start_date each history entry in the result will be time - * stamped after, or at this date. - * @param end_date each history entry in the result will be time - * stamped before, or at this date. - * @param hres_cb the callback to call with the transaction history - * @param hres_cb_cls closure for the above callback - * @param return the operation handle, or NULL on errors. - */ - struct TALER_WIRE_HistoryHandle * - (*get_history_range) (void *cls, - const char *account_section, - enum TALER_BANK_Direction direction, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date, - TALER_WIRE_HistoryResultCallback hres_cb, - void *hres_cb_cls); - - /** * Cancel going over the account's history. * * @param cls plugins' closure diff --git a/src/wire-plugins/Makefile.am b/src/wire-plugins/Makefile.am index 83bb9f05f..468e95a0b 100644 --- a/src/wire-plugins/Makefile.am +++ b/src/wire-plugins/Makefile.am @@ -74,8 +74,7 @@ AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH= TESTS = \ test_ebics_wireformat \ test_wire_plugin \ - test_wire_plugin_transactions_taler_bank \ - test_wire_plugin_legacy_taler_bank + test_wire_plugin_transactions_taler_bank check_PROGRAMS= $(TESTS) @@ -95,17 +94,6 @@ test_wire_plugin_LDADD = \ $(top_builddir)/src/util/libtalerutil.la -test_wire_plugin_legacy_taler_bank_SOURCES = \ - test_wire_plugin_legacy_taler-bank.c -test_wire_plugin_legacy_taler_bank_LDADD = \ - -lgnunetjson \ - -lgnunetutil \ - -ljansson \ - $(top_builddir)/src/wire/libtalerwire.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ - $(top_builddir)/src/bank-lib/libtalerfakebank.la \ - $(top_builddir)/src/util/libtalerutil.la - test_wire_plugin_transactions_taler_bank_SOURCES = \ test_wire_plugin_transactions_taler-bank.c test_wire_plugin_transactions_taler_bank_LDADD = \ diff --git a/src/wire-plugins/plugin_wire_taler-bank.c b/src/wire-plugins/plugin_wire_taler-bank.c index 282856ecf..c9d8cf2ac 100644 --- a/src/wire-plugins/plugin_wire_taler-bank.c +++ b/src/wire-plugins/plugin_wire_taler-bank.c @@ -1050,92 +1050,6 @@ taler_bank_get_history (void *cls, return whh; } - - -/** - * Query transfer history of an account. The query is based on - * the dates where the wire transfers got settled at the bank. - * - * @param cls the @e cls of this struct with the plugin-specific - * state - * @param account_section specifies the configuration section which - * identifies the account for which we should get the - * history - * @param direction what kinds of wire transfers should be returned - * @param start_date each history entry in the result will be time - * stamped after, or at this date. - * @param end_date each history entry in the result will be time - * stamped before, or at this date. - * @param hres_cb the callback to call with the transaction history - * @param hres_cb_cls closure for the above callback - * @param return the operation handle, or NULL on errors. - */ -static struct TALER_WIRE_HistoryHandle * -taler_bank_get_history_range - (void *cls, - const char *account_section, - enum TALER_BANK_Direction direction, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date, - TALER_WIRE_HistoryResultCallback hres_cb, - void *hres_cb_cls) -{ - struct TALER_Account account; - struct TalerBankClosure *tc = cls; - struct TALER_WIRE_HistoryHandle *whh; - - if (GNUNET_OK != - parse_account_cfg (tc->cfg, - account_section, - &account)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Could not parse the config section '%s'\n", - account_section); - return NULL; - } - - whh = GNUNET_new (struct TALER_WIRE_HistoryHandle); - whh->hres_cb = hres_cb; - whh->hres_cb_cls = hres_cb_cls; - - if (GNUNET_OK != - TALER_BANK_auth_parse_cfg (tc->cfg, - account_section, - &whh->auth)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Could not parse the auth values from '%s'\n", - account_section); - GNUNET_free (whh); - return NULL; - } - whh->hh = TALER_BANK_history_range (tc->ctx, - account.details.x_taler_bank.bank_base_url, - &whh->auth, - account.details.x_taler_bank.no, - direction, - /* Just always descending. */ - GNUNET_NO, - start_date, - end_date, - &bhist_cb, - whh); - if (NULL == whh->hh) - { - GNUNET_break (0); - taler_bank_get_history_cancel (NULL, - whh); - TALER_WIRE_account_free (&account); - return NULL; - } - TALER_WIRE_account_free (&account); - GNUNET_assert (NULL != whh); - - return whh; -} - - /** * Context for a rejection operation. */ diff --git a/src/wire-plugins/test_wire_plugin_legacy_taler-bank.c b/src/wire-plugins/test_wire_plugin_legacy_taler-bank.c deleted file mode 100644 index 690666f87..000000000 --- a/src/wire-plugins/test_wire_plugin_legacy_taler-bank.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - This file is part of TALER - (C) 2015-2018 Taler Systems SA - - 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 Foundation; either version 3, or - (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with TALER; see the file COPYING. If not, - see <http://www.gnu.org/licenses/> -*/ - -/** - * @file wire/test_wire_plugin_legacy_taler-bank.c - * @brief Tests legacy history-range API against the Fakebank. - * Version for the real Python bank forthcoming. - * - * @author Christian Grothoff - * @author Marcello Stanisci - */ -#include "platform.h" -#include "taler_util.h" -#include "taler_wire_lib.h" -#include "taler_wire_plugin.h" -#include "taler_fakebank_lib.h" -#include <gnunet/gnunet_json_lib.h> - -/** - * How many wire transfers this test should accomplish, before - * delving into actual checks. - */ -#define NTRANSACTIONS 5 - -/** - * Destination account to use. - */ -static const char *dest_account = "payto://x-taler-bank/localhost:8088/42"; - -/** - * Origin account, section in the configuration file. - */ -static const char *my_account = "account-test"; - -/** - * Our configuration. - */ -static struct GNUNET_CONFIGURATION_Handle *cfg; - -/** - * Set to #GNUNET_SYSERR if the test failed. - */ -static int global_ret; - -/** - * The 'test' plugin that we are using for the test. - */ -static struct TALER_WIRE_Plugin *plugin; - -/** - * Active preparation handle, or NULL if not active. - */ -static struct TALER_WIRE_PrepareHandle *ph; - -/** - * Active execution handle, or NULL if not active. - */ -static struct TALER_WIRE_ExecuteHandle *eh; - -/** - * Handle to the bank. - */ -static struct TALER_FAKEBANK_Handle *fb; - -/** - * Handle to the history-range request (the "legacy" bank API). - */ -static struct TALER_WIRE_HistoryHandle *hhr; - -/** - * Wire transfer identifier we are using. - */ -static struct TALER_WireTransferIdentifierRawP wtid; - -/** - * Number of total transaction to make it happen in the test. - */ -static int Ntransactions = NTRANSACTIONS; -static int ntransactions = NTRANSACTIONS; -static int ztransactions = 0; - -/** - * Timestamp used as the oldest extreme in the query range. - */ -static struct GNUNET_TIME_Absolute first_timestamp; - -/** - * Function called on shutdown (regular, error or CTRL-C). - * - * @param cls NULL - */ -static void -do_shutdown (void *cls) -{ - TALER_FAKEBANK_stop (fb); - fb = NULL; - if (NULL != eh) - { - plugin->execute_wire_transfer_cancel (plugin->cls, - eh); - eh = NULL; - } - if (NULL != ph) - { - plugin->prepare_wire_transfer_cancel (plugin->cls, - ph); - ph = NULL; - } - - if (NULL != hhr) - { - plugin->get_history_cancel (plugin->cls, - hhr); - hhr = NULL; - } - - TALER_WIRE_plugin_unload (plugin); -} - - -/** - * Callbacks of this type are used to serve the result of asking - * the bank for the transaction history. - * - * @param cls closure - * @param ec taler status code - * @param dir direction of the transfer - * @param row_off identification of the position at - * which we are querying - * @param row_off_size number of bytes in @a row_off - * @param details details about the wire transfer - * @return #GNUNET_OK to continue, #GNUNET_SYSERR to - * abort iteration - */ -static int -history_result_cb - (void *cls, - enum TALER_ErrorCode ec, - enum TALER_BANK_Direction dir, - const void *row_off, - size_t row_off_size, - const struct TALER_WIRE_TransferDetails *details) -{ - int *expected_number = cls; - static int accumulator = 0; - - if ( (TALER_BANK_DIRECTION_NONE == dir) && - (GNUNET_OK == global_ret) ) - { - /* End-of-list, check all the transactions got accounted - * into the history. */ - - if (*expected_number != accumulator) - { - GNUNET_break (0); - TALER_LOG_ERROR - ("Unexpected # of transactions: %d, %d were expected.\n", - accumulator, - *expected_number); - global_ret = GNUNET_NO; - } - - if (ztransactions != *expected_number) - { - /* Call the second test, under the assumption that after - * running the test with ztransactions expected entries, - * we shut the test down. */ - - accumulator = 0; - GNUNET_assert - (NULL != (hhr = plugin->get_history_range - (plugin->cls, - my_account, - TALER_BANK_DIRECTION_BOTH, - GNUNET_TIME_UNIT_ZERO_ABS, - GNUNET_TIME_absolute_subtract - (first_timestamp, - GNUNET_TIME_UNIT_HOURS), - &history_result_cb, - - /** - * Zero results are expected from 1970 up to 1 hour ago. - */ - &ztransactions))); - - return GNUNET_OK; - } - - GNUNET_SCHEDULER_shutdown (); - return GNUNET_OK; - } - - accumulator++; - return GNUNET_OK; -} - - -/** - * Function called with the result from the execute step. - * - * @param cls closure - * @param success #GNUNET_OK on success, - * #GNUNET_SYSERR on failure - * @param row_id ID of the fresh transaction, - * in _network_ byte order. - * @param emsg NULL on success, otherwise an error message - */ -static void -confirmation_cb (void *cls, - int success, - const void *row_id, - size_t row_id_size, - const char *emsg); - -/** - * Callback with prepared transaction. - * - * @param cls closure - * @param buf transaction data to persist, NULL on error - * @param buf_size number of bytes in @a buf, 0 on error - */ -static void -prepare_cb (void *cls, - const char *buf, - size_t buf_size) -{ - ph = NULL; - if (NULL == buf) - { - GNUNET_break (0); - global_ret = GNUNET_SYSERR; - GNUNET_SCHEDULER_shutdown (); - return; - } - plugin->execute_wire_transfer (plugin->cls, - buf, - buf_size, - &confirmation_cb, - NULL); -} - -/** - * Function called with the result from the execute step. - * - * @param cls closure - * @param success #GNUNET_OK on success, - * #GNUNET_SYSERR on failure - * @param row_id ID of the fresh transaction, - * in _network_ byte order. - * @param emsg NULL on success, otherwise an error message - */ -static void -confirmation_cb (void *cls, - int success, - const void *row_id, - size_t row_id_size, - const char *emsg) -{ - struct TALER_Amount amount; - - eh = NULL; - if (GNUNET_OK != success) - { - GNUNET_break (0); - global_ret = GNUNET_SYSERR; - GNUNET_SCHEDULER_shutdown (); - return; - } - - if (0 >= --Ntransactions) - { - GNUNET_assert - (NULL != (hhr = plugin->get_history_range - (plugin->cls, - my_account, - TALER_BANK_DIRECTION_BOTH, - GNUNET_TIME_UNIT_ZERO_ABS, - GNUNET_TIME_UNIT_FOREVER_ABS, - &history_result_cb, - &ntransactions))); - return; - } - - /* Issue a new wire transfer! */ - GNUNET_assert - (GNUNET_OK == TALER_string_to_amount ("KUDOS:5.01", - &amount)); - - ph = plugin->prepare_wire_transfer (plugin->cls, - my_account, - dest_account, - &amount, - "https://exchange.net/", - &wtid, - &prepare_cb, - NULL); -} - - -/** - * Run the test. - * - * @param cls NULL - */ -static void -run (void *cls) -{ - struct TALER_Amount amount; - GNUNET_SCHEDULER_add_shutdown (&do_shutdown, - NULL); - - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - &wtid, - sizeof (wtid)); - GNUNET_assert - (GNUNET_OK == TALER_string_to_amount ("KUDOS:5.01", - &amount)); - fb = TALER_FAKEBANK_start (8088); - - - first_timestamp = GNUNET_TIME_absolute_get (); - ph = plugin->prepare_wire_transfer (plugin->cls, - my_account, - dest_account, - &amount, - "https://exchange.net/", - &wtid, - &prepare_cb, - NULL); -} - - -int -main (int argc, - const char *const argv[]) -{ - GNUNET_log_setup ("test-wire-plugin-legacy-test", - "WARNING", - NULL); - cfg = GNUNET_CONFIGURATION_create (); - GNUNET_assert - (GNUNET_OK == GNUNET_CONFIGURATION_load - (cfg, - "test_wire_plugin_legacy_taler-bank.conf")); - global_ret = GNUNET_OK; - plugin = TALER_WIRE_plugin_load (cfg, - "taler_bank"); - GNUNET_assert (NULL != plugin); - GNUNET_SCHEDULER_run (&run, - NULL); - GNUNET_CONFIGURATION_destroy (cfg); - if (GNUNET_OK != global_ret) - return 1; - return 0; -} - -/* end of test_wire_plugin_legacy_taler-bank.c */ diff --git a/src/wire-plugins/test_wire_plugin_legacy_taler-bank.conf b/src/wire-plugins/test_wire_plugin_legacy_taler-bank.conf deleted file mode 100644 index d6d2e8346..000000000 --- a/src/wire-plugins/test_wire_plugin_legacy_taler-bank.conf +++ /dev/null @@ -1,12 +0,0 @@ -# This file is in the public domain. -# -[account-test] -# This is the response we give out for the /wire request. It provides -# wallets with the bank information for transfers to the exchange. - -TALER_BANK_AUTH_METHOD = NONE - -URL = payto://x-taler-bank/localhost:8088/2 - -[taler] -CURRENCY = "KUDOS" |