commit abd41c1dfe392419f05a8412642add082d7c26bd
parent b7459d4b88fd0e091da097d8f727c6ab42e7d17c
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Sat, 28 May 2016 22:47:37 +0200
making "make check" under src/lib compile; test still not passed. Also showing a problem in getting /keys
Diffstat:
2 files changed, 65 insertions(+), 17 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_track.c b/src/backend/taler-merchant-httpd_track.c
@@ -23,6 +23,7 @@
#include <taler/taler_signatures.h>
#include <taler/taler_json_lib.h>
#include "taler-merchant-httpd.h"
+#include "taler-merchant-httpd_mhd.h"
#include "taler-merchant-httpd_parsing.h"
#include "taler-merchant-httpd_auditors.h"
#include "taler-merchant-httpd_exchanges.h"
@@ -51,8 +52,19 @@ MH_handler_track_deposit (struct TMH_RequestHandler *rh,
const char *upload_data,
size_t *upload_data_size)
{
+ static struct TMH_RequestHandler pong =
+ {
+ "", NULL, "text/html",
+ "/track/deposit served\n", 0,
+ &TMH_MHD_handler_static_response, MHD_HTTP_OK
+ };
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "serving /track/deposit\n");
- return MHD_YES;
+ return TMH_MHD_handler_static_response (&pong,
+ connection,
+ connection_cls,
+ upload_data,
+ upload_data_size);
}
/* end of taler-merchant-httpd_contract.c */
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
@@ -208,9 +208,14 @@ struct Command
const char *amount;
/**
- * Wire details (JSON).
+ * Sender's bank account details (JSON).
*/
- const char *wire;
+ const char *sender_details;
+
+ /**
+ * Transfer details (JSON)
+ */
+ const char *transfer_details;
/**
* Set (by the interpreter) to the reserve's private key
@@ -844,7 +849,16 @@ track_deposit_cb (void *cls,
unsigned int http_status,
const json_t *obj)
{
- return;
+ if (MHD_HTTP_OK == http_status)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ok from /track/deposit handler\n");
+ result = GNUNET_OK;
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not Ok from /track/deposit handler\n");
+ result = GNUNET_SYSERR;
+ }
}
@@ -918,7 +932,8 @@ interpreter_run (void *cls)
struct TALER_CoinSpendPublicKeyP coin_pub;
struct TALER_Amount amount;
struct GNUNET_TIME_Absolute execution_date;
- json_t *wire;
+ json_t *sender_details;
+ json_t *transfer_details;
is->task = NULL;
tc = GNUNET_SCHEDULER_get_task_context ();
@@ -972,28 +987,46 @@ interpreter_run (void *cls)
fail (is);
return;
}
- wire = json_loads (cmd->details.admin_add_incoming.wire,
- JSON_REJECT_DUPLICATES,
- NULL);
- if (NULL == wire)
+
+ execution_date = GNUNET_TIME_absolute_get ();
+ GNUNET_TIME_round_abs (&execution_date);
+ sender_details = json_loads (cmd->details.admin_add_incoming.sender_details,
+ JSON_REJECT_DUPLICATES,
+ NULL);
+ if (NULL == sender_details)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse wire details `%s' at %u\n",
- cmd->details.admin_add_incoming.wire,
+ "Failed to parse sender details `%s' at %u\n",
+ cmd->details.admin_add_incoming.sender_details,
is->ip);
fail (is);
return;
}
- execution_date = GNUNET_TIME_absolute_get ();
- GNUNET_TIME_round_abs (&execution_date);
+ transfer_details = json_loads (cmd->details.admin_add_incoming.transfer_details,
+ JSON_REJECT_DUPLICATES,
+ NULL);
+
+ if (NULL == transfer_details)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to parse transfer details `%s' at %u\n",
+ cmd->details.admin_add_incoming.transfer_details,
+ is->ip);
+ fail (is);
+ return;
+ }
+
cmd->details.admin_add_incoming.aih
= TALER_EXCHANGE_admin_add_incoming (exchange,
&reserve_pub,
&amount,
execution_date,
- wire,
+ sender_details,
+ transfer_details,
&add_incoming_cb,
is);
+ json_decref (sender_details);
+ json_decref (transfer_details);
if (NULL == cmd->details.admin_add_incoming.aih)
{
GNUNET_break (0);
@@ -1457,7 +1490,8 @@ run (void *cls)
{ .oc = OC_ADMIN_ADD_INCOMING,
.label = "create-reserve-1",
.expected_response_code = MHD_HTTP_OK,
- .details.admin_add_incoming.wire = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account_number\":62, \"uuid\":1 }",
+ .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account_number\":62, \"uuid\":1 }",
+ .details.admin_add_incoming.transfer_details = "{ \"uuid\": 1}",
.details.admin_add_incoming.amount = "EUR:5.01" },
/* Withdraw a 5 EUR coin, at fee of 1 ct */
{ .oc = OC_WITHDRAW_SIGN,
@@ -1504,14 +1538,16 @@ run (void *cls)
{ .oc = OC_ADMIN_ADD_INCOMING,
.label = "create-reserve-2",
.expected_response_code = MHD_HTTP_OK,
- .details.admin_add_incoming.wire = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account_number\":63, \"uuid\":2 }",
+ .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account_number\":63, \"uuid\":2 }",
+ .details.admin_add_incoming.transfer_details = "{ \"uuid\": 2}",
.details.admin_add_incoming.amount = "EUR:1" },
/* Add another 4.01 EUR to reserve #2 */
{ .oc = OC_ADMIN_ADD_INCOMING,
.label = "create-reserve-2b",
.expected_response_code = MHD_HTTP_OK,
.details.admin_add_incoming.reserve_reference = "create-reserve-2",
- .details.admin_add_incoming.wire = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account_number\":63, \"uuid\":3 }",
+ .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account_number\":63, \"uuid\":3 }",
+ .details.admin_add_incoming.transfer_details = "{ \"uuid\": 3}",
.details.admin_add_incoming.amount = "EUR:4.01" },
/* Withdraw a 5 EUR coin, at fee of 1 ct */