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 (19bc21b -> 75a7824)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (19bc21b -> 75a7824)
Date: Fri, 02 Mar 2018 15:02:13 +0100

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

marcello pushed a change to branch master
in repository merchant.

    from 19bc21b  doc: missing graph
     new de095f3  twisted skeleton.
     new ae29517  fix compiler warning.
     new 5422937  convenience function to kill+wait+destroy processes.
     new f8b9805  finish testing if twister started correctly.
     new 799bab2  fix compilation regarding twister-lib dep.
     new 6962650  do not compile twister-based checks
     new 7272ce7  config file for twisted tests.
     new 75a7824  gitignore

The 8 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                                         |   4 +
 src/include/taler_merchant_testing_lib.h           |   8 -
 src/lib/Makefile.am                                |  22 ++
 src/lib/test_merchant_api_new.c                    |  14 +-
 src/lib/test_merchant_api_twisted.c                | 252 +++++++++++++++++++++
 ...ant_api.conf => test_merchant_api_twisted.conf} |  49 +++-
 src/lib/testing_api_cmd_pay.c                      |   5 +-
 7 files changed, 331 insertions(+), 23 deletions(-)
 create mode 100644 src/lib/test_merchant_api_twisted.c
 copy src/lib/{test_merchant_api.conf => test_merchant_api_twisted.conf} (82%)

diff --git a/.gitignore b/.gitignore
index f5c3e90..9ebe683 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,10 @@ src/lib/test_merchant_api
 src/lib/test_merchant_api_new
 src/lib/test_merchant_api_home/.local/share/taler/exchange/live-keys/
 src/lib/test_merchant_api_home/.local/share/taler/wirefees/
+src/lib/auditor.in
+src/lib/test_merchant_api_home/.local/share/taler/auditor/
+src/lib/test_merchant_api_home/.local/share/taler/auditors/
+src/lib/test_merchant_api_twisted
 taler_merchant_config.h
 taler_merchant_config.h.in
 doc/*
diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index 53f0469..3a34690 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -39,14 +39,6 @@
 #define CMD_NOT_FOUND "Command not found"
 #define TRAIT_NOT_FOUND "Trait not found"
 
-#define TALER_TESTING_FAIL(is) \
-  do \
-  {\
-    GNUNET_break (0); \
-    TALER_TESTING_interpreter_fail (is); \
-    return; \
-  } while (0)
-
 /**
  * Prepare the merchant execution.  Create tables and check if
  * the port is available.
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 93f154b..4419e67 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -77,11 +77,33 @@ if HAVE_TALERFAKEBANK
 check_PROGRAMS = \
   test_merchant_api_new \
   test_merchant_api
+  # test_merchant_api_twisted
 endif
 
 TESTS = \
   $(check_PROGRAMS)
 
+# To be uncommented once the twister is deployed.
+#test_merchant_api_twisted_SOURCES = \
+#  test_merchant_api_twisted.c
+#test_merchant_api_twisted_LDADD = \
+#  $(top_srcdir)/src/backenddb/libtalermerchantdb.la \
+#  libtalermerchant.la \
+#  $(LIBGCRYPT_LIBS) \
+#  -ltalertesting \
+#  -ltalermerchanttesting \
+#  -ltalertwistertesting \
+#  -ltalerfakebank \
+#  -ltalerbank \
+#  -ltalerexchange \
+#  -ltalerjson \
+#  -ltalerutil \
+#  -lgnunetjson \
+#  -lgnunetcurl \
+#  -lgnunetutil \
+#  -ljansson \
+#  -ltalertwister
+
 test_merchant_api_new_SOURCES = \
   test_merchant_api_new.c
 test_merchant_api_new_LDADD = \
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index 8615d6a..f7b94c7 100644
--- a/src/lib/test_merchant_api_new.c
+++ b/src/lib/test_merchant_api_new.c
@@ -65,6 +65,11 @@ static char *merchant_url;
 static struct GNUNET_OS_Process *merchantd;
 
 /**
+ * Exchange base URL.
+ */
+static char *exchange_url;
+
+/**
  * Account number of the exchange at the bank.
  */
 #define EXCHANGE_ACCOUNT_NO 2
