gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] 04/08: finish testing if twister started c


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] 04/08: finish testing if twister started correctly.
Date: Fri, 02 Mar 2018 15:02:17 +0100

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

marcello pushed a commit to branch master
in repository merchant.

commit f8b98058b8ed1a56b728aca82903762f1d4c807b
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Mar 1 15:53:00 2018 +0100

    finish testing if twister started correctly.
---
 src/lib/Makefile.am                 |   3 +-
 src/lib/test_merchant_api_new.c     |   8 +-
 src/lib/test_merchant_api_twisted.c | 539 +++---------------------------------
 3 files changed, 51 insertions(+), 499 deletions(-)

diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index fe600c3..6c63c6f 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -99,7 +99,8 @@ test_merchant_api_twisted_LDADD = \
   -lgnunetjson \
   -lgnunetcurl \
   -lgnunetutil \
-  -ljansson
+  -ljansson \
+  -ltalertwister
 
 test_merchant_api_new_SOURCES = \
   test_merchant_api_new.c
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index e9685f3..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
@@ -658,7 +663,8 @@ main (int argc,
   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
index 428bb9c..75b3713 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -36,12 +36,13 @@
 #include <taler/taler_fakebank_lib.h>
 #include <taler/taler_testing_lib.h>
 #include "taler_merchant_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.conf"
+#define CONFIG_FILE "test_merchant_api_twisted.conf"
 
 /**
  * Exchange base URL.  Could also be taken from config.
@@ -49,6 +50,11 @@
 #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.
  */
@@ -60,11 +66,21 @@ static char *fakebank_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
@@ -138,492 +154,10 @@ static void
 run (void *cls,
      struct TALER_TESTING_Interpreter *is)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Merchant serves at `%s'\n",
-              merchant_url);
 
   struct TALER_TESTING_Command commands[] = {
 
     /**
-     * Move money to the exchange's bank account.
-     */
-    CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
-                              "EUR:10.02"),
-    /**
-     * Make a reserve exist, according to the previous
-     * transfer.
-     */
-    CMD_EXEC_WIREWATCH ("wirewatch-1"),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-2",
-       "http://localhost:8081/";,
-       "EUR:10.02", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO),
-
-    TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
-                                       is->exchange,
-                                       "create-reserve-1",
-                                       "EUR:5",
-                                       MHD_HTTP_OK),
-
-    TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
-                                       is->exchange,
-                                       "create-reserve-1",
-                                       "EUR:5",
-                                       MHD_HTTP_OK),
-    /**
-     * Check the reserve is depleted.
-     */
-    TALER_TESTING_cmd_status ("withdraw-status-1",
-                              is->exchange,
-                              "create-reserve-1",
-                              "EUR:0",
-                              MHD_HTTP_OK),
-
-    TALER_TESTING_cmd_proposal
-      ("create-proposal-1",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "{\"max_fee\":\
-          {\"currency\":\"EUR\",\
-           \"value\":0,\
-           \"fraction\":50000000},\
-        \"order_id\":\"1\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
-        \"amount\":\
-          {\"currency\":\"EUR\",\
-           \"value\":5,\
-           \"fraction\":0},\
-        \"summary\": \"merchant-lib testcase\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }",
-        NULL),
-
-    TALER_TESTING_cmd_check_payment ("check-payment-1",
-                                     merchant_url,
-                                     is->ctx,
-                                     MHD_HTTP_OK,
-                                     "create-proposal-1",
-                                     GNUNET_NO),
-
-    TALER_TESTING_cmd_pay ("deposit-simple",
-                           merchant_url,
-                           is->ctx,
-                           MHD_HTTP_OK,
-                           "create-proposal-1",
-                           "withdraw-coin-1",
-                           "EUR:5",
-                           "EUR:4.99",
-                           "EUR:0.01"),
-
-    TALER_TESTING_cmd_check_payment ("check-payment-2",
-                                     merchant_url,
-                                     is->ctx,
-                                     MHD_HTTP_OK,
-                                     "create-proposal-1",
-                                     GNUNET_YES),
-
-    TALER_TESTING_cmd_pay_abort ("pay-abort-2",
-                                 merchant_url,
-                                 "deposit-simple",
-                                 is->ctx,
-                                 MHD_HTTP_FORBIDDEN),
-
-    TALER_TESTING_cmd_pay ("replay-simple",
-                           merchant_url,
-                           is->ctx,
-                           MHD_HTTP_OK,
-                           "create-proposal-1",
-                           "withdraw-coin-1",
-                           "EUR:5",
-                           "EUR:4.99",
-                           "EUR:0.01"),
-
-    TALER_TESTING_cmd_proposal
-      ("create-proposal-2",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "{\"max_fee\":\
-          {\"currency\":\"EUR\",\
-           \"value\":0,\
-           \"fraction\":50000000},\
-        \"order_id\":\"2\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
-        \"amount\":\
-          {\"currency\":\"EUR\",\
-           \"value\":5,\
-           \"fraction\":0},\
-        \"summary\": \"useful product\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }",
-        NULL),
-
-    TALER_TESTING_cmd_pay ("deposit-double-2",
-                           merchant_url,
-                           is->ctx,
-                           MHD_HTTP_FORBIDDEN,
-                           "create-proposal-2",
-                           "withdraw-coin-1",
-                           "EUR:5",
-                           "EUR:4.99",
-                           "EUR:0.01"),
-
-    TALER_TESTING_cmd_history ("history-0",
-                               merchant_url,
-                               is->ctx,
-                               MHD_HTTP_OK,
-      /**
-       * all records to be returned; setting date as 0 lets the
-       * interpreter set it as 'now' + one hour delta, just to
-       * make sure it surpasses the proposal's timestamp.
-       */
-                               GNUNET_TIME_UNIT_ZERO_ABS,
-      /**
-       * We only expect ONE result (create-proposal-1) to be
-       * included in /history response, because create-proposal-3
-       * did NOT go through because of double spending.
-       */
-                               1, // nresult
-                               10, // start
-                               10), // nrows
-
-    TALER_TESTING_cmd_fakebank_transfer ("create-reserve-2",
-                                         "EUR:1",
-                                         fakebank_url,
-                                         63, 2,
-                                         "user63",
-                                         "pass63",
-                                         EXCHANGE_URL),
-
-    TALER_TESTING_cmd_fakebank_transfer_with_ref
-      ("create-reserve-2b",
-       "EUR:4.01",
-       fakebank_url,
-       63, 2,
-       "user63",
-       "pass63",
-       "create-reserve-2",
-       EXCHANGE_URL),
-    CMD_EXEC_WIREWATCH ("wirewatch-2"),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-2",
-       "http://localhost:8081/";,
-       "EUR:1", 63, 2),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-2",
-       "http://localhost:8081/";,
-       "EUR:4.01", 63, 2),
-
-    TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
-                                       is->exchange,
-                                       "create-reserve-2",
-                                       "EUR:5",
-                                       MHD_HTTP_OK),
-
-    TALER_TESTING_cmd_proposal_lookup ("fetch-proposal-2",
-                                       is->ctx,
-                                       merchant_url,
-                                       MHD_HTTP_OK,
-                                       "create-proposal-2"),
-
-    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-1"),
-
-    CMD_EXEC_AGGREGATOR ("run-aggregator"),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-498c",
-       "http://localhost:8081/";,
-       "EUR:4.98", 2, 62),
-
-    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"),
-
-    TALER_TESTING_cmd_merchant_track_transaction
-      ("track-transaction-1",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "check_bank_transfer-498c",
-       "deposit-simple",
-       "EUR:0.01"),
-
-    TALER_TESTING_cmd_merchant_track_transfer
-      ("track-transfer-1",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "check_bank_transfer-498c",
-       "deposit-simple"),
-
-    TALER_TESTING_cmd_merchant_track_transfer
-      ("track-transfer-again",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "check_bank_transfer-498c",
-       "deposit-simple"),
-
-    TALER_TESTING_cmd_pay ("deposit-simple-2",
-                           merchant_url,
-                           is->ctx,
-                           MHD_HTTP_OK,
-                           "create-proposal-2",
-                           "withdraw-coin-2",
-                           "EUR:5",
-                           "EUR:4.99",
-                           "EUR:0.01"),
-
-    CMD_EXEC_AGGREGATOR ("run-aggregator-2"),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-498c-2",
-       "http://localhost:8081/";,
-       "EUR:4.98",
-       EXCHANGE_ACCOUNT_NO,
-       USER_ACCOUNT_NO),
-
-    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
-
-    TALER_TESTING_cmd_merchant_track_transfer
-      ("track-transfer-2",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "check_bank_transfer-498c-2",
-       "deposit-simple-2"),
-
-    TALER_TESTING_cmd_merchant_track_transfer
-      ("track-transfer-2-again",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "check_bank_transfer-498c-2",
-       "deposit-simple-2"),
-
-    TALER_TESTING_cmd_merchant_track_transaction
-      ("track-transaction-2",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "check_bank_transfer-498c-2",
-       "deposit-simple-2",
-       "EUR:0.01"),
-
-    TALER_TESTING_cmd_history ("history-1",
-                               merchant_url,
-                               is->ctx,
-                               MHD_HTTP_OK,
-                               GNUNET_TIME_UNIT_ZERO_ABS,
-      /**
-       * Now we expect BOTH contracts (create-proposal-{1,2})
-       * to be included in /history response, because
-       * create-proposal-2 has now been correctly paid.
-       */
-                               2,
-                               10,
-                               10),
-
-    TALER_TESTING_cmd_history
-      ("history-2",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       GNUNET_TIME_absolute_add (GNUNET_TIME_UNIT_ZERO_ABS,
-                                 GNUNET_TIME_UNIT_MICROSECONDS),
-       /* zero results expected, time too ancient. */
-       0,
-       10,
-       10),
-
-    TALER_TESTING_cmd_refund_increase ("refund-increase-1",
-                                       merchant_url,
-                                       is->ctx,
-                                       "refund test",
-                                       "1",
-                                       "EUR:0.1",
-                                       "EUR:0.01"),
-
-    TALER_TESTING_cmd_refund_lookup ("refund-lookup-1",
-                                     merchant_url,
-                                     is->ctx,
-                                     "refund-increase-1",
-                                     "deposit-simple",
-                                     "1"),
-    /* test tipping */
-    TALER_TESTING_cmd_fakebank_transfer_with_instance
-      ("create-reserve-10",
-       "EUR:10.02",
-       fakebank_url,
-       USER_ACCOUNT_NO,
-       EXCHANGE_ACCOUNT_NO,
-       USER_LOGIN_NAME,
-       USER_LOGIN_PASS,
-       "tip",
-       EXCHANGE_URL,
-       CONFIG_FILE),
-
-
-    CMD_EXEC_WIREWATCH ("wirewatch-10"),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-10",
-       "http://localhost:8081/";,
-       "EUR:10.02", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO),
-
-    TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10a",
-                                       is->exchange,
-                                       "create-reserve-10",
-                                       "EUR:5",
-                                       MHD_HTTP_OK),
-    TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10b",
-                                       is->exchange,
-                                       "create-reserve-10",
-                                       "EUR:5",
-                                       MHD_HTTP_OK),
-
-
-    TALER_TESTING_cmd_status ("withdraw-status-10",
-                              is->exchange,
-                              "create-reserve-10",
-                              "EUR:0",
-                              MHD_HTTP_OK),
-
-
-    TALER_TESTING_cmd_proposal
-      ("create-proposal-10",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "{\"max_fee\":\
-          {\"currency\":\"EUR\",\
-           \"value\":0,\
-           \"fraction\":50000000},\
-        \"order_id\":\"10\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
-        \"amount\":\
-          {\"currency\":\"EUR\",\
-           \"value\":10,\
-           \"fraction\":0},\
-        \"summary\": \"merchant-lib testcase\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:10}\"} ] }",
-        NULL),
-
-    TALER_TESTING_cmd_pay ("pay-fail-partial-double-10",
-                           merchant_url,
-                           is->ctx,
-                           MHD_HTTP_FORBIDDEN,
-                           "create-proposal-10",
-                           "withdraw-coin-10a;withdraw-coin-1",
-                           "EUR:5",
-                           "EUR:4.99",
-                           "EUR:0.01"),
-
-    TALER_TESTING_cmd_pay_again
-      ("pay-again-10",
-       merchant_url,
-       "pay-fail-partial-double-10",
-       "withdraw-coin-10a;withdraw-coin-10b",
-       "EUR:0.01",
-       is->ctx,
-       MHD_HTTP_OK),
-
-    CMD_EXEC_AGGREGATOR ("run-aggregator-10"),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-9.97-10",
-       "http://localhost:8081/";,
-       "EUR:9.97",
-       EXCHANGE_ACCOUNT_NO,
-       USER_ACCOUNT_NO),
-
-    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-10"),
-
-    CMD_TRANSFER_TO_EXCHANGE ("create-reserve-11",
-                              "EUR:10.02"),
-
-    CMD_EXEC_WIREWATCH ("wirewatch-11"),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-11",
-       "http://localhost:8081/";,
-       "EUR:10.02", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO),
-
-    TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11a",
-                                       is->exchange,
-                                       "create-reserve-11",
-                                       "EUR:5",
-                                       MHD_HTTP_OK),
-
-    TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11b",
-                                       is->exchange,
-                                       "create-reserve-11",
-                                       "EUR:5",
-                                       MHD_HTTP_OK),
-
-    TALER_TESTING_cmd_status ("withdraw-status-11",
-                              is->exchange,
-                              "create-reserve-11",
-                              "EUR:0",
-                              MHD_HTTP_OK),
-
-    TALER_TESTING_cmd_proposal
-      ("create-proposal-11",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "{\"max_fee\":\
-          {\"currency\":\"EUR\",\
-           \"value\":0,\
-           \"fraction\":50000000},\
-        \"order_id\":\"11\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
-        \"amount\":\
-          {\"currency\":\"EUR\",\
-           \"value\":10,\
-           \"fraction\":0},\
-        \"summary\": \"merchant-lib testcase\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:10}\"} ] }",
-        NULL),
-
-    TALER_TESTING_cmd_pay ("pay-fail-partial-double-11",
-                           merchant_url,
-                           is->ctx,
-                           MHD_HTTP_FORBIDDEN,
-                           "create-proposal-11",
-                           "withdraw-coin-11a;withdraw-coin-1",
-                           "EUR:5",
-                           "EUR:4.99",
-                           "EUR:0.01"),
-
-    TALER_TESTING_cmd_pay_abort ("pay-abort-11",
-                                 merchant_url,
-                                 "pay-fail-partial-double-11",
-                                 is->ctx,
-                                 MHD_HTTP_OK),
-
-    TALER_TESTING_cmd_pay_abort_refund ("pay-abort-refund-11",
-                                        is->exchange,
-                                        /* abort reference */
-                                        "pay-abort-11",
-                                        0,
-                                        "EUR:5",
-                                        "EUR:0.01",
-                                        MHD_HTTP_OK),
-
-    CMD_EXEC_AGGREGATOR ("run-aggregator-11"),
-
-    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-11"),
-
-    /**
      * End the suite.  Fixme: better to have a label for this
      * too, as it shows a "(null)" token on logs.
      */
@@ -656,22 +190,25 @@ main (int argc,
   /* These environment variables get in the way... */
   unsetenv ("XDG_DATA_HOME");
   unsetenv ("XDG_CONFIG_HOME");
-  GNUNET_log_setup ("test-merchant-api-new",
-                    "DEBUG",
-                    NULL);
+  GNUNET_log_setup ("test-merchant-api-new-twisted",
+                    "DEBUG", NULL);
 
-  if (NULL ==
-    (fakebank_url = TALER_TESTING_prepare_fakebank (CONFIG_FILE)))
+  if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank
+      (CONFIG_FILE)))
     return 77;
 
-  if (NULL ==
-    (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
+  if (NULL == (merchant_url = TALER_TESTING_prepare_merchant
+      (CONFIG_FILE)))
     return 77;
 
-  TALER_TESTING_cleanup_files (CONFIG_FILE);
+  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))
+  switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
+                                          &exchange_url))
   {
   case GNUNET_SYSERR:
     GNUNET_break (0);
@@ -681,15 +218,23 @@ main (int argc,
 
   case GNUNET_OK:
 
-    if (NULL == (merchantd =
-        TALER_TESTING_run_merchant (CONFIG_FILE)))
-      return 1;
+    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,
+    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;

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



reply via email to

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