simplify bank history commands
This commit is contained in:
parent
7236294ffb
commit
16a6d39dc9
@ -63,7 +63,10 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_WireTransferIdentifierRawP wtid;
|
||||
|
||||
memset (&wtid, 42, sizeof (wtid));
|
||||
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_bank_credits ("history-0",
|
||||
bc.exchange_account_url,
|
||||
@ -115,6 +118,7 @@ run (void *cls,
|
||||
else
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,6 +31,30 @@
|
||||
#include "taler_fakebank_lib.h"
|
||||
|
||||
|
||||
/**
|
||||
* Item in the transaction history, as reconstructed from the
|
||||
* command history.
|
||||
*/
|
||||
struct History
|
||||
{
|
||||
|
||||
/**
|
||||
* Wire details.
|
||||
*/
|
||||
struct TALER_BANK_CreditDetails details;
|
||||
|
||||
/**
|
||||
* Serial ID of the wire transfer.
|
||||
*/
|
||||
uint64_t row_id;
|
||||
|
||||
/**
|
||||
* URL to free.
|
||||
*/
|
||||
char *url;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* State for a "history" CMD.
|
||||
*/
|
||||
@ -74,30 +98,16 @@ struct HistoryState
|
||||
*/
|
||||
int failed;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Item in the transaction history, as reconstructed from the
|
||||
* command history.
|
||||
/**
|
||||
* Expected history.
|
||||
*/
|
||||
struct History
|
||||
{
|
||||
struct History *h;
|
||||
|
||||
/**
|
||||
* Wire details.
|
||||
* Length of @e h
|
||||
*/
|
||||
struct TALER_BANK_CreditDetails details;
|
||||
unsigned int total;
|
||||
|
||||
/**
|
||||
* Serial ID of the wire transfer.
|
||||
*/
|
||||
uint64_t row_id;
|
||||
|
||||
/**
|
||||
* URL to free.
|
||||
*/
|
||||
char *url;
|
||||
};
|
||||
|
||||
|
||||
@ -127,22 +137,6 @@ history_traits (void *cls,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Free history @a h of length @a h_len.
|
||||
*
|
||||
* @param h history array to free.
|
||||
* @param h_len number of entries in @a h.
|
||||
*/
|
||||
static void
|
||||
free_history (struct History *h,
|
||||
uint64_t h_len)
|
||||
{
|
||||
for (uint64_t off = 0; off<h_len; off++)
|
||||
GNUNET_free (h[off].url);
|
||||
GNUNET_free_non_null (h);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log which history we expected. Called when an error occurs.
|
||||
*
|
||||
@ -152,7 +146,7 @@ free_history (struct History *h,
|
||||
*/
|
||||
static void
|
||||
print_expected (struct History *h,
|
||||
uint64_t h_len,
|
||||
unsigned int h_len,
|
||||
unsigned int off)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
@ -161,12 +155,12 @@ print_expected (struct History *h,
|
||||
(unsigned long long) h_len);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Expected history:\n");
|
||||
for (uint64_t i = 0; i<h_len; i++)
|
||||
for (unsigned int i = 0; i<h_len; i++)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"H(%llu): %s (serial: %llu, subject: %s,"
|
||||
"H(%u): %s (serial: %llu, subject: %s,"
|
||||
" counterpart: %s)\n",
|
||||
(unsigned long long) i,
|
||||
i,
|
||||
TALER_amount2s (&h[i].details.amount),
|
||||
(unsigned long long) h[i].row_id,
|
||||
TALER_B2S (&h[i].details.reserve_pub),
|
||||
@ -175,26 +169,6 @@ print_expected (struct History *h,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tell if the current item is beyond the allowed limit.
|
||||
*
|
||||
* @param total current number of items in the built history list.
|
||||
* Note, this is the list we build locally and compare with
|
||||
* what the server returned.
|
||||
* @param hs the history CMD state.
|
||||
* @param pos current item to be evaluated or not (if the list
|
||||
* has already enough elements).
|
||||
* @return GNUNET_OK / GNUNET_NO.
|
||||
*/
|
||||
static int
|
||||
build_history_hit_limit (uint64_t total,
|
||||
const struct HistoryState *hs,
|
||||
const struct TALER_TESTING_Command *pos)
|
||||
{
|
||||
return total >= hs->num_results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function constructs the list of history elements that
|
||||
* interest the account number of the caller. It has two main
|
||||
@ -205,50 +179,49 @@ build_history_hit_limit (uint64_t total,
|
||||
* @param is interpreter state (supposedly having the
|
||||
* current CMD pointing at a "history" CMD).
|
||||
* @param[out] rh history array to initialize.
|
||||
*
|
||||
* @return number of entries in @a rh.
|
||||
*/
|
||||
static uint64_t
|
||||
static unsigned int
|
||||
build_history (struct TALER_TESTING_Interpreter *is,
|
||||
struct History **rh)
|
||||
{
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
uint64_t total;
|
||||
unsigned int total;
|
||||
struct History *h;
|
||||
const struct TALER_TESTING_Command *add_incoming_cmd;
|
||||
int inc;
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
|
||||
/**
|
||||
* @var turns GNUNET_YES whenever either no 'start' value was
|
||||
/* @var turns GNUNET_YES whenever either no 'start' value was
|
||||
* given for the history query, or the given value is found
|
||||
* in the list of all the CMDs.
|
||||
*/int ok;
|
||||
* in the list of all the CMDs. *///
|
||||
int ok;
|
||||
const uint64_t *row_id_start = NULL;
|
||||
|
||||
if (NULL != hs->start_row_reference)
|
||||
{
|
||||
TALER_LOG_INFO
|
||||
("`%s': start row given via reference `%s'\n",
|
||||
TALER_LOG_INFO ("`%s': start row given via reference `%s'\n",
|
||||
TALER_TESTING_interpreter_get_current_label (is),
|
||||
hs->start_row_reference);
|
||||
add_incoming_cmd = TALER_TESTING_interpreter_lookup_command
|
||||
(is, hs->start_row_reference);
|
||||
add_incoming_cmd
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
hs->start_row_reference);
|
||||
GNUNET_assert (NULL != add_incoming_cmd);
|
||||
GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_uint64
|
||||
(add_incoming_cmd, 0, &row_id_start));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_uint64 (add_incoming_cmd,
|
||||
0,
|
||||
&row_id_start));
|
||||
}
|
||||
|
||||
GNUNET_assert (0 != hs->num_results);
|
||||
if (0 == is->ip)
|
||||
{
|
||||
TALER_LOG_DEBUG ("Checking history at first CMD..\n");
|
||||
TALER_LOG_DEBUG ("Checking history at first CMD (empty history)\n");
|
||||
*rh = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* AKA 'delta'. */
|
||||
if (hs->num_results > 0)
|
||||
{
|
||||
inc = 1; /* _inc_rement */
|
||||
@ -304,9 +277,8 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
continue; /* skip until we find the marker */
|
||||
|
||||
TALER_LOG_DEBUG ("Found first row\n");
|
||||
if (build_history_hit_limit (total,
|
||||
hs,
|
||||
pos))
|
||||
if (total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results) )
|
||||
{
|
||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||
break;
|
||||
@ -343,8 +315,7 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
}
|
||||
|
||||
|
||||
GNUNET_assert (total < UINT_MAX);
|
||||
h = GNUNET_new_array ((unsigned int) total,
|
||||
h = GNUNET_new_array (total,
|
||||
struct History);
|
||||
total = 0;
|
||||
ok = GNUNET_NO;
|
||||
@ -391,9 +362,8 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
continue; /* skip until we find the marker */
|
||||
}
|
||||
|
||||
if (build_history_hit_limit (total,
|
||||
hs,
|
||||
pos))
|
||||
if (total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results) )
|
||||
{
|
||||
TALER_LOG_INFO ("Hit history limit (2)\n");
|
||||
break;
|
||||
@ -453,52 +423,32 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compute how many results we expect to be returned for
|
||||
* the current command at @a is.
|
||||
*
|
||||
* @param is the interpreter state to inspect.
|
||||
* @return number of results expected.
|
||||
*/
|
||||
static uint64_t
|
||||
compute_result_count (struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
uint64_t total;
|
||||
struct History *h;
|
||||
|
||||
total = build_history (is, &h);
|
||||
free_history (h, total);
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check that the "/history" response matches the
|
||||
* CMD whose offset in the list of CMDs is @a off.
|
||||
*
|
||||
* @param is the interpreter state.
|
||||
* @param h expected history (array)
|
||||
* @param total length of @a h
|
||||
* @param off the offset (of the CMD list) where the command
|
||||
* to check is.
|
||||
* @param dir the expected direction of the transaction.
|
||||
* @param details the expected transaction details.
|
||||
*
|
||||
* @return #GNUNET_OK if the transaction is what we expect.
|
||||
*/
|
||||
static int
|
||||
check_result (struct TALER_TESTING_Interpreter *is,
|
||||
struct History *h,
|
||||
unsigned int total,
|
||||
unsigned int off,
|
||||
const struct TALER_BANK_CreditDetails *details)
|
||||
{
|
||||
uint64_t total;
|
||||
struct History *h;
|
||||
|
||||
total = build_history (is, &h);
|
||||
if (off >= total)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Test says history has at most %u"
|
||||
" results, but got result #%u to check\n",
|
||||
(unsigned int) total,
|
||||
total,
|
||||
off);
|
||||
print_expected (h,
|
||||
total,
|
||||
@ -516,12 +466,8 @@ check_result (struct TALER_TESTING_Interpreter *is,
|
||||
print_expected (h,
|
||||
total,
|
||||
off);
|
||||
free_history (h,
|
||||
total);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
free_history (h,
|
||||
total);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
@ -561,38 +507,6 @@ history_cb (void *cls,
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
|
||||
(void) row_id;
|
||||
if (NULL == details)
|
||||
{
|
||||
hs->hh = NULL;
|
||||
if ( (hs->results_obtained != compute_result_count (is)) ||
|
||||
(GNUNET_YES == hs->failed) ||
|
||||
(MHD_HTTP_NO_CONTENT != http_status) )
|
||||
{
|
||||
uint64_t total;
|
||||
struct History *h;
|
||||
|
||||
GNUNET_break (0);
|
||||
total = build_history (is, &h);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Expected history of length %llu, got %llu;"
|
||||
" HTTP status code: %u/%d, failed: %d\n",
|
||||
(unsigned long long) total,
|
||||
(unsigned long long) hs->results_obtained,
|
||||
http_status,
|
||||
(int) ec,
|
||||
hs->failed);
|
||||
print_expected (h,
|
||||
total,
|
||||
UINT_MAX);
|
||||
free_history (h,
|
||||
total);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
if (MHD_HTTP_OK != http_status)
|
||||
{
|
||||
hs->hh = NULL;
|
||||
@ -602,8 +516,36 @@ history_cb (void *cls,
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
if (NULL == details)
|
||||
{
|
||||
hs->hh = NULL;
|
||||
if ( (hs->results_obtained != hs->total) ||
|
||||
(GNUNET_YES == hs->failed) ||
|
||||
(MHD_HTTP_NO_CONTENT != http_status) )
|
||||
{
|
||||
GNUNET_break (0);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Expected history of length %u, got %llu;"
|
||||
" HTTP status code: %u/%d, failed: %d\n",
|
||||
hs->total,
|
||||
(unsigned long long) hs->results_obtained,
|
||||
http_status,
|
||||
(int) ec,
|
||||
hs->failed);
|
||||
print_expected (hs->h,
|
||||
hs->total,
|
||||
UINT_MAX);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
/* check current element */
|
||||
if (GNUNET_OK != check_result (is,
|
||||
hs->h,
|
||||
hs->total,
|
||||
hs->results_obtained,
|
||||
details))
|
||||
{
|
||||
@ -664,7 +606,8 @@ history_run (void *cls,
|
||||
TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
|
||||
(unsigned long long) row_id);
|
||||
}
|
||||
|
||||
hs->total = build_history (is,
|
||||
&hs->h);
|
||||
hs->hh = TALER_BANK_credit_history (is->ctx,
|
||||
hs->account_url,
|
||||
&hs->auth,
|
||||
@ -696,6 +639,9 @@ history_cleanup (void *cls,
|
||||
TALER_BANK_credit_history_cancel (hs->hh);
|
||||
}
|
||||
GNUNET_free (hs->account_url);
|
||||
for (unsigned int off = 0; off<hs->total; off++)
|
||||
GNUNET_free (hs->h[off].url);
|
||||
GNUNET_free_non_null (hs->h);
|
||||
GNUNET_free (hs);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
<http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file bank-lib/testing_api_cmd_history.c
|
||||
* @file lib/testing_api_cmd_bank_history_debit.c
|
||||
* @brief command to check the /history API from the bank.
|
||||
* @author Marcello Stanisci
|
||||
*/
|
||||
@ -30,6 +30,29 @@
|
||||
#include "taler_bank_service.h"
|
||||
#include "taler_fakebank_lib.h"
|
||||
|
||||
/**
|
||||
* Item in the transaction history, as reconstructed from the
|
||||
* command history.
|
||||
*/
|
||||
struct History
|
||||
{
|
||||
|
||||
/**
|
||||
* Wire details.
|
||||
*/
|
||||
struct TALER_BANK_DebitDetails details;
|
||||
|
||||
/**
|
||||
* Serial ID of the wire transfer.
|
||||
*/
|
||||
uint64_t row_id;
|
||||
|
||||
/**
|
||||
* URL to free.
|
||||
*/
|
||||
char *url;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* State for a "history" CMD.
|
||||
@ -74,30 +97,16 @@ struct HistoryState
|
||||
*/
|
||||
int failed;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Item in the transaction history, as reconstructed from the
|
||||
* command history.
|
||||
/**
|
||||
* Expected history.
|
||||
*/
|
||||
struct History
|
||||
{
|
||||
struct History *h;
|
||||
|
||||
/**
|
||||
* Wire details.
|
||||
* Length of @e h
|
||||
*/
|
||||
struct TALER_BANK_DebitDetails details;
|
||||
unsigned int total;
|
||||
|
||||
/**
|
||||
* Serial ID of the wire transfer.
|
||||
*/
|
||||
uint64_t row_id;
|
||||
|
||||
/**
|
||||
* URL to free.
|
||||
*/
|
||||
char *url;
|
||||
};
|
||||
|
||||
|
||||
@ -127,22 +136,6 @@ history_traits (void *cls,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Free history @a h of length @a h_len.
|
||||
*
|
||||
* @param h history array to free.
|
||||
* @param h_len number of entries in @a h.
|
||||
*/
|
||||
static void
|
||||
free_history (struct History *h,
|
||||
uint64_t h_len)
|
||||
{
|
||||
for (uint64_t off = 0; off<h_len; off++)
|
||||
GNUNET_free (h[off].url);
|
||||
GNUNET_free_non_null (h);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log which history we expected. Called when an error occurs.
|
||||
*
|
||||
@ -152,7 +145,7 @@ free_history (struct History *h,
|
||||
*/
|
||||
static void
|
||||
print_expected (struct History *h,
|
||||
uint64_t h_len,
|
||||
unsigned int h_len,
|
||||
unsigned int off)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
@ -161,12 +154,11 @@ print_expected (struct History *h,
|
||||
(unsigned long long) h_len);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Expected history:\n");
|
||||
for (uint64_t i = 0; i<h_len; i++)
|
||||
for (unsigned int i = 0; i<h_len; i++)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"H(%llu): %s (serial: %llu, subject: %s,"
|
||||
" counterpart: %s)\n",
|
||||
(unsigned long long) i,
|
||||
"H(%u): %s (serial: %llu, subject: %s, counterpart: %s)\n",
|
||||
i,
|
||||
TALER_amount2s (&h[i].details.amount),
|
||||
(unsigned long long) h[i].row_id,
|
||||
TALER_B2S (&h[i].details.wtid),
|
||||
@ -175,26 +167,6 @@ print_expected (struct History *h,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tell if the current item is beyond the allowed limit.
|
||||
*
|
||||
* @param total current number of items in the built history list.
|
||||
* Note, this is the list we build locally and compare with
|
||||
* what the server returned.
|
||||
* @param hs the history CMD state.
|
||||
* @param pos current item to be evaluated or not (if the list
|
||||
* has already enough elements).
|
||||
* @return GNUNET_OK / GNUNET_NO.
|
||||
*/
|
||||
static int
|
||||
build_history_hit_limit (uint64_t total,
|
||||
const struct HistoryState *hs,
|
||||
const struct TALER_TESTING_Command *pos)
|
||||
{
|
||||
return total >= hs->num_results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function constructs the list of history elements that
|
||||
* interest the account number of the caller. It has two main
|
||||
@ -205,15 +177,14 @@ build_history_hit_limit (uint64_t total,
|
||||
* @param is interpreter state (supposedly having the
|
||||
* current CMD pointing at a "history" CMD).
|
||||
* @param[out] rh history array to initialize.
|
||||
*
|
||||
* @return number of entries in @a rh.
|
||||
*/
|
||||
static uint64_t
|
||||
static unsigned int
|
||||
build_history (struct TALER_TESTING_Interpreter *is,
|
||||
struct History **rh)
|
||||
{
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
uint64_t total;
|
||||
unsigned int total;
|
||||
struct History *h;
|
||||
const struct TALER_TESTING_Command *add_incoming_cmd;
|
||||
int inc;
|
||||
@ -303,9 +274,8 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
|
||||
TALER_LOG_DEBUG ("Found first row\n");
|
||||
|
||||
if (build_history_hit_limit (total,
|
||||
hs,
|
||||
pos))
|
||||
if (total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results) )
|
||||
{
|
||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||
break;
|
||||
@ -342,8 +312,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
GNUNET_assert (total < UINT_MAX);
|
||||
h = GNUNET_new_array ((unsigned int) total,
|
||||
struct History);
|
||||
total = 0;
|
||||
@ -390,9 +358,8 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
continue; /* skip until we find the marker */
|
||||
}
|
||||
|
||||
if (build_history_hit_limit (total,
|
||||
hs,
|
||||
pos))
|
||||
if (total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results))
|
||||
{
|
||||
TALER_LOG_INFO ("Hit history limit (2)\n");
|
||||
break;
|
||||
@ -461,46 +428,25 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compute how many results we expect to be returned for
|
||||
* the current command at @a is.
|
||||
*
|
||||
* @param is the interpreter state to inspect.
|
||||
* @return number of results expected.
|
||||
*/
|
||||
static uint64_t
|
||||
compute_result_count (struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
uint64_t total;
|
||||
struct History *h;
|
||||
|
||||
total = build_history (is, &h);
|
||||
free_history (h, total);
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check that the "/history" response matches the
|
||||
* CMD whose offset in the list of CMDs is @a off.
|
||||
*
|
||||
* @param is the interpreter state.
|
||||
* @param h expected history
|
||||
* @param total number of entries in @a h
|
||||
* @param off the offset (of the CMD list) where the command
|
||||
* to check is.
|
||||
* @param dir the expected direction of the transaction.
|
||||
* @param details the expected transaction details.
|
||||
*
|
||||
* @return #GNUNET_OK if the transaction is what we expect.
|
||||
*/
|
||||
static int
|
||||
check_result (struct TALER_TESTING_Interpreter *is,
|
||||
struct History *h,
|
||||
uint64_t total,
|
||||
unsigned int off,
|
||||
const struct TALER_BANK_DebitDetails *details)
|
||||
{
|
||||
uint64_t total;
|
||||
struct History *h;
|
||||
|
||||
total = build_history (is, &h);
|
||||
if (off >= total)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
@ -524,12 +470,8 @@ check_result (struct TALER_TESTING_Interpreter *is,
|
||||
print_expected (h,
|
||||
total,
|
||||
off);
|
||||
free_history (h,
|
||||
total);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
free_history (h,
|
||||
total);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
@ -569,38 +511,6 @@ history_cb (void *cls,
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
|
||||
(void) row_id;
|
||||
if (NULL == details)
|
||||
{
|
||||
hs->hh = NULL;
|
||||
if ( (hs->results_obtained != compute_result_count (is)) ||
|
||||
(GNUNET_YES == hs->failed) ||
|
||||
(MHD_HTTP_NO_CONTENT != http_status) )
|
||||
{
|
||||
uint64_t total;
|
||||
struct History *h;
|
||||
|
||||
GNUNET_break (0);
|
||||
total = build_history (is, &h);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Expected history of length %llu, got %llu;"
|
||||
" HTTP status code: %u/%d, failed: %d\n",
|
||||
(unsigned long long) total,
|
||||
(unsigned long long) hs->results_obtained,
|
||||
http_status,
|
||||
(int) ec,
|
||||
hs->failed);
|
||||
print_expected (h,
|
||||
total,
|
||||
UINT_MAX);
|
||||
free_history (h,
|
||||
total);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
if (MHD_HTTP_OK != http_status)
|
||||
{
|
||||
hs->hh = NULL;
|
||||
@ -610,8 +520,36 @@ history_cb (void *cls,
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
if (NULL == details)
|
||||
{
|
||||
hs->hh = NULL;
|
||||
if ( (hs->results_obtained != hs->total) ||
|
||||
(GNUNET_YES == hs->failed) ||
|
||||
(MHD_HTTP_NO_CONTENT != http_status) )
|
||||
{
|
||||
GNUNET_break (0);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Expected history of length %u, got %llu;"
|
||||
" HTTP status code: %u/%d, failed: %d\n",
|
||||
hs->total,
|
||||
(unsigned long long) hs->results_obtained,
|
||||
http_status,
|
||||
(int) ec,
|
||||
hs->failed);
|
||||
print_expected (hs->h,
|
||||
hs->total,
|
||||
UINT_MAX);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
/* check current element */
|
||||
if (GNUNET_OK != check_result (is,
|
||||
hs->h,
|
||||
hs->total,
|
||||
hs->results_obtained,
|
||||
details))
|
||||
{
|
||||
@ -656,12 +594,12 @@ history_run (void *cls,
|
||||
{
|
||||
const struct TALER_TESTING_Command *history_cmd;
|
||||
|
||||
history_cmd = TALER_TESTING_interpreter_lookup_command
|
||||
(is, hs->start_row_reference);
|
||||
history_cmd
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
hs->start_row_reference);
|
||||
|
||||
if (NULL == history_cmd)
|
||||
TALER_TESTING_FAIL (is);
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_uint64 (history_cmd,
|
||||
0,
|
||||
@ -672,7 +610,7 @@ history_run (void *cls,
|
||||
TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
|
||||
(unsigned long long) row_id);
|
||||
}
|
||||
|
||||
hs->total = build_history (is, &hs->h);
|
||||
hs->hh = TALER_BANK_debit_history (is->ctx,
|
||||
hs->account_url,
|
||||
&hs->auth,
|
||||
@ -703,6 +641,9 @@ history_cleanup (void *cls,
|
||||
TALER_LOG_WARNING ("/history did not complete\n");
|
||||
TALER_BANK_debit_history_cancel (hs->hh);
|
||||
}
|
||||
for (unsigned int off = 0; off<hs->total; off++)
|
||||
GNUNET_free (hs->h[off].url);
|
||||
GNUNET_free_non_null (hs->h);
|
||||
GNUNET_free (hs);
|
||||
}
|
||||
|
||||
@ -749,4 +690,4 @@ TALER_TESTING_cmd_bank_debits (const char *label,
|
||||
}
|
||||
|
||||
|
||||
/* end of testing_api_cmd_history_debit.c */
|
||||
/* end of testing_api_cmd_bank_history_debit.c */
|
||||
|
Loading…
Reference in New Issue
Block a user