gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] 10/12: spending tip passes.


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] 10/12: spending tip passes.
Date: Mon, 26 Mar 2018 10:38:04 +0200

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

marcello pushed a commit to branch master
in repository merchant.

commit 6d4afede86554e04fe87446a68df541234c870f3
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Mar 23 16:16:55 2018 +0100

    spending tip passes.
---
 src/backend/taler-merchant-httpd_pay.c | 11 ++++++-
 src/lib/test_merchant_api_new.c        | 35 +++++++++++++++++++++-
 src/lib/testing_api_cmd_tip.c          | 55 +++++++++++++++++++++++++++++-----
 3 files changed, 91 insertions(+), 10 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_pay.c 
b/src/backend/taler-merchant-httpd_pay.c
index 3ac4f39..e2b2b06 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -717,7 +717,9 @@ check_payment_sufficient (struct PayContext *pc)
                 TALER_amount_subtract (&acc_amount,
                                        &acc_amount,
                                        &pc->total_refunded));
-
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Subtracting total refunds from paid amount: %s\n",
+              TALER_amount_to_string (&pc->total_refunded));
   /* Now check that the customer paid enough for the full contract */
   if (-1 == TALER_amount_cmp (&pc->max_fee,
                               &acc_fee))
@@ -775,6 +777,9 @@ check_payment_sufficient (struct PayContext *pc)
                                             &wire_fee_customer_contribution,
                                             &deposit_fee_savings));
       /* subtract remaining wire fees from total contribution */
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  "Subtract remaining wire fees from total contribution: %s",
+                  TALER_amount_to_string (&wire_fee_customer_contribution));
       if (GNUNET_SYSERR ==
           TALER_amount_subtract (&acc_amount,
                                  &acc_amount,
@@ -790,6 +795,10 @@ check_payment_sufficient (struct PayContext *pc)
                                 &pc->amount))
     {
       GNUNET_break_op (0);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "price vs. sent: %s vs. %s\n",
+                  TALER_amount_to_string (&pc->amount),
+                  TALER_amount_to_string (&acc_amount));
       return TALER_EC_PAY_PAYMENT_INSUFFICIENT;
     }
   }
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index 2b6ad91..e83e100 100644
--- a/src/lib/test_merchant_api_new.c
+++ b/src/lib/test_merchant_api_new.c
@@ -592,6 +592,40 @@ run (void *cls,
        is->exchange,
        TALER_EC_TIP_PICKUP_NO_FUNDS),
 
+    // TALER_TESTING_cmd_end (),
+
+    TALER_TESTING_cmd_proposal
+      ("create-proposal-tip-1",
+       merchant_url,
+       is->ctx,
+       MHD_HTTP_OK,
+       "{\"max_fee\":\
+          {\"currency\":\"EUR\",\
+           \"value\":0,\
+           \"fraction\":50000000},\
+        \"order_id\":\"1-tip\",\
+        \"refund_deadline\":\"\\/Date(0)\\/\",\
+        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"amount\":\
+          {\"currency\":\"EUR\",\
+           \"value\":5,\
+           \"fraction\":0},\
+        \"summary\": \"useful product\",\
+        \"fulfillment_url\": \"https://example.com/\",\
+        \"products\": [ {\"description\":\"ice cream\",\
+                         \"value\":\"{EUR:5}\"} ] }",
+        NULL),
+
+    TALER_TESTING_cmd_pay ("deposit-tip-simple",
+                           merchant_url,
+                           is->ctx,
+                           MHD_HTTP_OK,
+                           "create-proposal-tip-1",
+                           "pickup-tip-1",
+                           "EUR:5", // amount + fee
+                           "EUR:4.99", // amount - fee
+                           "EUR:0.01"), // refund fee
+
     /* Will fail here until all new
      * transfers have not been checked.  I.e.,
      * there is now a 20.04 euro "pending" transfer.  */
@@ -607,7 +641,6 @@ run (void *cls,
        USER_LOGIN_PASS,
        EXCHANGE_URL),
 
-
     CMD_EXEC_WIREWATCH ("wirewatch-10"),
 
     TALER_TESTING_cmd_check_bank_transfer
diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c
index c784dbc..b04db4e 100644
--- a/src/lib/testing_api_cmd_tip.c
+++ b/src/lib/testing_api_cmd_tip.c
@@ -29,11 +29,23 @@
 #include "taler_merchant_service.h"
 #include "taler_merchant_testing_lib.h"
 
