summaryrefslogtreecommitdiff
path: root/src/bank-lib/testing_api_cmd_history.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bank-lib/testing_api_cmd_history.c')
-rw-r--r--src/bank-lib/testing_api_cmd_history.c137
1 files changed, 72 insertions, 65 deletions
diff --git a/src/bank-lib/testing_api_cmd_history.c b/src/bank-lib/testing_api_cmd_history.c
index e69cd7c1a..ca8613141 100644
--- a/src/bank-lib/testing_api_cmd_history.c
+++ b/src/bank-lib/testing_api_cmd_history.c
@@ -64,9 +64,9 @@ struct HistoryState
/**
* How many rows we want in the result, _at most_. In
* the case of /history-range, we fake this value with
- * INT64_MAX.
+ * UINT64_MAX.
*/
- long long num_results;
+ unsigned long long num_results;
/**
* Handle to a pending "history" operation.
@@ -159,6 +159,10 @@ history_traits (void *cls,
const char *trait,
unsigned int index)
{
+ (void) cls;
+ (void) ret;
+ (void) trait;
+ (void) index;
/* Must define this function because some callbacks
* look for certain traits on _all_ the commands. */
return GNUNET_SYSERR;
@@ -184,7 +188,7 @@ test_cancelled (struct TALER_TESTING_Interpreter *is,
current_cmd = &is->commands[off];
TALER_LOG_INFO ("Is `%s' rejected?\n",
current_cmd->label);
- for (unsigned int i = 0; i<is->ip; i++)
+ for (int i = 0; i<is->ip; i++)
{
const struct TALER_TESTING_Command *c = &is->commands[i];
@@ -290,13 +294,10 @@ build_history_hit_limit (uint64_t total,
TALER_TESTING_get_trait_absolute_time (pos,
0,
&timestamp));
-
GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us !=
hs->end_date.abs_value_us);
-
return timestamp->abs_value_us >= hs->end_date.abs_value_us;
}
-
return total >= hs->num_results;
}
@@ -714,6 +715,7 @@ compute_result_count (struct TALER_TESTING_Interpreter *is)
return total;
}
+
/**
* Check that the "/history" response matches the
* CMD whose offset in the list of CMDs is @a off.
@@ -807,6 +809,7 @@ history_cb (void *cls,
struct TALER_TESTING_Interpreter *is = cls;
struct HistoryState *hs = is->commands[is->ip].cls;
+ (void) row_id;
/*NOTE: "204 No Content" is used to signal the end of results.*/
if (MHD_HTTP_NO_CONTENT == http_status)
{
@@ -819,16 +822,19 @@ history_cb (void *cls,
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, failed: %d\n",
- (unsigned long long) total,
- (unsigned long long) hs->results_obtained,
- http_status,
- hs->failed);
- print_expected (h, total, UINT_MAX);
- free_history (h, total);
+ 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;
}
@@ -839,10 +845,9 @@ history_cb (void *cls,
if (MHD_HTTP_OK != http_status)
{
hs->hh = NULL;
- GNUNET_log
- (GNUNET_ERROR_TYPE_ERROR,
- "Unwanted response code from /history[-range]: %u\n",
- http_status);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unwanted response code from /history[-range]: %u\n",
+ http_status);
TALER_TESTING_interpreter_fail (is);
return;
}
@@ -892,6 +897,7 @@ history_run (void *cls,
const uint64_t *row_id_ptr = &row_id;
struct TALER_BANK_AuthenticationData *auth;
+ (void) cmd;
/* Get row_id from trait. */
if (NULL != hs->start_row_reference)
{
@@ -940,15 +946,14 @@ history_range_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is)
{
-
struct HistoryState *hs = cls;
const struct GNUNET_TIME_Absolute *start_date;
const struct GNUNET_TIME_Absolute *end_date;
struct TALER_BANK_AuthenticationData *auth;
+ (void) cmd;
if (NULL != hs->start_row_reference)
{
-
const struct TALER_TESTING_Command *history_cmd;
history_cmd = TALER_TESTING_interpreter_lookup_command
@@ -972,7 +977,6 @@ history_range_run (void *cls,
if (NULL != hs->end_row_reference)
{
-
const struct TALER_TESTING_Command *history_cmd;
history_cmd = TALER_TESTING_interpreter_lookup_command
@@ -1017,18 +1021,17 @@ history_range_run (void *cls,
* @param cmd the command which is being cleaned up.
*/
static void
-history_cleanup
- (void *cls,
- const struct TALER_TESTING_Command *cmd)
+history_cleanup (void *cls,
+ const struct TALER_TESTING_Command *cmd)
{
struct HistoryState *hs = cls;
+ (void) cmd;
if (NULL != hs->hh)
{
TALER_LOG_WARNING ("/history did not complete\n");
TALER_BANK_history_cancel (hs->hh);
}
-
GNUNET_free (hs);
}
@@ -1041,24 +1044,22 @@ history_cleanup
* operation.
* @param account_no bank account number to ask the history for.
* @param direction which direction this operation is interested.
- * @param ascending if GNUNET_YES, the bank will return the rows
+ * @param ascending if #GNUNET_YES, the bank will return the rows
* in ascending (= chronological) order.
* @param start_row_reference reference to a command that can
* offer a row identifier, to be used as the starting row
* to accept in the result.
- * @param num_result how many rows we want in the result.
- *
+ * @param num_results how many rows we want in the result.
* @return the command.
*/
struct TALER_TESTING_Command
-TALER_TESTING_cmd_bank_history
- (const char *label,
- const char *bank_url,
- uint64_t account_no,
- enum TALER_BANK_Direction direction,
- unsigned int ascending,
- const char *start_row_reference,
- long long num_results)
+TALER_TESTING_cmd_bank_history (const char *label,
+ const char *bank_url,
+ uint64_t account_no,
+ enum TALER_BANK_Direction direction,
+ unsigned int ascending,
+ const char *start_row_reference,
+ unsigned long long num_results)
{
struct HistoryState *hs;
@@ -1072,15 +1073,17 @@ TALER_TESTING_cmd_bank_history
hs->start_date = GNUNET_TIME_UNIT_FOREVER_ABS;
hs->end_date = GNUNET_TIME_UNIT_FOREVER_ABS;
- struct TALER_TESTING_Command cmd = {
- .label = label,
- .cls = hs,
- .run = &history_run,
- .cleanup = &history_cleanup,
- .traits = &history_traits
- };
-
- return cmd;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .label = label,
+ .cls = hs,
+ .run = &history_run,
+ .cleanup = &history_cleanup,
+ .traits = &history_traits
+ };
+
+ return cmd;
+ }
}
@@ -1124,15 +1127,17 @@ TALER_TESTING_cmd_bank_history_range
hs->start_date = GNUNET_TIME_UNIT_FOREVER_ABS;
hs->end_date = GNUNET_TIME_UNIT_FOREVER_ABS;
- struct TALER_TESTING_Command cmd = {
- .label = label,
- .cls = hs,
- .run = &history_range_run,
- .cleanup = &history_cleanup,
- .traits = &history_traits
- };
-
- return cmd;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .label = label,
+ .cls = hs,
+ .run = &history_range_run,
+ .cleanup = &history_cleanup,
+ .traits = &history_traits
+ };
+
+ return cmd;
+ }
}
@@ -1173,15 +1178,17 @@ TALER_TESTING_cmd_bank_history_range_with_dates
hs->start_date = start_date;
hs->end_date = end_date;
- struct TALER_TESTING_Command cmd = {
- .label = label,
- .cls = hs,
- .run = &history_range_run,
- .cleanup = &history_cleanup,
- .traits = &history_traits
- };
-
- return cmd;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .label = label,
+ .cls = hs,
+ .run = &history_range_run,
+ .cleanup = &history_cleanup,
+ .traits = &history_traits
+ };
+
+ return cmd;
+ }
}
/* end of testing_api_cmd_history.c */