summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-03-20 16:09:18 +0100
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-03-20 16:09:18 +0100
commitb8f25a07e94cc9f421a547e8d6c9c8026d39f710 (patch)
tree0b0cb8bfe4e2a16b47750a5479fbf4b891aaf303 /src
parent2e761cdd0b811f4a283c424ccdf5de4dcabd9eb3 (diff)
downloadmerchant-b8f25a07e94cc9f421a547e8d6c9c8026d39f710.tar.gz
merchant-b8f25a07e94cc9f421a547e8d6c9c8026d39f710.tar.bz2
merchant-b8f25a07e94cc9f421a547e8d6c9c8026d39f710.zip
Fix lib testcase.
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_history.c43
-rw-r--r--src/lib/merchant_api_history.c5
-rw-r--r--src/lib/merchant_api_track_transfer.c4
-rw-r--r--src/lib/test_merchant_api.c11
4 files changed, 19 insertions, 44 deletions
diff --git a/src/backend/taler-merchant-httpd_history.c b/src/backend/taler-merchant-httpd_history.c
index 44e8216c..e7bd12dc 100644
--- a/src/backend/taler-merchant-httpd_history.c
+++ b/src/backend/taler-merchant-httpd_history.c
@@ -36,12 +36,6 @@ static int start = -1;
static unsigned int delta;
/**
- * Index to the current row being processed.
- */
-static unsigned int current = 0;
-
-
-/**
* Function called with information about a transaction.
*
* @param cls closure
@@ -60,33 +54,23 @@ pd_cb (void *cls,
json_t *amount;
json_t *timestamp;
json_t *instance;
+ uint64_t r64 = (uint64_t) row_id;
GNUNET_assert (-1 != json_unpack ((json_t *) proposal_data,
- "{s:o, s:o, s:{s:o}, s:I}",
+ "{s:o, s:o, s:{s:o}}",
"amount", &amount,
"timestamp", &timestamp,
- "merchant", "instance", &instance,
- "row_id", (json_int_t) row_id));
+ "merchant", "instance", &instance));
- if ( (current >= start) &&
- (current < start + delta) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding history element. Current: %u, start: %u, delta: %u\n",
- current,
- start,
- delta);
- GNUNET_break (NULL != (entry = json_pack ("{s:s, s:O, s:O, s:O}",
- "order_id", order_id,
- "amount", amount,
- "timestamp", timestamp,
- "instance", instance)));
-
- GNUNET_break (0 == json_array_append_new (response,
- entry));
- }
+ GNUNET_break (NULL != (entry = json_pack ("{s:I, s:s, s:O, s:O, s:O}",
+ "row_id", r64,
+ "order_id", order_id,
+ "amount", amount,
+ "timestamp", timestamp,
+ "instance", instance)));
- current++;
+ GNUNET_break (0 == json_array_append_new (response,
+ entry));
}
@@ -206,11 +190,6 @@ MH_handler_history (struct TMH_RequestHandler *rh,
delta,
pd_cb,
response);
-
-
-
-
- current = 0;
if (GNUNET_SYSERR == ret)
{
json_decref (response);
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index 69d09b8e..a2c2d5fa 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -137,7 +137,8 @@ history_raw_cb (void *cls,
* @param ctx execution context
* @param backend_uri base URL of the merchant backend
* @param instance which merchant instance is performing this call
- * @param start return `delta` records starting from position `start`
+ * @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
@@ -163,6 +164,7 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
ho->cb = history_cb;
ho->cb_cls = history_cb_cls;
seconds = date.abs_value_us / 1000LL / 1000LL;
+
GNUNET_asprintf (&ho->url,
"%s/history?date=%llu&instance=%s&start=%d&delta=%d",
backend_uri,
@@ -170,6 +172,7 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
instance,
start,
delta);
+
eh = curl_easy_init ();
if (CURLE_OK != curl_easy_setopt (eh,
CURLOPT_URL,
diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c
index 94dac1e3..c73e155d 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -124,10 +124,6 @@ check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh
GNUNET_JSON_spec_end()
};
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Extracting fields from: '%s'.\n",
- json_dumps (deposit, JSON_INDENT (1)));
-
if (GNUNET_OK !=
GNUNET_JSON_parse (deposit,
spec_detail,
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 3688cd7b..58075c09 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -1287,9 +1287,6 @@ track_transaction_cb (void *cls,
}
if (MHD_HTTP_OK != http_status)
fail (is);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "/track/order response: %s\n",
- json_dumps (json, JSON_INDENT (1)));
next_command (is);
}
@@ -1853,7 +1850,7 @@ interpreter_run (void *cls)
(cmd->details.history.ho = TALER_MERCHANT_history (ctx,
MERCHANT_URI,
instance,
- 0,
+ 20,
20,
cmd->details.history.date,
history_cb,
@@ -2344,14 +2341,14 @@ run (void *cls)
.label = "history-1",
.expected_response_code = MHD_HTTP_OK,
/*all records to be returned*/
- .details.history.date.abs_value_us = 0,
+ .details.history.date.abs_value_us = 43 * 1000LL * 1000LL,
.details.history.nresult = 2
},
{ .oc = OC_HISTORY,
.label = "history-2",
.expected_response_code = MHD_HTTP_OK,
- /*no records to be returned, as limit is in the future*/
- .details.history.date.abs_value_us = 43 * 1000LL * 1000LL,
+ /*no records returned, time limit too ancient*/
+ .details.history.date.abs_value_us = 0,
.details.history.nresult = 0
},