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 (a3ceef4 -> 5a0697a)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (a3ceef4 -> 5a0697a)
Date: Thu, 09 Mar 2017 20:35:49 +0100

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

marcello pushed a change to branch master
in repository merchant.

    from a3ceef4  Beginning #4945..
     new 2af86bf  Undoing last commit.
     new 5a0697a  Adding options to take exchange, merchant backend, and bank 
URIs to the payments generator.

The 2 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:
 src/samples/generate_payments.c | 119 ++++++++++++++++++----------------------
 1 file changed, 53 insertions(+), 66 deletions(-)

diff --git a/src/samples/generate_payments.c b/src/samples/generate_payments.c
index 67f0c79..5c398fd 100644
--- a/src/samples/generate_payments.c
+++ b/src/samples/generate_payments.c
@@ -26,16 +26,12 @@
 #include <gnunet/gnunet_curl_lib.h>
 #include <microhttpd.h>
 
-#define EXCHANGE_URI "http://localhost:8081/";
-
-#define BANK_URI "http://localhost:8083/";
+char *exchange_uri;
+char *merchant_uri;
+char *bank_uri;
 
 #define ORDER_MAX_SIZE 1000
 
-const char *exchange_uri;
-
-const char *backend_uri;
-
 /**
  * Task run on timeout.
  */
@@ -836,7 +832,7 @@ interpreter_run (void *cls)
 
       cmd->details.pay.ph
        = TALER_MERCHANT_pay_wallet (ctx,
-                                    backend_uri,
+                                    merchant_uri,
                                      "default",
                                     &ref->details.proposal.hash,
                                     &total_amount,
@@ -847,7 +843,7 @@ interpreter_run (void *cls)
                                     refund_deadline,
                                     pay_deadline,
                                     &h_wire,
-                                    EXCHANGE_URI,
+                                    exchange_uri,
                                      order_id,
                                     1 /* num_coins */,
                                     &pc /* coins */,
@@ -884,7 +880,7 @@ interpreter_run (void *cls)
         }
         cmd->details.proposal.po
           = TALER_MERCHANT_order_put (ctx,
-                                      backend_uri,
+                                      merchant_uri,
                                       order,
                                       &proposal_cb,
                                       is);
@@ -1024,6 +1020,9 @@ interpreter_run (void *cls)
         fail (is);
         return;
       }
+
+      json_object_set (sender_details, "bank_uri", json_string (bank_uri));
+
       transfer_details = json_loads 
(cmd->details.admin_add_incoming.transfer_details,
                                      JSON_REJECT_DUPLICATES,
                                      NULL);
@@ -1315,21 +1314,21 @@ run (void *cls)
     { .oc = OC_ADMIN_ADD_INCOMING,
       .label = "create-reserve-1",
       .expected_response_code = MHD_HTTP_OK,
-      .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", 
\"bank_uri\":\"" BANK_URI "\", \"account_number\":62, \"uuid\":1 }",
+      .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", 
\"account_number\":62, \"uuid\":1 }",
       .details.admin_add_incoming.transfer_details = "{ \"uuid\": 1}",
       .details.admin_add_incoming.amount = "EUR:5.01" },
     /* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per config */
     { .oc = OC_ADMIN_ADD_INCOMING,
       .label = "create-reserve-2",
       .expected_response_code = MHD_HTTP_OK,
-      .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", 
\"bank_uri\":\"" BANK_URI "\", \"account_number\":62, \"uuid\":1 }",
+      .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", 
\"account_number\":62, \"uuid\":1 }",
       .details.admin_add_incoming.transfer_details = "{ \"uuid\": 1}",
       .details.admin_add_incoming.amount = "EUR:5.01" },
     /* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per config */
     { .oc = OC_ADMIN_ADD_INCOMING,
       .label = "create-reserve-3",
       .expected_response_code = MHD_HTTP_OK,
-      .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", 
\"bank_uri\":\"" BANK_URI "\", \"account_number\":62, \"uuid\":1 }",
+      .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", 
\"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 */
@@ -1438,7 +1437,7 @@ run (void *cls)
   GNUNET_assert (NULL != ctx);
   rc = GNUNET_CURL_gnunet_rc_create (ctx);
   exchange = TALER_EXCHANGE_connect (ctx,
-                                     EXCHANGE_URI,
+                                     exchange_uri,
                                      &cert_cb, is,
                                      TALER_EXCHANGE_OPTION_END);
   GNUNET_assert (NULL != exchange);
@@ -1452,62 +1451,33 @@ run (void *cls)
 }
 
 int
