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 (63d4c63 -> 041ad71)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (63d4c63 -> 041ad71)
Date: Thu, 24 May 2018 15:56:19 +0200

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

marcello pushed a change to branch master
in repository merchant.

    from 63d4c63  minor edit.
     new afceb5b  Splitting pay CMD.
     new 041ad71  Fix bugs strongly related to #5330.

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/lib/merchant_api_pay.c          |  4 ++++
 src/lib/test_merchant_api.c         | 43 +++++++++++++++++++++++++++++++------
 src/lib/test_merchant_api_new.c     | 21 ++++++++++--------
 src/lib/test_merchant_api_twisted.c |  2 +-
 src/lib/testing_api_cmd_pay.c       |  3 ++-
 5 files changed, 56 insertions(+), 17 deletions(-)

diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 973a9b5..93b6478 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -337,6 +337,10 @@ handle_pay_finished (void *cls,
     case 0:
       break;
     case MHD_HTTP_OK:
+    /* Tolerating Not Acceptable because sometimes
+     * - especially in tests - we might want to POST
+     * coins one at a time.  */
+    case MHD_HTTP_NOT_ACCEPTABLE:
       break;
     case MHD_HTTP_BAD_REQUEST:
       /* This should never happen, either us or the merchant is buggy
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index f0d7f49..db9e11e 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -3690,8 +3690,11 @@ interpreter_run (void *cls)
                               (is,
                                cmd->details.pay_abort_refund.abort_ref)));
       GNUNET_assert (OC_PAY_ABORT == ref->oc);
+
       GNUNET_assert (ref->details.pay_abort.num_refunds >
+                     /* 'num_coin' is actually the coin _index_ */
                     cmd->details.pay_abort_refund.num_coin);
+
       re = &ref->details.pay_abort.res[cmd->details.pay_abort_refund.num_coin];
 
       GNUNET_assert (GNUNET_OK ==
@@ -4862,7 +4865,8 @@ run (void *cls)
         = "create-reserve-11",
       .details.reserve_status.expected_balance = "EUR:0" },
 
