summaryrefslogtreecommitdiff
path: root/src/bank-lib/fakebank.c
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2019-04-10 17:03:24 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2019-04-10 17:07:14 +0200
commit5c496633092de5ebccd43e7040db2cc92b72c332 (patch)
tree3ee5337ad7a29bcaf50828cc30fd116ed41ef90b /src/bank-lib/fakebank.c
parentca718b9f1f76cd987d38572385d67b45114d4807 (diff)
downloadexchange-5c496633092de5ebccd43e7040db2cc92b72c332.tar.gz
exchange-5c496633092de5ebccd43e7040db2cc92b72c332.tar.bz2
exchange-5c496633092de5ebccd43e7040db2cc92b72c332.zip
Fixing twisted tests.
It has been observed that when a "twisted" test has "very little" commands in the stack, it uses to fail since the proxied service cannot be reached. This commit puts some delay before the first command gets run by the test interpreter; both in the form of a "blind" sleep, and with a more structured 'wget' loop.
Diffstat (limited to 'src/bank-lib/fakebank.c')
-rw-r--r--src/bank-lib/fakebank.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 9915516cd..1220fa057 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -587,6 +587,7 @@ handle_reject (struct TALER_FAKEBANK_Handle *h,
return ret;
}
+
/**
* Handle incoming HTTP request for /history
*
@@ -596,9 +597,40 @@ handle_reject (struct TALER_FAKEBANK_Handle *h,
* @return MHD result code
*/
static int
-handle_history_new (struct TALER_FAKEBANK_Handle *h,
- struct MHD_Connection *connection,
- void **con_cls)
+handle_home_page (struct TALER_FAKEBANK_Handle *h,
+ struct MHD_Connection *connection,
+ void **con_cls)
+{
+ int ret;
+ struct MHD_Response *resp;
+#define HELLOMSG "Hello, Fakebank!"
+
+ resp = MHD_create_response_from_buffer
+ (strlen (HELLOMSG),
+ HELLOMSG,
+ MHD_RESPMEM_MUST_COPY);
+
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_OK,
+ resp);
+
+ MHD_destroy_response (resp);
+ return ret;
+}
+
+
+/**
+ * Handle incoming HTTP request for /history
+ *
+ * @param h the fakebank handle
+ * @param connection the connection
+ * @param con_cls place to store state, not used
+ * @return MHD result code
+ */
+static int
+handle_history (struct TALER_FAKEBANK_Handle *h,
+ struct MHD_Connection *connection,
+ void **con_cls)
{
struct HistoryArgs ha;
struct HistoryRangeIds hri;
@@ -763,6 +795,18 @@ handle_mhd_request (void *cls,
{
struct TALER_FAKEBANK_Handle *h = cls;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Fakebank, serving: %s\n",
+ url);
+
+
+ if ( (0 == strcasecmp (url,
+ "/")) &&
+ (0 == strcasecmp (method,
+ MHD_HTTP_METHOD_GET)) )
+ return handle_home_page (h,
+ connection,
+ con_cls);
if ( (0 == strcasecmp (url,
"/admin/add/incoming")) &&
(0 == strcasecmp (method,
@@ -792,9 +836,9 @@ handle_mhd_request (void *cls,
"/history")) &&
(0 == strcasecmp (method,
MHD_HTTP_METHOD_GET)) )
- return handle_history_new (h,
- connection,
- con_cls);
+ return handle_history (h,
+ connection,
+ con_cls);
/* Unexpected URL path, just close the connection. */
/* we're rather impolite here, but it's a testcase. */