gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated (e94e8c3 -> 39a9045)


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (e94e8c3 -> 39a9045)
Date: Thu, 17 May 2018 21:29:42 +0200

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

marcello pushed a change to branch master
in repository exchange.

    from e94e8c3  Trigger deposit to refund not found
     new 2fff7d8  Trigger /refund currency missmatch the right way.
     new 1b5dfe2  Trigger refund insufficient funds
     new c0c5bd3  Trigger refund fee to low
     new 5e1178a  Trigger double(-successful) refund.
     new 381ac75  Trigger conflicting refunds
     new 39a9045  comment

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:
 src/exchange-lib/exchange_api_refund.c       |  8 +++++
 src/exchange-lib/test_exchange_api_new.c     |  9 ++++++
 src/exchange-lib/test_exchange_api_twisted.c | 36 +++++++++++++--------
 src/exchange-lib/testing_api_cmd_refund.c    | 47 ++++++++++++++++++++++++++--
 src/include/taler_testing_lib.h              | 20 ++++++++++++
 5 files changed, 105 insertions(+), 15 deletions(-)

diff --git a/src/exchange-lib/exchange_api_refund.c 
b/src/exchange-lib/exchange_api_refund.c
index ef1d66b..c91952f 100644
--- a/src/exchange-lib/exchange_api_refund.c
+++ b/src/exchange-lib/exchange_api_refund.c
@@ -180,6 +180,14 @@ handle_refund_finished (void *cls,
     /* Kind of normal: the money was already sent to the merchant
        (it was too late for the refund). */
     break;
+  case MHD_HTTP_PRECONDITION_FAILED:
+    /* Client request was inconsistent; might be a currency missmatch
+       problem.  */
+    break;
+  case MHD_HTTP_CONFLICT:
+    /* Two refund requests were made about the same deposit, but
+       carrying different refund transaction ids.  */
+    break;
   case MHD_HTTP_INTERNAL_SERVER_ERROR:
     /* Server had an internal issue; we should retry, but this API
        leaves this to the application */
diff --git a/src/exchange-lib/test_exchange_api_new.c 
b/src/exchange-lib/test_exchange_api_new.c
index 8d39ca0..c5e62a0 100644
--- a/src/exchange-lib/test_exchange_api_new.c
+++ b/src/exchange-lib/test_exchange_api_new.c
@@ -496,6 +496,15 @@ run (void *cls,
       ("refund-ok", MHD_HTTP_OK,
        "EUR:5", "EUR:0.01", "deposit-refund-1"),
 
+    TALER_TESTING_cmd_refund
+      ("refund-ok-double", MHD_HTTP_OK,
+       "EUR:5", "EUR:0.01", "deposit-refund-1"),
+
+    /* Previous /refund(s) had id == 0.  */
+    TALER_TESTING_cmd_refund_with_id
+      ("refund-conflicting", MHD_HTTP_CONFLICT,
+       "EUR:5", "EUR:0.01", "deposit-refund-1", 1),
+
     /**
      * Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone
      * due to refund) (merchant would receive EUR:4.98 due to
diff --git a/src/exchange-lib/test_exchange_api_twisted.c 
b/src/exchange-lib/test_exchange_api_twisted.c
index 6b044a8..7d24fbc 100644
--- a/src/exchange-lib/test_exchange_api_twisted.c
+++ b/src/exchange-lib/test_exchange_api_twisted.c
@@ -201,7 +201,7 @@ run (void *cls,
        /* Next chunk, refund conflicts
        
          (contract hash missmatch [!],
-          original deposit does not exist,
+          original deposit does not exist V,
           currency missmatch) V;
           
           'refund_transaction()' has many of the relevant cases;
@@ -235,22 +235,15 @@ run (void *cls,
        "EUR:5",
        MHD_HTTP_OK),
 
-    TALER_TESTING_cmd_modify_object_ul
-      ("hack-currency",
-       CONFIG_FILE,
-       /* Will make currency missmatch */
-       "refund_amount",
-       "USD:5"),
-
     TALER_TESTING_cmd_refund
       ("refund-currency-missmatch",
-       MHD_HTTP_BAD_REQUEST,
-       "EUR:5",
-       "EUR:0.01",
+       MHD_HTTP_PRECONDITION_FAILED,
+       "USD:5",
+       "USD:0.01",
        "deposit-refund-1"),
 
     TALER_TESTING_cmd_refund
-      ("refund-above-amount",
+      ("refund-fee-above-amount",
        MHD_HTTP_BAD_REQUEST,
        "EUR:5",
        "EUR:10",
@@ -283,6 +276,9 @@ run (void *cls,
        TALER_TESTING_make_wire_details
          (42,
           fakebank_url),
+       /* This parameter will make any comparison about
+          h_contract_terms fail, when /refund will be handled.
+          So in other words, this is h_contract missmatch.  */
        "{\"items\":[{\"name\":\"ice skate\","
                     "\"value\":\"EUR:5\"}]}",
        GNUNET_TIME_UNIT_MINUTES,
@@ -291,11 +287,25 @@ run (void *cls,
 
     TALER_TESTING_cmd_refund
       ("refund-deposit-not-found",
-       MHD_HTTP_BAD_REQUEST,
+       MHD_HTTP_NOT_FOUND,
        "EUR:5",
        "EUR:0.01",
        "deposit-refund-to-fail"),
 
+    TALER_TESTING_cmd_refund
+      ("refund-insufficient-funds",
+       MHD_HTTP_PRECONDITION_FAILED,
+       "EUR:50",
+       "EUR:0.01",
+       "deposit-refund-1"),
+
+    TALER_TESTING_cmd_refund
+      ("refund-fee-too-low",
+       MHD_HTTP_BAD_REQUEST,
+       "EUR:5",
+       "EUR:0.000001",
+       "deposit-refund-1"),
+
     TALER_TESTING_cmd_end ()
   };
 
diff --git a/src/exchange-lib/testing_api_cmd_refund.c 
b/src/exchange-lib/testing_api_cmd_refund.c
index 35cb20d..ed3bd7c 100644
--- a/src/exchange-lib/testing_api_cmd_refund.c
+++ b/src/exchange-lib/testing_api_cmd_refund.c
@@ -227,8 +227,12 @@ refund_run (void *cls,
   }
 
   rs->rh = TALER_EXCHANGE_refund
-    (rs->exchange, &refund_amount, &refund_fee, &h_contract_terms,
-     &coin, rs->refund_transaction_id,
+    (rs->exchange,
+     &refund_amount,
+     &refund_fee,
+     &h_contract_terms,
+     &coin,
+     rs->refund_transaction_id,
      (const struct TALER_MerchantPrivateKeyP *) merchant_priv,
      &refund_cb, rs);
 
@@ -294,3 +298,42 @@ TALER_TESTING_cmd_refund (const char *label,
 
   return cmd;
 }
+
+/**
+ * Create a /refund test command, allows to specify refund
+ * transaction id.  Mainly used to create conflicting requests.
+ *
+ * @param label command label
+ * @param expected_response_code expected HTTP status code
+ * @param refund_amount the amount to ask a refund for
+ * @param refund_fee expected refund fee
+ * @param coin_reference reference to a command that can
+ *        provide a coin to be refunded.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_refund_with_id
+  (const char *label,
+   unsigned int expected_response_code,
+   const char *refund_amount,
+   const char *refund_fee,
+   const char *coin_reference,
+   uint64_t refund_transaction_id)
+{
+  struct RefundState *rs;
+  struct TALER_TESTING_Command cmd;
+
+  rs = GNUNET_new (struct RefundState);
+
+  rs->expected_response_code = expected_response_code;
+  rs->refund_amount = refund_amount;
+  rs->refund_fee = refund_fee;
+  rs->coin_reference = coin_reference;
+  rs->refund_transaction_id = refund_transaction_id;
+
+  cmd.cls = rs;
+  cmd.label = label;
+  cmd.run = &refund_run;
+  cmd.cleanup = &refund_cleanup;
+
+  return cmd;
+}
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 910495e..f7d3cca 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -829,6 +829,26 @@ struct TALER_TESTING_Command
 TALER_TESTING_cmd_check_bank_empty (const char *label);
 
 /**
+ * Create a /refund test command, allows to specify refund
+ * transaction id.
+ *
+ * @param label command label
+ * @param expected_response_code expected HTTP status code
+ * @param refund_amount the amount to ask a refund for
+ * @param refund_fee expected refund fee
+ * @param coin_reference reference to a command that can
+ *        provide a coin to be refunded.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_refund_with_id
+  (const char *label,
+   unsigned int expected_response_code,
+   const char *refund_amount,
+   const char *refund_fee,
+   const char *deposit_reference,
+   uint64_t refund_transaction_id);
+
+/**
  * Create a /refund test command.
  *
  * @param label command label

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



reply via email to

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