gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 272/277: more merchant benchmark cleanup


From: gnunet
Subject: [taler-merchant] 272/277: more merchant benchmark cleanup
Date: Sun, 05 Jul 2020 20:53:05 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit 1610f3a16efe10c456f86af65134e1d3765863fd
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Jul 3 17:46:30 2020 +0200

    more merchant benchmark cleanup
---
 src/include/taler_merchant_testing_lib.h      |   8 +-
 src/merchant-tools/taler-merchant-benchmark.c | 194 ++++++++++++--------------
 2 files changed, 97 insertions(+), 105 deletions(-)

diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index 2424924..cad54e7 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -40,13 +40,13 @@
  * the port is available.
  *
  * @param config_filename configuration filename.
- *
  * @return the base url, or NULL upon errors.  Must be freed
  *         by the caller.
  */
 char *
 TALER_TESTING_prepare_merchant (const char *config_filename);
 
+
 /**
  * Start the merchant backend process.  Assume the port
  * is available and the database is clean.  Use the "prepare
@@ -55,7 +55,6 @@ TALER_TESTING_prepare_merchant (const char *config_filename);
  * @param config_filename configuration filename.
  * @param merchant_url merchant base URL, used to check
  *        if the merchant was started right.
- *
  * @return the process, or NULL if the process could not
  *         be started.
  */
@@ -1520,6 +1519,11 @@ TALER_TESTING_get_trait_refund_entry ( // FIXME: rename: 
entry->detail
  * Make the instruction pointer point to @a new_ip
  * only if @a counter is greater than zero.
  *
+ * FIXME: this seems to be a BAD API! Proposal: replace "new_ip"
+ * with a 'const char *' that is the _label_ of the target
+ * command (not an offset, and not -1!). Also, this command
+ * should probably be moved to the *exchange* codebase.
+ *
  * @param label command label
  * @param new_ip new instruction pointer's value.  Note that,
  *    when the next instruction will be called, the interpreter
diff --git a/src/merchant-tools/taler-merchant-benchmark.c 
b/src/merchant-tools/taler-merchant-benchmark.c
index f811b50..ac34899 100644
--- a/src/merchant-tools/taler-merchant-benchmark.c
+++ b/src/merchant-tools/taler-merchant-benchmark.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  (C) 2014-2018 Taler Systems SA
+  (C) 2014--2020 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
@@ -55,19 +55,18 @@ enum PaymentGeneratorError
   PG_SUCCESS = 0,
   PG_NO_SUBCOMMAND,
   PG_BAD_OPTIONS,
+  PG_BAD_CONFIG_FILE,
+  PG_FAILED_CFG_CURRENCY,
+  PG_FAILED_TO_PREPARE_MERCHANT,
+  PG_FAILED_TO_PREPARE_BANK,
   PG_FAILED_TO_LAUNCH_MERCHANT,
   PG_FAILED_TO_LAUNCH_BANK,
   PG_RUNTIME_FAILURE
 };
 
 
-/* Hard-coded params.  Note, the bank is expected to
- * have the Tor user with account number 3 and password 'x'.
- */
-#define EXCHANGE_ACCOUNT_NO 2
-#define USER_LOGIN_NAME "Tor"
-#define USER_LOGIN_PASS "x"
-#define EXCHANGE_URL "http://example.com/";
+/* Arguments for #TALER_TESTING_cmd_rewind_ip(). FIXME: should probably be
+   replaced with labels? Bad style! */
 #define FIRST_INSTRUCTION -1
 #define TRACKS_INSTRUCTION 9
 #define TWOCOINS_INSTRUCTION 5
@@ -88,11 +87,6 @@ static bool ordinary;
  */
 static bool corner;
 
-/**
- * Alternative non default instance.
- */
-static char *alt_instance_id;
-
 /**
  * Base URL of the alternative non default instance.
  */
@@ -124,9 +118,9 @@ static unsigned int tracks_number = 1;
 static char *cfg_filename;
 
 /**
- * Bank base URL.
+ * Bank configuration.
  */
-static char *bank_url;
+static struct TALER_TESTING_BankConfiguration bc;
 
 /**
  * Merchant base URL.
@@ -138,15 +132,6 @@ static char *merchant_url;
  */
 static char *currency;
 