+/**
+ * Obtain the URL to use for an API request.
+ *
+ * @param h the exchange handle to query
+ * @param path Taler API path (i.e. "/reserve/withdraw")
+ * @return the full URL to use with cURL
+ */
+char *
+MAH_path_to_url (struct TALER_EXCHANGE_Handle *h,
+                 const char *path);
 
 struct TipPickupState
 {
   const char *merchant_url;
 
+  const char *exchange_url;
+
   struct GNUNET_CURL_Context *ctx;
 
   unsigned int http_status;
@@ -52,6 +64,8 @@ struct TipPickupState
 
   const char **amounts;
 
+  struct TALER_Amount *amounts_obj;
+
   unsigned int num_coins;
   
   const struct TALER_EXCHANGE_DenomPublicKey **dks;
@@ -707,10 +721,10 @@ tip_pickup_run (void *cls,
   unsigned int num_planchets;
   const struct TALER_TESTING_Command *replay_cmd;
   const struct TALER_TESTING_Command *authorize_cmd;
-  struct TALER_Amount amount;
   const struct GNUNET_HashCode *tip_id;
 
   tps->is = is;
+  tps->exchange_url = MAH_path_to_url (tps->exchange, "/");
   if (NULL == tps->replay_reference)
   {
     replay_cmd = NULL;
@@ -749,15 +763,20 @@ tip_pickup_run (void *cls,
       (num_planchets,
        const struct TALER_EXCHANGE_DenomPublicKey *);
 
+    tps->amounts_obj = GNUNET_new_array
+      (num_planchets, struct TALER_Amount);
+
     for (unsigned int i=0;i<num_planchets;i++)
     {
       if (NULL == replay_cmd)
       {
         GNUNET_assert (GNUNET_OK == TALER_string_to_amount
-          (tps->amounts[i], &amount));
+          (tps->amounts[i], &tps->amounts_obj[i]));
+
+        tps->dks[i] = TALER_TESTING_find_pk
+          (is->keys,
+           &tps->amounts_obj[i]);
 
-        tps->dks[i] = TALER_TESTING_find_pk (is->keys,
-                                             &amount);
         if (NULL == tps->dks[i])
           TALER_TESTING_FAIL (is);
 
@@ -804,7 +823,7 @@ tip_pickup_cleanup (void *cls,
                     const struct TALER_TESTING_Command *cmd)
 {
   struct TipPickupState *tps = cls;
-
+  #warning free elements *in* the state!
   if (NULL != tps->tpo)
   {
     TALER_LOG_WARNING ("Tip-pickup operation"
@@ -835,12 +854,32 @@ tip_pickup_traits (void *cls,
                    unsigned int index)
 {
   struct TipPickupState *tps = cls;
-  struct TALER_TESTING_Trait traits[tps->num_coins + 1];
+  #define NUM_TRAITS (tps->num_coins * 5) + 2
+  struct TALER_TESTING_Trait traits[NUM_TRAITS];
   
   for (unsigned int i=0; i<tps->num_coins; i++)
+  {
     traits[i] = TALER_TESTING_make_trait_planchet_secrets
-      (0, &tps->psa[i]);
-  traits[tps->num_coins + 1] = TALER_TESTING_trait_end ();
+      (i, &tps->psa[i]);
+
+    traits[i + tps->num_coins] =
+      TALER_TESTING_make_trait_coin_priv
+        (i, &tps->psa[i].coin_priv);
+
+    traits[i + (tps->num_coins * 2)] =
+      TALER_TESTING_make_trait_denom_pub (i, tps->dks[i]);
+
+    traits[i + (tps->num_coins *3)] =
+      TALER_TESTING_make_trait_denom_sig (i, &tps->sigs[i]);
+
+    traits[i + (tps->num_coins *4)] =
+      TALER_TESTING_make_trait_amount_obj
+        (i, &tps->amounts_obj[i]);
+
+  }
+  traits[NUM_TRAITS - 2] = TALER_TESTING_make_trait_url
+    (0, tps->exchange_url);
+  traits[NUM_TRAITS - 1] = TALER_TESTING_trait_end ();
 
   return TALER_TESTING_get_trait (traits,
                                   ret,

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



reply via email to

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