aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2019-09-04 15:01:31 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2019-09-04 15:01:31 +0200
commit1fc9595b2c66ac1b2af21c88f22d086defc8be57 (patch)
tree68494ff1e2934e13351a9d1705825089a8fff7be /src
parentf4ffc4a27bd3724d83c8d205b35d6ea884fc3cfe (diff)
Calling bank legacy API in a test
Diffstat (limited to 'src')
-rw-r--r--src/bank-lib/bank_api_history.c21
-rw-r--r--src/wire-plugins/plugin_wire_taler-bank.c49
-rw-r--r--src/wire-plugins/test_wire_plugin_transactions_taler-bank.c27
3 files changed, 61 insertions, 36 deletions
diff --git a/src/bank-lib/bank_api_history.c b/src/bank-lib/bank_api_history.c
index 6bc53cd50..74c462f07 100644
--- a/src/bank-lib/bank_api_history.c
+++ b/src/bank-lib/bank_api_history.c
@@ -369,16 +369,17 @@ conv_cancel (enum TALER_BANK_Direction direction)
* called.
*/
struct TALER_BANK_HistoryHandle *
-TALER_BANK_history_range (struct GNUNET_CURL_Context *ctx,
- const char *bank_base_url,
- const struct TALER_BANK_AuthenticationData *auth,
- uint64_t account_number,
- enum TALER_BANK_Direction direction,
- unsigned int ascending,
- struct GNUNET_TIME_Absolute start_date,
- struct GNUNET_TIME_Absolute end_date,
- TALER_BANK_HistoryResultCallback hres_cb,
- void *hres_cb_cls)
+TALER_BANK_history_range
+ (struct GNUNET_CURL_Context *ctx,
+ const char *bank_base_url,
+ const struct TALER_BANK_AuthenticationData *auth,
+ uint64_t account_number,
+ enum TALER_BANK_Direction direction,
+ unsigned int ascending,
+ struct GNUNET_TIME_Absolute start_date,
+ struct GNUNET_TIME_Absolute end_date,
+ TALER_BANK_HistoryResultCallback hres_cb,
+ void *hres_cb_cls)
{
struct TALER_BANK_HistoryHandle *hh;
char *url;
diff --git a/src/wire-plugins/plugin_wire_taler-bank.c b/src/wire-plugins/plugin_wire_taler-bank.c
index 6b92f4744..f66566372 100644
--- a/src/wire-plugins/plugin_wire_taler-bank.c
+++ b/src/wire-plugins/plugin_wire_taler-bank.c
@@ -808,19 +808,23 @@ taler_bank_get_history_cancel (void *cls,
/**
- * Function called with results from the bank about the transaction history.
+ * Function called with results from the bank
+ * about the transaction history.
*
* @param cls the `struct TALER_WIRE_HistoryHandle`
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
- * 0 if the bank's reply is bogus (fails to follow the protocol),
- * #MHD_HTTP_NO_CONTENT if there are no more results; on success the
- * last callback is always of this status (even if `abs(num_results)` were
- * already returned).
+ * @param http_status HTTP response code, #MHD_HTTP_OK (200)
+ * for successful status request 0 if the bank's reply
+ * is bogus (fails to follow the protocol),
+ * #MHD_HTTP_NO_CONTENT if there are no more results; on
+ * success the last callback is always of this status
+ * (even if `abs(num_results)` were already returned).
* @param ec taler error code
* @param dir direction of the transfer
- * @param serial_id monotonically increasing counter corresponding to the transaction
+ * @param serial_id monotonically increasing
+ * counter corresponding to the transaction
* @param details details about the wire transfer
- * @param json detailed response from the HTTPD, or NULL if reply was not in JSON
+ * @param json detailed response from the HTTPD,
+ * or NULL if reply was not in JSON
*/
static void
bhist_cb (void *cls,
@@ -849,12 +853,14 @@ bhist_cb (void *cls,
(unsigned char) ' ');
if (NULL != space)
{
- /* Space separates the actual wire transfer subject from the
- exchange base URL (if present, expected only for outgoing
- transactions). So we cut the string off at the space. */
+ /* Space separates the actual wire transfer subject
+ from the exchange base URL (if present, expected
+ only for outgoing transactions). So we cut the
+ string off at the space. */
*space = '\0';
}
- /* NOTE: For a real bank, the subject should include a checksum! */
+ /* NOTE: For a real bank, the subject should include a
+ checksum! */
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (subject,
strlen (subject),
@@ -1069,18 +1075,13 @@ taler_bank_get_history (void *cls,
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)
+ 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)
{
-
- /* FIXME: remove the following lines when addressing #5746*/
- GNUNET_break (0);
- return NULL;
-
struct TALER_Account account;
struct TalerBankClosure *tc = cls;
struct TALER_WIRE_HistoryHandle *whh;
@@ -1111,8 +1112,6 @@ taler_bank_get_history_range
GNUNET_free (whh);
return NULL;
}
-
-
whh->hh = TALER_BANK_history_range (tc->ctx,
account.details.x_taler_bank.bank_base_url,
&whh->auth,
diff --git a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c b/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c
index 304890dcb..3d7fa76e0 100644
--- a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c
+++ b/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c
@@ -79,6 +79,11 @@ static struct TALER_FAKEBANK_Handle *fb;
static struct TALER_WIRE_HistoryHandle *hh;
/**
+ * Handle to the history-range request (the "legacy" bank API).
+ */
+static struct TALER_WIRE_HistoryHandle *hhr;
+
+/**
* Handle for the timeout task.
*/
static struct GNUNET_SCHEDULER_Task *tt;
@@ -122,6 +127,14 @@ do_shutdown (void *cls)
hh);
hh = NULL;
}
+
+ if (NULL != hhr)
+ {
+ plugin->get_history_cancel (plugin->cls,
+ hhr);
+ hhr = NULL;
+ }
+
if (NULL != tt)
{
GNUNET_SCHEDULER_cancel (tt);
@@ -256,10 +269,21 @@ confirmation_cb (void *cls,
hh = plugin->get_history (plugin->cls,
my_account,
TALER_BANK_DIRECTION_BOTH,
- NULL, 0,
+ NULL,
+ 0,
5,
&history_result_cb,
NULL);
+
+ 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,
+ NULL)));
}
@@ -328,6 +352,7 @@ int
main (int argc,
const char *const argv[])
{
+
GNUNET_log_setup ("test-wire-plugin-transactions-test",
"WARNING",
NULL);