@@ -648,19 +653,18 @@ main (int argc,
                     NULL);
 
   if (NULL ==
-     (fakebank_url = TALER_TESTING_prepare_fakebank (
-       CONFIG_FILE)))
+    (fakebank_url = TALER_TESTING_prepare_fakebank (CONFIG_FILE)))
     return 77;
 
   if (NULL ==
-     (merchant_url = TALER_TESTING_prepare_merchant (
-       CONFIG_FILE)))
+    (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
     return 77;
 
   TALER_TESTING_cleanup_files (CONFIG_FILE);
 
 
-  switch (TALER_TESTING_prepare_exchange (CONFIG_FILE))
+  switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
+                                          &exchange_url))
   {
   case GNUNET_SYSERR:
     GNUNET_break (0);
diff --git a/src/lib/test_merchant_api_twisted.c 
b/src/lib/test_merchant_api_twisted.c
new file mode 100644
index 0000000..8ffbd2b
--- /dev/null
+++ b/src/lib/test_merchant_api_twisted.c
@@ -0,0 +1,252 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2014-2018 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify
+  it under the terms of the GNU 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 exchange/test_merchant_api_new.c
+ * @brief testcase to test exchange's HTTP API interface
+ * @author Sree Harsha Totakura <address@hidden>
+ * @author Christian Grothoff
+ * @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_merchant_testing_lib.h"
+#include <taler/taler_twister_testing_lib.h>
+#include <taler/taler_twister_service.h>
+
+/**
+ * Configuration file we use.  One (big) configuration is used
+ * for the various components for this test.
+ */
+#define CONFIG_FILE "test_merchant_api_twisted.conf"
+
+/**
+ * Exchange base URL.  Could also be taken from config.
+ */
+#define EXCHANGE_URL "http://localhost:8081/";
+
+/**
+ * (real) Twister URL.  Used at startup time to check if it runs.
+ */
+static char *twister_url;
+
+/**
+ * URL of the fakebank.  Obtained from CONFIG_FILE's
+ * "exchange-wire-test:BANK_URI" option.
+ */
+static char *fakebank_url;
+
+/**
+ * Merchant base URL.
+ */
+static char *merchant_url;
+
+/**
+ * Exchange base URL.
+ */
+static char *exchange_url;
+
+/**
+ * Merchant process.
+ */
+static struct GNUNET_OS_Process *merchantd;
+
+/**
+ * Twister process.
+ */
+static struct GNUNET_OS_Process *twisterd;
+
+/**
+ * Account number of the exchange at the bank.
+ */
+#define EXCHANGE_ACCOUNT_NO 2
+
+/**
+ * Account number of some user.
+ */
+#define USER_ACCOUNT_NO 62
+
+/**
+ * User name. Never checked by fakebank.
+ */
+#define USER_LOGIN_NAME "user42"
+
+/**
+ * User password. Never checked by fakebank.
+ */
+#define USER_LOGIN_PASS "pass42"
+
+/**
+ * Execute the taler-exchange-wirewatch command with
+ * our configuration file.
+ *
+ * @param label label to use for the command.
+ */
+#define CMD_EXEC_WIREWATCH(label) \
+   TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE)
+
+/**
+ * Execute the taler-exchange-aggregator command with
+ * our configuration file.
+ *
+ * @param label label to use for the command.
+ */
+#define CMD_EXEC_AGGREGATOR(label) \
+   TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE)
+
+/**
+ * Run wire transfer of funds from some user's account to the
+ * exchange.
+ *
+ * @param label label to use for the command.
+ * @param amount amount to transfer, i.e. "EUR:1"
+ * @param url exchange_url
+ */
+#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
+   TALER_TESTING_cmd_fakebank_transfer (label, amount, \
+     fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \
+     USER_LOGIN_NAME, USER_LOGIN_PASS, EXCHANGE_URL)
+
+/**
+ * Run wire transfer of funds from some user's account to the
+ * exchange.
+ *
+ * @param label label to use for the command.
+ * @param amount amount to transfer, i.e. "EUR:1"
+ */
+#define CMD_TRANSFER_TO_EXCHANGE_SUBJECT(label,amount,subject) \
+   TALER_TESTING_cmd_fakebank_transfer_with_subject \
+     (label, amount, fakebank_url, USER_ACCOUNT_NO, \
+      EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \
+      subject)
+
+/**
+ * Main function that will tell the interpreter what commands to
+ * run.
+ *
+ * @param cls closure
+ */
+static void
+run (void *cls,
+     struct TALER_TESTING_Interpreter *is)
+{
+
+  struct TALER_TESTING_Command commands[] = {
+    TALER_TESTING_cmd_hack_response_code ("hack-1",
+                                          CONFIG_FILE,
+                                          MHD_HTTP_FORBIDDEN),
+    /**
+     * End the suite.  Fixme: better to have a label for this
+     * too, as it shows a "(null)" token on logs.
+     */
+    TALER_TESTING_cmd_end ()
+  };
+
+  TALER_TESTING_run_with_fakebank (is,
+                                   commands,
+                                   fakebank_url);
+}
+
+/**
+ * Kill, wait, and destroy convenience function.
+ *
+ * @param process process to purge.
+ */
+static void
+purge_process (struct GNUNET_OS_Process *process)
+{
+  GNUNET_OS_process_kill (process, SIGKILL);
+  GNUNET_OS_process_wait (process);
+  GNUNET_OS_process_destroy (process);
+}
+
+int
+main (int argc,
+      char * const *argv)
+{
+  unsigned int ret;
+  /* These environment variables get in the way... */
+  unsetenv ("XDG_DATA_HOME");
+  unsetenv ("XDG_CONFIG_HOME");
+  GNUNET_log_setup ("test-merchant-api-new-twisted",
+                    "DEBUG", NULL);
+
+  if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank
+      (CONFIG_FILE)))
+    return 77;
+
+  if (NULL == (merchant_url = TALER_TESTING_prepare_merchant
+      (CONFIG_FILE)))
+    return 77;
+
+  if (NULL == (twister_url = TALER_TESTING_prepare_twister
+      (CONFIG_FILE)))
+    return 77;
+
+  TALER_TESTING_cleanup_files (CONFIG_FILE);
+
+  switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
+                                          &exchange_url))
+  {
+  case GNUNET_SYSERR:
+    GNUNET_break (0);
+    return 1;
+  case GNUNET_NO:
+    return 77;
+
+  case GNUNET_OK:
+
+    if (NULL == (merchantd = TALER_TESTING_run_merchant
+        (CONFIG_FILE)))
+    {
+      purge_process (twisterd);
+      return 1; // 1 is fine; after all is merchant test cases.
+    }
+
+    if (NULL == (twisterd = TALER_TESTING_run_twister
+        (CONFIG_FILE)))
+      return 77;
+
+    ret = TALER_TESTING_setup_with_exchange (&run, NULL,
+                                             CONFIG_FILE);
+    purge_process (merchantd);
+    purge_process (twisterd);
+    GNUNET_free (merchant_url);
+    GNUNET_free (twister_url);
+
+    if (GNUNET_OK != ret)
+      return 1;
+    break;
+  default:
+    GNUNET_break (0);
+    return 1;
+  }
+  return 0;
+}
+
+/* end of test_merchant_api_new.c */
diff --git a/src/lib/test_merchant_api.conf 
b/src/lib/test_merchant_api_twisted.conf
similarity index 82%
copy from src/lib/test_merchant_api.conf
copy to src/lib/test_merchant_api_twisted.conf
index ef819e4..ea298df 100644
--- a/src/lib/test_merchant_api.conf
+++ b/src/lib/test_merchant_api_twisted.conf
@@ -1,4 +1,33 @@
 # This file is in the public domain.
