summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-08 11:44:43 +0200
committerChristian Grothoff <christian@grothoff.org>2016-06-08 11:44:43 +0200
commit6e09459865afc1b3b00405331f6370ad8ce91c41 (patch)
tree4e6ff84f22a35d25199be1e82694e2a52e96ff94
parent4032d7f64a80d7f5f01de646e8f39fc2a0a6e381 (diff)
downloadmerchant-6e09459865afc1b3b00405331f6370ad8ce91c41.tar.gz
merchant-6e09459865afc1b3b00405331f6370ad8ce91c41.tar.bz2
merchant-6e09459865afc1b3b00405331f6370ad8ce91c41.zip
start fakebank service in testcase (not yet actually used)
-rw-r--r--configure.ac27
-rw-r--r--src/lib/Makefile.am3
-rw-r--r--src/lib/test_merchant_api.c25
3 files changed, 53 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 618780ae..850bdf6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,6 +84,33 @@ AC_CHECK_HEADERS([gnunet/gnunet_pq_lib.h],
AM_CONDITIONAL(HAVE_GNUNETPQ, test x$libgnunetpq = x1)
+
+# Check for Taler's libtalerfakebank
+libtalerfakebank=0
+AC_MSG_CHECKING([for libtalerfakebank])
+AC_ARG_WITH(exchange,
+ [AS_HELP_STRING([--with-exchange=PFX], [base of Taler EXCHANGE installation])],
+ [AC_MSG_RESULT([given as $with_exchange])],
+ [AC_MSG_RESULT(not given)
+ with_exchange=yes])
+AS_CASE([$with_exchange],
+ [yes], [],
+ [no], [AC_MSG_ERROR([--with-exchange is required])],
+ [LDFLAGS="-L$with_exchange/lib $LDFLAGS"
+ CPPFLAGS="-I$with_exchange/include $CPPFLAGS $POSTGRESQL_CPPFLAGS"])
+
+CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS"
+LDFLAGS="$LDFLAGS -L/usr/local/lib"
+
+AC_CHECK_HEADERS([taler/taler_fakebank_lib.h],
+ [AC_CHECK_LIB([talerfakebank], [TALER_FAKEBANK_start], libtalerfakebank=1)],
+ [], [#ifdef HAVE_GNUNET_PLATFORM_H
+ #include <gnunet/platform.h>
+ #endif])
+AM_CONDITIONAL(HAVE_TALERFAKEBANK, test x$libtalerfakebank = x1)
+
+
+
# check for libmicrohttpd
microhttpd=0
AC_MSG_CHECKING([for microhttpd])
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 29a6f89d..5baf0296 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -36,8 +36,10 @@ libtalermerchant_la_LIBADD += -lgnurl
endif
endif
+if HAVE_TALERFAKEBANK
check_PROGRAMS = \
test_merchant_api
+endif
TESTS = \
$(check_PROGRAMS)
@@ -48,6 +50,7 @@ test_merchant_api_LDADD = \
$(top_srcdir)/src/backenddb/libtalermerchantdb.la \
libtalermerchant.la \
$(LIBGCRYPT_LIBS) \
+ -ltalerfakebank \
-ltalerexchange \
-ltalerjson \
-ltalerutil \
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 720480f3..1284a3b8 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -19,10 +19,11 @@
* @author Christian Grothoff
*/
#include "platform.h"
-#include <taler/taler_util.h>
-#include <taler/taler_signatures.h>
#include <taler/taler_exchange_service.h>
+#include <taler/taler_fakebank_lib.h>
#include <taler/taler_json_lib.h>
+#include <taler/taler_util.h>
+#include <taler/taler_signatures.h>
#include "taler_merchant_service.h"
#include "taler_merchantdb_lib.h"
#include <gnunet/gnunet_util_lib.h>
@@ -66,6 +67,12 @@ static struct GNUNET_SCHEDULER_Task *timeout_task;
static struct GNUNET_CURL_RescheduleContext *rc;
/**
+ * Handle to the fake bank service we run for the
+ * aggregator.
+ */
+static struct TALER_FAKEBANK_Handle *fakebank;
+
+/**
* Result of the testcases, #GNUNET_OK on success
*/
static int result;
@@ -1431,6 +1438,8 @@ do_shutdown (void *cls)
GNUNET_CURL_gnunet_rc_destroy (rc);
rc = NULL;
}
+ TALER_FAKEBANK_stop (fakebank);
+ fakebank = NULL;
}
@@ -1565,6 +1574,15 @@ run (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Interpreter initializing\n");
+ fakebank = TALER_FAKEBANK_start (8888);
+ if (NULL == fakebank)
+ {
+ fprintf (stderr,
+ "\nFailed to start fake bank service\n");
+ result = 77;
+ return;
+ }
+
is = GNUNET_new (struct InterpreterState);
is->commands = commands;
@@ -1745,6 +1763,7 @@ main (int argc,
}
while (0 != system ("wget -q -t 1 -T 1 " MERCHANT_URI " -o /dev/null -O /dev/null"));
fprintf (stderr, "\n");
+
result = GNUNET_SYSERR;
GNUNET_SCHEDULER_run (&run, NULL);
GNUNET_OS_process_kill (merchantd,
@@ -1755,6 +1774,8 @@ main (int argc,
SIGTERM);
GNUNET_OS_process_wait (exchanged);
GNUNET_OS_process_destroy (exchanged);
+ if (77 == result)
+ return 77;
return (GNUNET_OK == result) ? 0 : 1;
}