-    /* Create proposal */
+    /* Create proposal, to be partially paid, then
+     * abort-refunded, and then paid again.  */
     { .oc = OC_PROPOSAL,
       .label = "create-proposal-11",
       .expected_response_code = MHD_HTTP_OK,
@@ -4884,28 +4888,55 @@ run (void *cls)
           [ {\"description\":\"ice cream\",\
              \"value\":\"{EUR:10}\"} ] }"},
 
-    /* execute simple payment, re-using one ancient coin */
+    /**
+     * The following two OC_PAY CMDs used to be one.
+     *
+     * However, This caused the refund to be issued _randomly_,
+     * because the order the good coin and the double-spent
+     * coin were deposited was random.  Therefore, when
+     * the bad coin was first deposited, the CMD returned
+     * (403) and the good coin was never deposited.  This
+     * used to make the "abort refund" CMD fail, since it
+     * expected at least one coin to be refunded.
+     *
+     * The workaround is to _split_ the payment, so as to make
+     * sure that the good coin is always deposited, therefore
+     * having _always_ one coin to get a refund for.
+     *
+     * The test case could now work even without the second
+     * half of the split, but we keep it for "historical"
+     * reasons. */
     { .oc = OC_PAY,
-      .label = "pay-fail-partial-double-11",
+      .label = "pay-fail-partial-double-11-not_acceptable",
+      .expected_response_code = MHD_HTTP_NOT_ACCEPTABLE,
+      .details.pay.contract_ref = "create-proposal-11",
+      .details.pay.coin_ref = "withdraw-coin-11a",
+      /* These amounts are given per coin! */
+      .details.pay.refund_fee = "EUR:0.01",
+      .details.pay.amount_with_fee = "EUR:5",
+      .details.pay.amount_without_fee = "EUR:4.99" },
+    { .oc = OC_PAY,
+      .label = "pay-fail-partial-double-11-forbidden",
       .expected_response_code = MHD_HTTP_FORBIDDEN,
       .details.pay.contract_ref = "create-proposal-11",
-      .details.pay.coin_ref = "withdraw-coin-11a;withdraw-coin-1",
+      .details.pay.coin_ref = "withdraw-coin-1",
       /* These amounts are given per coin! */
       .details.pay.refund_fee = "EUR:0.01",
       .details.pay.amount_with_fee = "EUR:5",
       .details.pay.amount_without_fee = "EUR:4.99" },
 
-    /* Try to replay payment reusing coin */
     { .oc = OC_PAY_ABORT,
       .label = "pay-abort-11",
       .expected_response_code = MHD_HTTP_OK,
-      .details.pay_abort.pay_ref = "pay-fail-partial-double-11",
+      .details.pay_abort.pay_ref = "pay-fail-partial-double-11-not_acceptable",
     },
 
     { .oc = OC_PAY_ABORT_REFUND,
       .label = "pay-abort-refund-11",
       .expected_response_code = MHD_HTTP_OK,
+      /* Will provide the refund permission.  */
       .details.pay_abort_refund.abort_ref = "pay-abort-11",
+      /* Coin _index_ to be refunded.  */
       .details.pay_abort_refund.num_coin = 0,
       .details.pay_abort_refund.refund_amount = "EUR:5",
       .details.pay_abort_refund.refund_fee = "EUR:0.01" },
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index e6d0c00..7500981 100644
--- a/src/lib/test_merchant_api_new.c
+++ b/src/lib/test_merchant_api_new.c
@@ -977,25 +977,28 @@ run (void *cls,
                          \"value\":\"{EUR:10}\"} ] }",
         NULL),
 
-    /* This CMD will (1) successfully deposit `withdraw-coin-11a'
-     * and subsequently _fail_ to deposit `withdraw-coin-1',
-     * because of double spending.  The abort CMD then will try
-     * to get a refund permission out of that first coin that
-     * was regularly spent, and eventually abort refund CMD, will
-     * get the actual refund coin from the exchange.  */
-    TALER_TESTING_cmd_pay ("pay-fail-partial-double-11",
+    TALER_TESTING_cmd_pay ("pay-fail-partial-double-11-good",
+                           merchant_url,
+                           is->ctx,
+                           MHD_HTTP_NOT_ACCEPTABLE,
+                           "create-proposal-11",
+                           "withdraw-coin-11a",
+                           "EUR:5",
+                           "EUR:4.99",
+                           "EUR:0.01"),
+    TALER_TESTING_cmd_pay ("pay-fail-partial-double-11-bad",
                            merchant_url,
                            is->ctx,
                            MHD_HTTP_FORBIDDEN,
                            "create-proposal-11",
-                           "withdraw-coin-11a;withdraw-coin-1",
+                           "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",
+                                 "pay-fail-partial-double-11-good",
                                  is->ctx,
                                  MHD_HTTP_OK),
 
diff --git a/src/lib/test_merchant_api_twisted.c 
b/src/lib/test_merchant_api_twisted.c
index cd9adb9..09eb771 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -635,7 +635,7 @@ run (void *cls,
     TALER_TESTING_cmd_pay ("deposit-simple-for-abort",
                            twister_merchant_url,
                            is->ctx,
-                           0,
+                           MHD_HTTP_NOT_ACCEPTABLE,
                            "create-proposal-abort-1",
                            "withdraw-coin-abort-1",
                            "EUR:1",
diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c
index a1ed690..e6a5aa6 100644
--- a/src/lib/testing_api_cmd_pay.c
+++ b/src/lib/testing_api_cmd_pay.c
@@ -1422,7 +1422,8 @@ pay_again_cleanup (void *cls,
 /**
  * Make a "pay again" test command.  Its purpose is to
  * take all the data from a aborted "pay" CMD, and use
- * good coins to correctly pay for it.
+ * good coins - found in @a coin_reference - to correctly
+ * pay for it.
  *
  * @param label command label
  * @param merchant_url merchant base URL

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



reply via email to

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