gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] 01/02: Splitting pay CMD.


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] 01/02: Splitting pay CMD.
Date: Thu, 24 May 2018 15:56:20 +0200

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

marcello pushed a commit to branch master
in repository merchant.

commit afceb5b1c993b9429a620bec61b8eafc71ce144a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu May 24 12:02:26 2018 +0200

    Splitting pay CMD.
    
    The pay CMD used to be aborted in the _old_
    test case got split in two CMDs, one per coin,
    in order to make sure that the good coins is
    _always_ deposited before we abort and ask for
    refund.  This should fix #5330.
---
 src/lib/merchant_api_pay.c    |  4 ++++
 src/lib/test_merchant_api.c   | 43 +++++++++++++++++++++++++++++++++++++------
 src/lib/testing_api_cmd_pay.c |  3 ++-
 3 files changed, 43 insertions(+), 7 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/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]