+
+#########################
+# Twister configuration #
+#########################
+
+[twister]
+# HTTP listen port for twister
+HTTP_PORT = 8888
+
+# HTTP Destination for twister.  The test-Webserver needs
+# to listen on the port used here.  Note: no trailing '/'!
+DESTINATION_BASE_URL = "http://localhost:8081";
+
+# Control port for TCP
+# PORT = 8889
+HOSTNAME = localhost
+ACCEPT_FROM = 127.0.0.1;
+ACCEPT_FROM6 = ::1;
+
+# Control port for UNIX
+UNIXPATH = /tmp/taler-service-twister.sock
+UNIX_MATCH_UID = NO
+UNIX_MATCH_GID = YES
+
+# Launching of twister by ARM
+# BINARY = taler-service-twister
+# AUTOSTART = NO
+# FORCESTART = NO
+
 #
 [PATHS]
 # Persistant data storage for the testcase
@@ -13,7 +42,6 @@ CURRENCY = EUR
 # Configuration for the merchant backend #
 ##########################################
 
-
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
@@ -72,7 +100,8 @@ CLOSING-FEE-2026 = EUR:0.01
 
 
 [merchant-exchange-test]
-URL = http://localhost:8081/
+# must target the twister's http port.
+URL = http://localhost:8888/
 MASTER_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
 
 [merchant-instance-default]
