Calling bank legacy API in a test

This commit is contained in:
Marcello Stanisci 2019-09-04 15:01:31 +02:00
parent f4ffc4a27b
commit 1fc9595b2c
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
3 changed files with 61 additions and 36 deletions

View File

@ -369,7 +369,8 @@ conv_cancel (enum TALER_BANK_Direction direction)
* called. * called.
*/ */
struct TALER_BANK_HistoryHandle * struct TALER_BANK_HistoryHandle *
TALER_BANK_history_range (struct GNUNET_CURL_Context *ctx, TALER_BANK_history_range
(struct GNUNET_CURL_Context *ctx,
const char *bank_base_url, const char *bank_base_url,
const struct TALER_BANK_AuthenticationData *auth, const struct TALER_BANK_AuthenticationData *auth,
uint64_t account_number, uint64_t account_number,

View File

@ -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 cls the `struct TALER_WIRE_HistoryHandle`
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request * @param http_status HTTP response code, #MHD_HTTP_OK (200)
* 0 if the bank's reply is bogus (fails to follow the protocol), * for successful status request 0 if the bank's reply
* #MHD_HTTP_NO_CONTENT if there are no more results; on success the * is bogus (fails to follow the protocol),
* last callback is always of this status (even if `abs(num_results)` were * #MHD_HTTP_NO_CONTENT if there are no more results; on
* already returned). * success the last callback is always of this status
* (even if `abs(num_results)` were already returned).
* @param ec taler error code * @param ec taler error code
* @param dir direction of the transfer * @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 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 static void
bhist_cb (void *cls, bhist_cb (void *cls,
@ -849,12 +853,14 @@ bhist_cb (void *cls,
(unsigned char) ' '); (unsigned char) ' ');
if (NULL != space) if (NULL != space)
{ {
/* Space separates the actual wire transfer subject from the /* Space separates the actual wire transfer subject
exchange base URL (if present, expected only for outgoing from the exchange base URL (if present, expected
transactions). So we cut the string off at the space. */ only for outgoing transactions). So we cut the
string off at the space. */
*space = '\0'; *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 != if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (subject, GNUNET_STRINGS_string_to_data (subject,
strlen (subject), strlen (subject),
@ -1076,11 +1082,6 @@ taler_bank_get_history_range
TALER_WIRE_HistoryResultCallback hres_cb, TALER_WIRE_HistoryResultCallback hres_cb,
void *hres_cb_cls) void *hres_cb_cls)
{ {
/* FIXME: remove the following lines when addressing #5746*/
GNUNET_break (0);
return NULL;
struct TALER_Account account; struct TALER_Account account;
struct TalerBankClosure *tc = cls; struct TalerBankClosure *tc = cls;
struct TALER_WIRE_HistoryHandle *whh; struct TALER_WIRE_HistoryHandle *whh;
@ -1111,8 +1112,6 @@ taler_bank_get_history_range
GNUNET_free (whh); GNUNET_free (whh);
return NULL; return NULL;
} }
whh->hh = TALER_BANK_history_range (tc->ctx, whh->hh = TALER_BANK_history_range (tc->ctx,
account.details.x_taler_bank.bank_base_url, account.details.x_taler_bank.bank_base_url,
&whh->auth, &whh->auth,

View File

@ -78,6 +78,11 @@ static struct TALER_FAKEBANK_Handle *fb;
*/ */
static struct TALER_WIRE_HistoryHandle *hh; 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. * Handle for the timeout task.
*/ */
@ -122,6 +127,14 @@ do_shutdown (void *cls)
hh); hh);
hh = NULL; hh = NULL;
} }
if (NULL != hhr)
{
plugin->get_history_cancel (plugin->cls,
hhr);
hhr = NULL;
}
if (NULL != tt) if (NULL != tt)
{ {
GNUNET_SCHEDULER_cancel (tt); GNUNET_SCHEDULER_cancel (tt);
@ -256,10 +269,21 @@ confirmation_cb (void *cls,
hh = plugin->get_history (plugin->cls, hh = plugin->get_history (plugin->cls,
my_account, my_account,
TALER_BANK_DIRECTION_BOTH, TALER_BANK_DIRECTION_BOTH,
NULL, 0, NULL,
0,
5, 5,
&history_result_cb, &history_result_cb,
NULL); 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, main (int argc,
const char *const argv[]) const char *const argv[])
{ {
GNUNET_log_setup ("test-wire-plugin-transactions-test", GNUNET_log_setup ("test-wire-plugin-transactions-test",
"WARNING", "WARNING",
NULL); NULL);