-/**
- * Authentication data to use. FIXME: init !
- */
-static struct TALER_BANK_AuthenticationData auth;
-
-static char *exchange_payto;
-static char *customer_payto;
-static char *merchant_payto;
-
 
 /**
  * Actual commands collection.
@@ -251,6 +236,8 @@ run (void *cls,
                    currency,
                    currency,
                    currency);
+
+  if (NULL != apikey)
   {
     char *hdr;
 
@@ -269,8 +256,8 @@ run (void *cls,
     struct TALER_TESTING_Command ordinary_commands[] = {
       TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1",
                                             CURRENCY_10_02,
-                                            &auth,
-                                            customer_payto),
+                                            &bc.exchange_auth,
+                                            bc.user43_payto),
       TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1",
                                         cfg_filename),
       TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
@@ -313,17 +300,18 @@ run (void *cls,
 
       TALER_TESTING_cmd_exec_aggregator ("aggregate-1",
                                          cfg_filename),
-      TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1",
-                                                &auth,
-                                                bank_url,
-                                                merchant_url,
-                                                "EUR:4.98", /* FIXME: check 
amount! */
-                                                MHD_HTTP_OK,
-                                                "deposit-simple-2",
-                                                NULL),
+      TALER_TESTING_cmd_merchant_post_transfer (
+        "post-transfer-1",
+        &bc.exchange_auth,
+        bc.exchange_auth.wire_gateway_url,
+        merchant_url,
+        "EUR:4.98",                                         /* FIXME: check 
amount! */
+        MHD_HTTP_OK,
+        "deposit-simple-2",
+        NULL),
       TALER_TESTING_cmd_merchant_get_transfers ("track-transfer-1",
                                                 merchant_url,
-                                                merchant_payto,
+                                                bc.user42_payto,
                                                 MHD_HTTP_OK,
                                                 "post-transaction-1",
                                                 NULL),
@@ -343,8 +331,8 @@ run (void *cls,
     struct TALER_TESTING_Command corner_commands[] = {
       TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1",
                                             CURRENCY_5_01,
-                                            &auth,
-                                            customer_payto),
+                                            &bc.exchange_auth,
+                                            bc.user43_payto),
       TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1",
                                         cfg_filename),
       TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
@@ -367,8 +355,8 @@ run (void *cls,
                                    &unaggregated_number),
       TALER_TESTING_cmd_admin_add_incoming ("create-reserve-2",
                                             CURRENCY_10_02,
-                                            &auth,
-                                            customer_payto),
+                                            &bc.exchange_auth,
+                                            bc.user43_payto),
       TALER_TESTING_cmd_exec_wirewatch ("wirewatch-2",
                                         cfg_filename),
       TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
