gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] branch master updated (9693905 -> 72e7044)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (9693905 -> 72e7044)
Date: Fri, 04 May 2018 16:19:44 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository merchant.

    from 9693905  conditions in test code.
     new 4fc18cc  Reverting last change.
     new 912b35e  new paygen draft
     new 119d6b4  Payments generator skeleton.
     new 0bc6d51  merchant gets launched but wget fails to detect it.
     new 323d84d  Explicit merchant URL.
     new 72e7044  passing the "paygen" control to CMDs.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |   1 +
 src/include/taler_merchant_testing_lib.h           |   3 +-
 src/lib/Makefile.am                                |   1 -
 src/lib/test_merchant_api_new.c                    |   7 +-
 src/lib/test_merchant_api_twisted.c                |   2 +-
 src/lib/testing_api_helpers.c                      |  46 ++---
 src/merchant-tools/Makefile.am                     |  12 +-
 .../taler-merchant-generate-payments_new.c         | 197 +++++++++++++++++++++
 8 files changed, 222 insertions(+), 47 deletions(-)
 create mode 100644 src/merchant-tools/taler-merchant-generate-payments_new.c

diff --git a/.gitignore b/.gitignore
index 661e10f..4b183db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,3 +59,4 @@ src/merchant-tools/taler-merchant-tip-enable
 src/lib/reserve_dkey.priv
 src/lib/reserve_key.priv
 doc/version.texi
+src/merchant-tools/taler-merchant-generate-payments-new
diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index 67ca40a..8394fc4 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -62,7 +62,8 @@ TALER_TESTING_prepare_merchant (const char *config_filename);
  *         be started.
  */
 struct GNUNET_OS_Process *
-TALER_TESTING_run_merchant (const char *config_filename);
+TALER_TESTING_run_merchant (const char *config_filename,
+                            const char *merchant_url);
 
 /* ******************* Generic interpreter logic ************ */
 
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index dbc0f07..39acd3a 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -127,7 +127,6 @@ test_merchant_api_new_LDADD = \
   -lgnunetcurl \
   -lgnunetutil \
   -ljansson
-test_merchant_api_new_CFLAGS = -DCUSTOM_CONFIG -DPURGE_DATABASE
 
 test_merchant_api_SOURCES = \
   test_merchant_api.c
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index 0559a63..9e5ebde 100644
--- a/src/lib/test_merchant_api_new.c
+++ b/src/lib/test_merchant_api_new.c
@@ -834,8 +834,9 @@ main (int argc,
                     NULL);
 
   if (NULL ==
-      (fakebank_url = TALER_TESTING_prepare_fakebank (CONFIG_FILE,
-                                                      "account-exchange")))
+      (fakebank_url = TALER_TESTING_prepare_fakebank
+        (CONFIG_FILE,
+         "account-exchange")))
     return 77;
   if (NULL ==
       (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
@@ -855,7 +856,7 @@ main (int argc,
   case GNUNET_OK:
 
     if (NULL == (merchantd =
-        TALER_TESTING_run_merchant (CONFIG_FILE)))
+        TALER_TESTING_run_merchant (CONFIG_FILE, merchant_url)))
       return 1;
 
     ret = TALER_TESTING_setup_with_exchange (&run,
diff --git a/src/lib/test_merchant_api_twisted.c 
b/src/lib/test_merchant_api_twisted.c
index e17a4d2..5ff2109 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -854,7 +854,7 @@ main (int argc,
   case GNUNET_OK:
 
     if (NULL == (merchantd = TALER_TESTING_run_merchant
-        (CONFIG_FILE)))
+        (CONFIG_FILE, merchant_url)))
       // 1 is fine; after all this is merchant test cases.
       return 1;
 
diff --git a/src/lib/testing_api_helpers.c b/src/lib/testing_api_helpers.c
index dbb65bb..9bccd4d 100644
--- a/src/lib/testing_api_helpers.c
+++ b/src/lib/testing_api_helpers.c
@@ -41,50 +41,28 @@
  *         be started.
  */
 struct GNUNET_OS_Process *
-TALER_TESTING_run_merchant (const char *config_filename)
+TALER_TESTING_run_merchant (const char *config_filename,
+                            const char *merchant_url)
 {
-  struct GNUNET_CONFIGURATION_Handle *cfg;
   struct GNUNET_OS_Process *merchant_proc;
   unsigned int iter;
-  unsigned long long port;
   char *wget_cmd;
 
-  cfg = GNUNET_CONFIGURATION_create ();
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_load (cfg,
-                                 config_filename))
-    MERCHANT_FAIL ();
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (cfg,
-                                             "merchant",
-                                             "PORT",
-                                             &port))
-  {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                               "merchant",
-                               "PORT");
-    GNUNET_CONFIGURATION_destroy (cfg);
-    MERCHANT_FAIL ();
-  }
-  GNUNET_CONFIGURATION_destroy (cfg);
-
   merchant_proc
     = GNUNET_OS_start_process (GNUNET_NO,
                                GNUNET_OS_INHERIT_STD_ALL,
                                NULL, NULL, NULL,
                                "taler-merchant-httpd",
                                "taler-merchant-httpd",
-                               #ifdef CUSTOM_CONFIG
                                "-c", config_filename,
-                               #endif
                                NULL);
   if (NULL == merchant_proc)
     MERCHANT_FAIL ();
 
   GNUNET_asprintf (&wget_cmd,
-                   "wget -q -t 1 -T 1 http://127.0.0.1:%llu/";
+                   "wget -q -t 1 -T 1 %s"
                    " -o /dev/null -O /dev/null",
-                   port);
+                   merchant_url);
 
   /* give child time to start and bind against the socket */
   fprintf (stderr,
@@ -95,7 +73,8 @@ TALER_TESTING_run_merchant (const char *config_filename)
       if (10 == iter)
       {
        fprintf (stderr,
-                 "Failed to launch `taler-merchant-httpd' (or `wget')\n");
+                 "Failed to launch"
+                 " `taler-merchant-httpd' (or `wget')\n");
        GNUNET_OS_process_kill (merchant_proc,
                                SIGTERM);
        GNUNET_OS_process_wait (merchant_proc);
@@ -128,6 +107,9 @@ TALER_TESTING_prepare_merchant (const char *config_filename)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg;
   unsigned long long port;
+  struct GNUNET_OS_Process *dbinit_proc;
+  enum GNUNET_OS_ProcessStatusType type;
+  unsigned long code;
   char *base_url;
 
   cfg = GNUNET_CONFIGURATION_create ();
@@ -160,11 +142,6 @@ TALER_TESTING_prepare_merchant (const char 
*config_filename)
     MERCHANT_FAIL ();
   }
 
