summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_get_orders.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_get_orders.c')
-rw-r--r--src/testing/testing_api_cmd_get_orders.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/src/testing/testing_api_cmd_get_orders.c b/src/testing/testing_api_cmd_get_orders.c
index 7a271521..0eab0b7f 100644
--- a/src/testing/testing_api_cmd_get_orders.c
+++ b/src/testing/testing_api_cmd_get_orders.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -71,41 +71,39 @@ struct GetOrdersState
* Callback for a GET /orders operation.
*
* @param cls closure for this function
- * @param hr HTTP response
- * @param orders_length how many orders are returned
- * @param orders all the orders' details
+ * @param ogr response
*/
static void
get_orders_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int orders_length,
- const struct TALER_MERCHANT_OrderEntry orders[])
+ const struct TALER_MERCHANT_OrdersGetResponse *ogr)
{
struct GetOrdersState *gos = cls;
gos->ogh = NULL;
- if (gos->http_status != hr->http_status)
+ if (gos->http_status != ogr->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u (%d) to command %s\n",
- hr->http_status,
- (int) hr->ec,
+ ogr->hr.http_status,
+ (int) ogr->hr.ec,
TALER_TESTING_interpreter_get_current_label (gos->is));
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- switch (hr->http_status)
+ switch (ogr->hr.http_status)
{
case MHD_HTTP_OK:
- if (orders_length != gos->orders_length)
+ if (ogr->details.ok.orders_length != gos->orders_length)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Number of orders found does not match\n");
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- for (unsigned int i = 0; i < orders_length; ++i)
+ for (unsigned int i = 0; i < ogr->details.ok.orders_length; ++i)
{
+ const struct TALER_MERCHANT_OrderEntry *order =
+ &ogr->details.ok.orders[i];
const struct TALER_TESTING_Command *order_cmd;
order_cmd = TALER_TESTING_interpreter_lookup_command (
@@ -113,7 +111,7 @@ get_orders_cb (void *cls,
gos->orders[i]);
{
- const char **order_id;
+ const char *order_id;
if (GNUNET_OK !=
TALER_TESTING_get_trait_order_id (order_cmd,
@@ -124,8 +122,8 @@ get_orders_cb (void *cls,
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- if (0 != strcmp (orders[i].order_id,
- *order_id))
+ if (0 != strcmp (order->order_id,
+ order_id))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order id does not match\n");
@@ -165,11 +163,11 @@ get_orders_cb (void *cls,
return;
}
if ((0 != strcmp (summary,
- orders[i].summary)) ||
+ order->summary)) ||
(GNUNET_OK != TALER_amount_cmp_currency (&amount,
- &orders[i].amount)) ||
+ &order->amount)) ||
(0 != TALER_amount_cmp (&amount,
- &orders[i].amount)))
+ &order->amount)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order summary and/or amount does not match\n");
@@ -205,7 +203,8 @@ get_orders_run (void *cls,
struct GetOrdersState *gos = cls;
gos->is = is;
- gos->ogh = TALER_MERCHANT_orders_get (is->ctx,
+ gos->ogh = TALER_MERCHANT_orders_get (TALER_TESTING_interpreter_get_context (
+ is),
gos->merchant_url,
&get_orders_cb,
gos);
@@ -396,31 +395,27 @@ conclude_task (void *cls)
* Callback to process a GET /orders request
*
* @param cls closure
- * @param hr HTTP response details
- * @param orders_length how many orders are returned
- * @param orders the returned orders
+ * @param ogr response details
*/
static void
merchant_poll_orders_cb (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int orders_length,
- const struct TALER_MERCHANT_OrderEntry orders[])
+ const struct TALER_MERCHANT_OrdersGetResponse *ogr)
{
struct MerchantPollOrdersStartState *pos = cls;
pos->ogh = NULL;
- if (MHD_HTTP_OK != hr->http_status)
+ if (MHD_HTTP_OK != ogr->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u (%d) to command %s\n",
- hr->http_status,
- (int) hr->ec,
+ ogr->hr.http_status,
+ (int) ogr->hr.ec,
TALER_TESTING_interpreter_get_current_label (pos->is));
TALER_TESTING_interpreter_fail (pos->is);
return;
}
- switch (hr->http_status)
+ switch (ogr->hr.http_status)
{
case MHD_HTTP_OK:
// FIXME: use order references to check if the data returned matches that from the POST / PATCH
@@ -429,7 +424,7 @@ merchant_poll_orders_cb (
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Unhandled HTTP status.\n");
}
- pos->http_status = hr->http_status;
+ pos->http_status = ogr->hr.http_status;
if (NULL != pos->cs)
{
GNUNET_SCHEDULER_cancel (pos->cs->task);
@@ -459,7 +454,8 @@ merchant_poll_orders_start_run (void *cls,
GNUNET_TIME_relative_add (pos->timeout,
GNUNET_TIME_UNIT_SECONDS));
pos->is = is;
- pos->ogh = TALER_MERCHANT_orders_get2 (is->ctx,
+ pos->ogh = TALER_MERCHANT_orders_get2 (TALER_TESTING_interpreter_get_context (
+ is),
pos->merchant_url,
TALER_EXCHANGE_YNA_ALL,
TALER_EXCHANGE_YNA_ALL,