@@ -94,7 +123,7 @@ NAME = Test Tipping Merchant
 
 [merchant-instance-dtip]
 KEYFILE = reserve_dtip.priv
-TIP_EXCHANGE = http://localhost:8081/
+TIP_EXCHANGE = http://localhost:8088/
 TIP_RESERVE_PRIV_FILENAME = reserve_dkey.priv
 NAME = Test Tipping Merchant 2
 
@@ -135,9 +164,9 @@ SALT = 17919252168512238964
 ADDRESS = "Garching"
 
 
-###################################################
-# Configuration for the exchange for the testcase #
-###################################################
+##########################
+# Exchange configuration #
+##########################
 
 [exchange]
 # How to access our database
@@ -149,8 +178,12 @@ PORT = 8081
 # Our public key
 MASTER_PUBLIC_KEY = T1VVFQZZARQ1CMF4BN58EE7SKTW5AV2BS18S87ZEGYS4S29J6DNG
 
-# Base URL of the exchange.
-BASE_URL = "http://localhost:8081/";
+# Base URL of the (PROXIED) exchange.  This URL is where the
+# twister listens at, so that it will be able to get all the
+# connection addressed to the exchange.  In fact, the presence
+# of the twister is 100% transparent to the test case, as it
+# only seeks the exchange/BASE_URL URL to connect to the exchange.
+BASE_URL = "http://localhost:8888/";
 
 [exchangedb-postgres]
 DB_CONN_STR = "postgres:///talercheck"
diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c
index c7f3e87..e628de9 100644
--- a/src/lib/testing_api_cmd_pay.c
+++ b/src/lib/testing_api_cmd_pay.c
@@ -486,10 +486,11 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
 
     icoin = &(*pc)[(*npc)-1];
 
+    /* FIXME: make the two following 'const'. */
     struct TALER_CoinSpendPrivateKeyP *coin_priv; 
-    const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
     struct TALER_DenominationSignature *denom_sig;
-    struct TALER_Amount *denom_value;
+    const struct TALER_Amount *denom_value;
+    const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
 
     GNUNET_assert
       (GNUNET_OK == TALER_TESTING_get_trait_coin_priv

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



reply via email to

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