-main ()
+main (int argc,
+      char *argv[])
 {
-  struct GNUNET_OS_Process *proc;
   struct GNUNET_OS_Process *exchanged;
   struct GNUNET_OS_Process *merchantd;
   unsigned int cnt;
   struct GNUNET_SIGNAL_Context *shc_chld;
   char *wget_cmd;
 
+  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    { 'e', "exchange-uri", "EXCHANGE_URI",
+      "Indicates the exchange's URI.", GNUNET_YES,
+      &GNUNET_GETOPT_set_string, &exchange_uri},
+    { 'm', "merchant-uri", "MERCHANT_URI",
+      "Indicates the merchant backend's URI.", GNUNET_YES,
+      &GNUNET_GETOPT_set_string, &merchant_uri},
+    { 'b', "merchant-uri", "MERCHANT_URI",
+      "Indicates the bank's URI.", GNUNET_YES,
+      &GNUNET_GETOPT_set_string, &bank_uri},
+    GNUNET_GETOPT_OPTION_END
+  };
 
   unsetenv ("XDG_DATA_HOME");
   unsetenv ("XDG_CONFIG_HOME");
   GNUNET_log_setup ("merchant-create-payments",
                     "DEBUG",
                     NULL);
-  cfg = GNUNET_CONFIGURATION_create ();
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONFIGURATION_load (cfg,
-                                            
"merchant_generate_payments.conf"));
-
-
-  proc = GNUNET_OS_start_process (GNUNET_NO,
-                                  GNUNET_OS_INHERIT_STD_ALL,
-                                  NULL, NULL, NULL,
-                                  "taler-exchange-keyup",
-                                  "taler-exchange-keyup",
-                                  "-c", "merchant_generate_payments.conf",
-                                  NULL);
-  if (NULL == proc)
-  {
-    fprintf (stderr,
-             "Failed to run taler-exchange-keyup. Check your PATH.\n");
-    return 77;
-  }
-
-
-  GNUNET_OS_process_wait (proc);
-  GNUNET_OS_process_destroy (proc);
-
-  proc = GNUNET_OS_start_process (GNUNET_NO,
-                                  GNUNET_OS_INHERIT_STD_ALL,
-                                  NULL, NULL, NULL,
-                                  "taler-exchange-dbinit",
-                                  "taler-exchange-dbinit",
-                                  "-c", "merchant_generate_payments.conf",
-                                  "-r",
-                                  NULL);
-  if (NULL == proc)
-  {
-    fprintf (stderr,
-             "Failed to run taler-exchange-dbinit. Check your PATH.\n");
-    return 77;
-  }
-  GNUNET_OS_process_wait (proc);
-  GNUNET_OS_process_destroy (proc);
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "About to launch the exchange.\n");
 
@@ -1516,7 +1486,6 @@ main ()
                                        NULL, NULL, NULL,
                                        "taler-exchange-httpd",
                                        "taler-exchange-httpd",
-                                       "-c", "merchant_generate_payments.conf",
                                        NULL);
   if (NULL == exchanged)
   {
@@ -1527,6 +1496,10 @@ main ()
 
   fprintf (stderr,
            "Waiting for taler-exchange-httpd to be ready\n");
+
+  GNUNET_asprintf (&wget_cmd,
+                   "wget -q -t 1 -T 1 %skeys -o /dev/null -O /dev/null",
+                   exchange_uri);
   cnt = 0;
   do
     {
@@ -1544,15 +1517,16 @@ main ()
         return 77;
       }
     }
-  while (0 != system ("wget -q -t 1 -T 1 " EXCHANGE_URI "keys -o /dev/null -O 
/dev/null"));
+  while (0 != system (wget_cmd));
   fprintf (stderr, "\n");
 
+  GNUNET_free (wget_cmd);
+
   merchantd = GNUNET_OS_start_process (GNUNET_NO,
                                        GNUNET_OS_INHERIT_STD_ALL,
                                        NULL, NULL, NULL,
                                        "taler-merchant-httpd",
                                        "taler-merchant-httpd",
-                                       "-c", "merchant_generate_payments.conf",
                                        "-L", "DEBUG",
                                        NULL);
   if (NULL == merchantd)
@@ -1568,11 +1542,10 @@ main ()
   /* give child time to start and bind against the socket */
   fprintf (stderr,
            "Waiting for taler-merchant-httpd to be ready\n");
-  cnt = 0;
-
   GNUNET_asprintf (&wget_cmd,
                    "wget -q -t 1 -T 1 %s -o /dev/null -O /dev/null",
-                   backend_uri);
+                   merchant_uri);
+  cnt = 0;
   do
     {
       fprintf (stderr, ".");
@@ -1593,17 +1566,31 @@ main ()
         return 77;
       }
     }
-  while (0 != system (wget_cmd));
-
-  GNUNET_free (wget_cmd);
+  while (wget_cmd);
   fprintf (stderr, "\n");
+  GNUNET_free (wget_cmd);
 
   result = GNUNET_SYSERR;
   sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
   GNUNET_assert (NULL != sigpipe);
   shc_chld = GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD,
                                             &sighandler_child_death);
+  if (GNUNET_GETOPT_run ("merchant-payments-generator",
+                         options, argc, argv) < 0)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Invalid command line options."); 
+    return 77;
+  }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Options: exchange_uri '%s', merchant_uri '%s' bank_uri '%s'.",
+              exchange_uri,
+              merchant_uri,
+              bank_uri);
+
   GNUNET_SCHEDULER_run (&run, NULL);
+
   GNUNET_SIGNAL_handler_uninstall (shc_chld);
   shc_chld = NULL;
   GNUNET_DISK_pipe_close (sigpipe);

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



reply via email to

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