summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_get_tips.c
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-16 02:18:22 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-16 02:18:22 -0400
commitadd99bf305d986cf14805cc99767cf665a1ccacb (patch)
tree4b14c62cce38bf0f8997c49946aa039cf2fd94d4 /src/testing/testing_api_cmd_get_tips.c
parent46fdfc6cf7001a1e158690ca30468b68ab887a02 (diff)
downloadmerchant-add99bf305d986cf14805cc99767cf665a1ccacb.tar.gz
merchant-add99bf305d986cf14805cc99767cf665a1ccacb.tar.bz2
merchant-add99bf305d986cf14805cc99767cf665a1ccacb.zip
more fixes/tests for claim order and get tips
Diffstat (limited to 'src/testing/testing_api_cmd_get_tips.c')
-rw-r--r--src/testing/testing_api_cmd_get_tips.c83
1 files changed, 75 insertions, 8 deletions
diff --git a/src/testing/testing_api_cmd_get_tips.c b/src/testing/testing_api_cmd_get_tips.c
index ae7ffb02..0ce9218a 100644
--- a/src/testing/testing_api_cmd_get_tips.c
+++ b/src/testing/testing_api_cmd_get_tips.c
@@ -50,6 +50,16 @@ struct GetTipsState
const char *merchant_url;
/**
+ * Row to start querying the database from.
+ */
+ uint64_t offset;
+
+ /**
+ * How many rows to return (with direction).
+ */
+ int64_t limit;
+
+ /**
* Expected HTTP response code.
*/
unsigned int http_status;
@@ -60,7 +70,7 @@ struct GetTipsState
unsigned int tips_length;
/**
- *
+ * References to tips that we expect to be found.
*/
const char **tips;
@@ -80,7 +90,6 @@ get_tips_cb (void *cls,
unsigned int tips_length,
const struct TALER_MERCHANT_TipEntry tips[])
{
- /* FIXME, deeper checks should be implemented here. */
struct GetTipsState *gts = cls;
gts->tgh = NULL;
@@ -97,8 +106,6 @@ get_tips_cb (void *cls,
switch (hr->http_status)
{
case MHD_HTTP_OK:
- // FIXME: use gis->product_reference here to
- // check if the data returned matches that from the POST / PATCH
if (tips_length != gts->tips_length)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -184,10 +191,13 @@ get_tips_run (void *cls,
struct GetTipsState *gts = cls;
gts->is = is;
- gts->tgh = TALER_MERCHANT_tips_get (is->ctx,
- gts->merchant_url,
- &get_tips_cb,
- gts);
+ gts->tgh = TALER_MERCHANT_tips_get2 (is->ctx,
+ gts->merchant_url,
+ TALER_EXCHANGE_YNA_NO,
+ gts->limit,
+ gts->offset,
+ &get_tips_cb,
+ gts);
GNUNET_assert (NULL != gts->tgh);
}
@@ -238,6 +248,63 @@ TALER_TESTING_cmd_get_tips (const char *label,
gts = GNUNET_new (struct GetTipsState);
gts->merchant_url = merchant_url;
+ gts->offset = INT64_MAX;
+ gts->limit = -20;
+ gts->http_status = http_status;
+ {
+ const char *clabel;
+ va_list ap;
+
+ va_start (ap, http_status);
+ while (NULL != (clabel = va_arg (ap, const char *)))
+ {
+ GNUNET_array_append (gts->tips,
+ gts->tips_length,
+ clabel);
+ }
+ va_end (ap);
+ }
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = gts,
+ .label = label,
+ .run = &get_tips_run,
+ .cleanup = &get_tips_cleanup
+ };
+
+ return cmd;
+ }
+}
+
+
+/**
+ * Define a get tips CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * server the /tip-query request.
+ * @param http_status expected HTTP response code for the
+ * /tip-query request.
+ * @param offset row to start querying the database from.
+ * @param limit how many rows to return (with direction).
+ * @param ... NULL-terminated list of labels (const char *) of
+ * tip (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_get_tips2 (const char *label,
+ const char *merchant_url,
+ uint64_t offset,
+ int64_t limit,
+ unsigned int http_status,
+ ...)
+{
+ struct GetTipsState *gts;
+
+ gts = GNUNET_new (struct GetTipsState);
+ gts->merchant_url = merchant_url;
+ gts->offset = offset;
+ gts->limit = limit;
gts->http_status = http_status;
{
const char *clabel;