summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-12-18 12:29:35 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2018-12-18 12:29:35 +0100
commit50b156ac060dcb24088e69f03429b5a38d0520e0 (patch)
tree371838f62f39552e2dfaa9d3fdae2e2d06fd7be6 /src
parent808cdfd7971a5e00a3fbd685fcd860e709b3fa5c (diff)
downloadmerchant-50b156ac060dcb24088e69f03429b5a38d0520e0.tar.gz
merchant-50b156ac060dcb24088e69f03429b5a38d0520e0.tar.bz2
merchant-50b156ac060dcb24088e69f03429b5a38d0520e0.zip
Fix last commit.
Diffstat (limited to 'src')
-rw-r--r--src/lib/merchant_api_history.c90
-rw-r--r--src/lib/test_merchant_api_new.c6
-rw-r--r--src/lib/testing_api_cmd_history.c49
3 files changed, 95 insertions, 50 deletions
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index d98df671..bab8d82a 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -2,21 +2,25 @@
This file is part of TALER
Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
- Foundation; either version 2.1, or (at your option) any later version.
+ TALER is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1,
+ 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 Lesser General Public License for more details.
+ 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
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License along with
- TALER; see the file COPYING.LGPL. If not, see
- <http://www.gnu.org/licenses/>
+ You should have received a copy of the GNU Lesser General Public
+ License along with TALER; see the file COPYING.LGPL. If not,
+ see <http://www.gnu.org/licenses/>
*/
+
/**
* @file lib/merchant_api_contract.c
- * @brief Implementation of the /history request of the merchant's HTTP API
+ * @brief Implementation of the /history request of the merchant's
+ * HTTP API
* @author Marcello Stanisci
*/
#include "platform.h"
@@ -229,28 +233,35 @@ TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx,
* @param ctx execution context
* @param backend_url base URL of the merchant backend
* @param instance which merchant instance is performing this call
- * @param start return `delta` records starting from position `start`.
- * If given as zero, then no initial skip of `start` records is done.
- * @param delta return `delta` records starting from position `start`
- * @param date only transactions younger than/equals to date will be returned
- * @param history_cb callback which will work the response gotten from the backend
+ * @param start return `delta` records starting from position
+ * `start`. If given as zero, then no initial skip of
+ * `start` records is done.
+ * @param delta return `delta` records starting from position
+ * `start`
+ * @param date only transactions younger than/equals to date will
+ * be returned
+ * @param history_cb callback which will work the response gotten
+ * from the backend
* @param history_cb_cls closure to pass to @a history_cb
* @return handle for this operation, NULL upon errors
*/
struct TALER_MERCHANT_HistoryOperation *
-TALER_MERCHANT_history_default_start (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const char *instance,
- long long delta,
- struct GNUNET_TIME_Absolute date,
- TALER_MERCHANT_HistoryOperationCallback history_cb,
- void *history_cb_cls)
+TALER_MERCHANT_history_default_start
+ (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance,
+ long long delta,
+ struct GNUNET_TIME_Absolute date,
+ TALER_MERCHANT_HistoryOperationCallback history_cb,
+ void *history_cb_cls)
{
return TALER_MERCHANT_history2 (ctx,
backend_url,
instance,
- -1, /* fake 'start' argument: will NOT be used */
- GNUNET_YES, /* Specifies "no start argument" in final URL */
+ /* fake 'start' argument: will NOT be used */
+ -1,
+ /* Specifies "no start argument" in final URL */
+ GNUNET_YES,
delta,
date,
history_cb,
@@ -264,23 +275,28 @@ TALER_MERCHANT_history_default_start (struct GNUNET_CURL_Context *ctx,
* @param ctx execution context
* @param backend_url base URL of the merchant backend
* @param instance which merchant instance is performing this call
- * @param start return `delta` records starting from position `start`.
- * If given as zero, then no initial skip of `start` records is done.
- * @param delta return `delta` records starting from position `start`
- * @param date only transactions younger than/equals to date will be returned
- * @param history_cb callback which will work the response gotten from the backend
+ * @param start return `delta` records starting from position
+ * `start`. If given as zero, then no initial skip of
+ * `start` records is done.
+ * @param delta return `delta` records starting from position
+ * `start`
+ * @param date only transactions younger than/equals to date will
+ * be returned
+ * @param history_cb callback which will work the response gotten
+ * from the backend
* @param history_cb_cls closure to pass to @a history_cb
* @return handle for this operation, NULL upon errors
*/
struct TALER_MERCHANT_HistoryOperation *
-TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const char *instance,
- unsigned long long start,
- long long delta,
- struct GNUNET_TIME_Absolute date,
- TALER_MERCHANT_HistoryOperationCallback history_cb,
- void *history_cb_cls)
+TALER_MERCHANT_history
+ (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance,
+ unsigned long long start,
+ long long delta,
+ struct GNUNET_TIME_Absolute date,
+ TALER_MERCHANT_HistoryOperationCallback history_cb,
+ void *history_cb_cls)
{
return TALER_MERCHANT_history2 (ctx,
backend_url,
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index 19068341..41d600c6 100644
--- a/src/lib/test_merchant_api_new.c
+++ b/src/lib/test_merchant_api_new.c
@@ -1077,9 +1077,9 @@ run (void *cls,
merchant_url,
is->ctx,
MHD_HTTP_OK,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- 0,
- -100),
+ GNUNET_TIME_UNIT_ZERO_ABS,
+ 5, /* Expected number of records */
+ -100), /* Delta */
/**
* End the suite. Fixme: better to have a label for this
* too, as it shows a "(null)" token on logs.
diff --git a/src/lib/testing_api_cmd_history.c b/src/lib/testing_api_cmd_history.c
index 7b4874fb..ac4039eb 100644
--- a/src/lib/testing_api_cmd_history.c
+++ b/src/lib/testing_api_cmd_history.c
@@ -78,6 +78,13 @@ struct HistoryState
*/
unsigned long long start;
+
+ /**
+ * When this flag is GNUNET_YES, then the interpreter
+ * will request /history *omitting* the 'start' URL argument.
+ */
+ int use_default_start;
+
/**
* How many rows we want the response to contain, at most.
*/
@@ -260,16 +267,37 @@ history_run (void *cls,
GNUNET_TIME_UNIT_HOURS);
GNUNET_TIME_round_abs (&hs->time);
}
- if ( NULL ==
- ( hs->ho = TALER_MERCHANT_history (hs->ctx,
- hs->merchant_url,
- "default",
- hs->start,
- hs->nrows,
- hs->time,
- &history_cb,
- hs)))
- TALER_TESTING_FAIL (is);
+
+ switch (hs->use_default_start)
+ {
+ case GNUNET_YES:
+ hs->ho = TALER_MERCHANT_history_default_start
+ (hs->ctx,
+ hs->merchant_url,
+ "default",
+ hs->nrows,
+ hs->time,
+ &history_cb,
+ hs);
+ break;
+
+ case GNUNET_NO:
+ hs->ho = TALER_MERCHANT_history (hs->ctx,
+ hs->merchant_url,
+ "default",
+ hs->start,
+ hs->nrows,
+ hs->time,
+ &history_cb,
+ hs);
+ break;
+ default:
+ TALER_LOG_ERROR ("Bad value for 'use_default_start'\n");
+ TALER_TESTING_FAIL (is);
+ }
+
+ if (NULL == hs->ho)
+ TALER_TESTING_FAIL (is);
}
@@ -313,6 +341,7 @@ TALER_TESTING_cmd_history2 (const char *label,
hs->nrows = nrows;
hs->merchant_url = merchant_url;
hs->ctx = ctx;
+ hs->use_default_start = use_default_start;
cmd.cls = hs;
cmd.label = label;