@@ -433,6 +421,8 @@ main (int argc,
 {
   char *loglev;
   char *logfile;
+  char *exchange_account;
+  char *alt_instance_id;
   struct GNUNET_OS_Process *bankd;
   struct GNUNET_OS_Process *merchantd;
   struct GNUNET_GETOPT_CommandLineOption *options;
@@ -456,31 +446,17 @@ main (int argc,
                                "TC",
                                "will perform TC 2-coins payments, defaults to 
1",
                                &twocoins_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_mandatory (
-      GNUNET_GETOPT_option_string ('m',
-                                   "merchant-url",
-                                   "MU",
-                                   "merchant base url, mandatory",
-                                   &merchant_url)),
-    GNUNET_GETOPT_option_mandatory (
-      GNUNET_GETOPT_option_string ('a',
-                                   "apikey",
-                                   "APIKEY",
-                                   "HTTP 'Authorization' header to send to the 
merchant, mandatory",
-                                   &apikey)),
-    GNUNET_GETOPT_option_mandatory (
-      GNUNET_GETOPT_option_string ('k',
-                                   "currency",
-                                   "K",
-                                   "Used currency, mandatory",
-                                   &currency)),
+      GNUNET_GETOPT_option_string ('e',
+                                   "exchange-account",
+                                   "SECTION",
+                                   "configuration section specifying the 
exchange account to use, mandatory",
+                                   &exchange_account)),
+    GNUNET_GETOPT_option_string ('a',
+                                 "apikey",
+                                 "APIKEY",
+                                 "HTTP 'Authorization' header to send to the 
merchant",
+                                 &apikey),
     GNUNET_GETOPT_option_mandatory (
       GNUNET_GETOPT_option_string ('i',
                                    "alt-instance",
@@ -494,12 +470,6 @@ main (int argc,
                                    " as they would get those far future ones"
                                    " aggregated too.",
                                    &alt_instance_id)),
-    GNUNET_GETOPT_option_mandatory (
-      GNUNET_GETOPT_option_string ('b',
-                                   "bank-url",
-                                   "BU",
-                                   "bank base url, mandatory",
-                                   &bank_url)),
     GNUNET_GETOPT_option_string ('l',
                                  "logfile",
                                  "LF",
@@ -513,41 +483,27 @@ main (int argc,
     GNUNET_GETOPT_option_help ("Generate Taler ordinary payments"
                                " to populate the databases"),
     GNUNET_GETOPT_option_loglevel (&loglev),
+    GNUNET_GETOPT_option_mandatory (
+      GNUNET_GETOPT_option_string ('e',
+                                   "exchange-account",
+                                   "SECTION",
+                                   "configuration section specifying the 
exchange account to use, mandatory",
+                                   &exchange_account)),
     GNUNET_GETOPT_option_uint ('p',
                                "payments-number",
                                "PN",
                                "will generate PN payments, defaults to 1",
                                &payments_number),
-    GNUNET_GETOPT_option_mandatory (
-      GNUNET_GETOPT_option_string ('a',
-                                   "apikey",
-                                   "APIKEY",
-                                   "HTTP 'Authorization' header to send to the 
merchant, mandatory",
-                                   &apikey)),
+    GNUNET_GETOPT_option_string ('a',
+                                 "apikey",
+                                 "APIKEY",
+                                 "HTTP 'Authorization' header to send to the 
merchant",
+                                 &apikey),
     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_mandatory (
-      GNUNET_GETOPT_option_string ('m',
-                                   "merchant-url",
-                                   "MU",
-                                   "merchant base url, mandatory",
-                                   &merchant_url)),
-    GNUNET_GETOPT_option_mandatory (
-      GNUNET_GETOPT_option_string ('b',
-                                   "bank-url",
-                                   "BU",
-                                   "bank base url, mandatory",
-                                   &bank_url)),
     GNUNET_GETOPT_option_string ('l',
                                  "logfile",
                                  "LF",
@@ -598,6 +554,35 @@ main (int argc,
   }
   if (NULL == cfg_filename)
     cfg_filename = (char *) default_config_file;
+  /* load currency from configuration */
+  {
+    struct GNUNET_CONFIGURATION_Handle *cfg;
+
+    cfg = GNUNET_CONFIGURATION_create ();
+    if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_load (cfg,
+                                   cfg_filename))
+    {
+      TALER_LOG_ERROR ("Could not parse configuration\n");
+      return PG_BAD_CONFIG_FILE;
+    }
+    if (GNUNET_OK !=
+        TALER_config_get_currency (cfg,
+                                   &currency))
+    {
+      TALER_LOG_ERROR ("Failed to read currency from configuration\n");
+      GNUNET_CONFIGURATION_destroy (cfg);
+      return PG_FAILED_CFG_CURRENCY;
+    }
+    GNUNET_CONFIGURATION_destroy (cfg);
+  }
+  /* prepare merchant and bank */
+  merchant_url = TALER_TESTING_prepare_merchant (cfg_filename);
+  if (NULL == merchant_url)
+  {
+    TALER_LOG_ERROR ("Failed to prepare for the merchant\n");
+    return PG_FAILED_TO_PREPARE_MERCHANT;
+  }
   if (NULL != alt_instance_id)
   {
     GNUNET_assert (0 < GNUNET_asprintf (&alt_instance_url,
@@ -605,6 +590,16 @@ main (int argc,
                                         merchant_url,
                                         &alt_instance_id));
   }
+  if (GNUNET_OK !=
+      TALER_TESTING_prepare_bank (cfg_filename,
+                                  GNUNET_YES,
+                                  exchange_account,
+                                  &bc))
+  {
+    TALER_LOG_ERROR ("Failed to prepare for the bank\n");
+    return PG_FAILED_TO_PREPARE_BANK;
+  }
+  /* launch merchant and bank */
   if (NULL == (merchantd = TALER_TESTING_run_merchant (cfg_filename,
                                                        merchant_url)))
   {
@@ -612,21 +607,14 @@ main (int argc,
     return PG_FAILED_TO_LAUNCH_MERCHANT;
   }
   if (NULL == (bankd = TALER_TESTING_run_bank (cfg_filename,
-                                               bank_url)))
+                                               
bc.exchange_auth.wire_gateway_url)))
   {
     TALER_LOG_ERROR ("Failed to run the bank\n");
     terminate_process (merchantd);
     return PG_FAILED_TO_LAUNCH_BANK;
   }
 
-  /**
-   * FIXME: Need to retrieve the bank base URL!
-   */
-
-  exchange_payto = "payto://x-taler-bank/localhost/Exchange";
-  merchant_payto = "payto://x-taler-bank/localhost/Merchant";
-  customer_payto = "payto://x-taler-bank/localhost/Customer";
-
+  /* launch exchange and run benchmark */
   {
     int result;
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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