-  #ifdef PURGE_DATABASE
-  struct GNUNET_OS_Process *dbinit_proc;
-  enum GNUNET_OS_ProcessStatusType type;
-  unsigned long code;
-
   /* DB preparation */
   if (NULL == (dbinit_proc = GNUNET_OS_start_process
     (GNUNET_NO,
@@ -172,9 +149,7 @@ TALER_TESTING_prepare_merchant (const char *config_filename)
      NULL, NULL, NULL,
      "taler-merchant-dbinit",
      "taler-merchant-dbinit",
-     #ifdef CUSTOM_CONFIG
      "-c", config_filename,
-     #endif
      "-r",
      NULL)))
   {
@@ -207,9 +182,8 @@ TALER_TESTING_prepare_merchant (const char *config_filename)
              " `taler-merchant-dbinit'!\n");
     MERCHANT_FAIL ();
   }
-
   GNUNET_OS_process_destroy (dbinit_proc);
-  #endif
+
 
 
   GNUNET_asprintf (&base_url,
diff --git a/src/merchant-tools/Makefile.am b/src/merchant-tools/Makefile.am
index 4e68837..0ad5520 100644
--- a/src/merchant-tools/Makefile.am
+++ b/src/merchant-tools/Makefile.am
@@ -3,7 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include
 
 bin_PROGRAMS = \
   taler-merchant-dbinit \
-  taler-merchant-generate-payments
+  taler-merchant-generate-payments-new
 
 taler_merchant_dbinit_SOURCES = \
   taler-merchant-dbinit.c
@@ -15,15 +15,17 @@ taler_merchant_dbinit_LDADD = \
   -ltalerutil \
   -ltalerpq
 
-taler_merchant_generate_payments_SOURCES = \
-  taler-merchant-generate-payments.c
+taler_merchant_generate_payments_new_SOURCES = \
+  taler-merchant-generate-payments_new.c
 
-taler_merchant_generate_payments_LDADD = \
+taler_merchant_generate_payments_new_LDADD = \
   $(top_srcdir)/src/backenddb/libtalermerchantdb.la \
   $(top_srcdir)/src/lib/libtalermerchant.la \
   $(LIBGCRYPT_LIBS) \
-  -ltalerbank \
+  -ltalertesting \
+  -ltalermerchanttesting \
   -ltalerfakebank \
+  -ltalerbank \
   -ltalerexchange \
   -ltalerjson \
   -ltalerutil \
diff --git a/src/merchant-tools/taler-merchant-generate-payments_new.c 
b/src/merchant-tools/taler-merchant-generate-payments_new.c
new file mode 100644
index 0000000..fb5939e
--- /dev/null
+++ b/src/merchant-tools/taler-merchant-generate-payments_new.c
@@ -0,0 +1,197 @@
+/*
+  This file is part of TALER
+  (C) 2014-2018 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Affero General Public License as
+  published by the Free Software Foundation; either version 3, or
+  (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with TALER; see the file COPYING.  If not,
+  see <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file merchant/backend/taler-merchant-httpd.c
+ * @brief HTTP serving layer intended to perform crypto-work and
+ * communication with the exchange
+ * @author Marcello Stanisci
+ */
+
+#include "platform.h"
+#include <taler/taler_util.h>
+#include <taler/taler_signatures.h>
+#include <taler/taler_exchange_service.h>
+#include <taler/taler_json_lib.h>
+#include <gnunet/gnunet_util_lib.h>
+#include <microhttpd.h>
+#include <taler/taler_bank_service.h>
+#include <taler/taler_fakebank_lib.h>
+#include <taler/taler_testing_lib.h>
+#include <taler/taler_error_codes.h>
+#include "taler_merchant_testing_lib.h"
+
+/**
+ * Exit code.
+ */
+unsigned int result = 1;
+
+/**
+ * Merchant process.
+ */
+static struct GNUNET_OS_Process *merchantd;
+
+/**
+ * How many payments we want to generate.
+ */
+unsigned int payments_number;
+
+/**
+ * How many /tracks operation we want to perform.
+ */
+unsigned int tracks_number;
+
+/**
+ * Merchant base URL.
+ */
+static char *merchant_url;
+
+/**
+ * Fakebank URL.
+ */
+static char *fakebank_url;
+
+/**
+ * Actual commands collection.
+ */
+static void
+run_commands (void *cls,
+              struct TALER_TESTING_Interpreter *is)
+{
+
+
+  struct TALER_TESTING_Command commands[] = {
+
+    TALER_TESTING_cmd_end ()
+  };
+
+  TALER_TESTING_run_with_fakebank (is,
+                                   commands,
+                                   fakebank_url);
+  return;
+}
+
+/**
+ * Main function that will be run by the scheduler,
+ * mainly needed to get the configuration filename to use.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file
+ *        used (for saving, can be NULL!)
+ * @param config configuration
+ */
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *config)
+{
+  TALER_LOG_DEBUG ("Using configuration file: %s\n", cfgfile);
+
+  if (NULL == merchant_url)
+  {
+    TALER_LOG_ERROR ("Option -m is mandatory!\n");
+    result = 2;
+    return;
+  }
+
+  if (NULL == (merchantd = TALER_TESTING_run_merchant
+    (cfgfile, merchant_url)))
+  {
+    TALER_LOG_ERROR ("Failed to launch the merchant\n");
+    result = 3;
+    return;
+  }
+
+  result = 0;
+
+  if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank
+        (cfgfile, "account-1")))
+  {
+    TALER_LOG_ERROR ("Failed to prepare the fakebank\n");
+    result = 4;
+    GNUNET_OS_process_kill (merchantd, SIGTERM);
+    GNUNET_OS_process_wait (merchantd);
+    GNUNET_OS_process_destroy (merchantd);
+    return;
+  }
+
+  /* Blocks.. */
+  result = TALER_TESTING_setup_with_exchange (&run_commands,
+                                              NULL,
+                                              cfgfile);
+
+  GNUNET_OS_process_kill (merchantd, SIGTERM);
+  GNUNET_OS_process_wait (merchantd);
+  GNUNET_OS_process_destroy (merchantd);
+}
+
+
+/**
+ * The main function of the serve tool
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc,
+      char *const *argv)
+{
+
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+    GNUNET_GETOPT_option_uint
+      ('n',
+       "payments-number",
+       "PN",
+       "will generate PN payments, defaults to 1",
+       &payments_number),
+
+    GNUNET_GETOPT_option_uint
+      ('t',
+       "tracks-number",
+       "TN",
+       "will perform TN /track operations, defaults to 1",
+       &tracks_number),
+
+    /**
+     * NOTE: useful when the setup serves merchant
+     * backends via unix domain sockets, since there
+     * is no way - yet? - to get the merchant base url.
+     * Clearly, we could introduce a merchant_base_url
+     * value into the configuration.
+     */
+    GNUNET_GETOPT_option_string
+      ('m',
+       "merchant-url",
+       "MU",
+       "merchant base url, mandatory",
+       &merchant_url),
+
+    GNUNET_GETOPT_OPTION_END
+  };
+
+  GNUNET_PROGRAM_run (argc, argv,
+                      "taler-merchant-generate-payments-new",
+                      "Populate the database with payments",
+                      options, &run, NULL);
+  return result;
+}

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]