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 (a607690 -> a54daf3)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (a607690 -> a54daf3)
Date: Mon, 26 Mar 2018 10:37:54 +0200

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

marcello pushed a change to branch master
in repository merchant.

    from a607690  make pay abort response unparsable.
     new 76736ce  fix confusion about reserve creation
     new 2bf5a09  putting tip-authorize into tests.
     new 4daf864  putting second tip-authorize under tests.
     new b97d4e7  putting tip-query under test.
     new ff6fba5  putting query with amounts under test.
     new 68436af  putting tip-pickup under test.
     new 49ff2d9  after pickup query under test.
     new db34b15  tip queries, before error generating authorize(s).
     new dfd4806  testing until last pickup ("too much" one)
     new 6d4afed  spending tip passes.
     new 938c7f0  extra bank checks (no pass now)
     new a54daf3  fix tipping test aftermath.

The 12 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/backend/taler-merchant-httpd_pay.c   |  11 +-
 src/include/taler_merchant_testing_lib.h |  84 +++++++++++++
 src/lib/test_merchant_api.c              |   3 +-
 src/lib/test_merchant_api_new.c          | 184 +++++++++++++++++++++++++++-
 src/lib/testing_api_cmd_refund.c         |  12 +-
 src/lib/testing_api_cmd_tip.c            | 202 +++++++++++++++++++++++++++++--
 6 files changed, 473 insertions(+), 23 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/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index c487edb..67ca40a 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -497,4 +497,88 @@ TALER_TESTING_get_trait_refund_entry
    unsigned int index,
    const struct TALER_MERCHANT_RefundEntry **refund_entry);
 
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_authorize_with_ec
+  (const char *label,
+   const char *merchant_url,
+   const char *exchange_url,
+   struct GNUNET_CURL_Context *ctx,
+   unsigned int http_status,
+   const char *instance,
+   const char *justification,
+   const char *amount,
+   enum TALER_ErrorCode ec);
+
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_authorize (const char *label,
+                                 const char *merchant_url,
+                                 const char *exchange_url,
+                                 struct GNUNET_CURL_Context *ctx,
+                                 unsigned int http_status,
+                                 const char *instance,
+                                 const char *justification,
+                                 const char *amount);
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_query (const char *label,
+                             const char *merchant_url,
+                             struct GNUNET_CURL_Context *ctx,
+                             unsigned int http_status,
+                             const char *instance);
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_query_with_amounts
+  (const char *label,
+   const char *merchant_url,
+   struct GNUNET_CURL_Context *ctx,
+   unsigned int http_status,
+   const char *instance,
+   const char *expected_amount_picked_up,
+   const char *expected_amount_authorized,
+   const char *expected_amount_available);
+
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_pickup_with_ec
+  (const char *label,
+   const char *merchant_url,
+   struct GNUNET_CURL_Context *ctx,
+   unsigned int http_status,
+   const char *authorize_reference,
+   const char **amounts,
+   struct TALER_EXCHANGE_Handle *exchange,
+   enum TALER_ErrorCode ec);
+
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_pickup
+  (const char *label,
+   const char *merchant_url,
+   struct GNUNET_CURL_Context *ctx,
+   unsigned int http_status,
+   const char *authorize_reference,
+   const char **amounts,
+   struct TALER_EXCHANGE_Handle *exchange);
+
+
 #endif
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 807376c..b552648 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -4533,7 +4533,7 @@ run (void *cls)
       .details.admin_add_incoming.credit_account_no = EXCHANGE_ACCOUNT_NO,
       .details.admin_add_incoming.auth_username = "user62",
       .details.admin_add_incoming.auth_password = "pass62",
-      /* we run *two* instances, but only this first call will
+      /* we run *two* __merchant__ instances, but only this first call will
          actually fill the reserve, as the second one will be seen as
          a duplicate. Hence fill with twice the require amount per
          round. */
@@ -4625,6 +4625,7 @@ run (void *cls)
       .details.tip_authorize.justification = "tip 5",
       .details.tip_authorize.amount = "EUR:5.01",
       .details.tip_authorize.expected_ec = 
TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP },
+
     { .oc = OC_TIP_PICKUP,
       .label = "pickup-tip-3-too-much",
       .expected_response_code = MHD_HTTP_CONFLICT,
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index 444636d..d063491 100644
--- a/src/lib/test_merchant_api_new.c
+++ b/src/lib/test_merchant_api_new.c
@@ -35,6 +35,7 @@
 #include <taler/taler_bank_service.h>
 #include <taler/taler_fakebank_lib.h>
 #include <taler/taler_testing_lib.h>
+#include <taler/taler_error_codes.h>
 #include "taler_merchant_testing_lib.h"
 
 /**
@@ -48,6 +49,8 @@
  */
 #define EXCHANGE_URL "http://localhost:8081/";
 
+static const char *pickup_amounts_1[] = {"EUR:5", NULL};
+
 /**
  * URL of the fakebank.  Obtained from CONFIG_FILE's
  * "exchange-wire-test:BANK_URI" option.
@@ -462,10 +465,11 @@ run (void *cls,
                                      "refund-increase-1",
                                      "deposit-simple",
                                      "1"),
-    /* test tipping */
+
+    /* Test tipping.  */
     TALER_TESTING_cmd_fakebank_transfer_with_instance
-      ("create-reserve-10",
-       "EUR:10.02",
+      ("create-reserve-tip-1",
+       "EUR:20.04",
        fakebank_url,
        USER_ACCOUNT_NO,
        EXCHANGE_ACCOUNT_NO,
@@ -476,6 +480,174 @@ run (void *cls,
        CONFIG_FILE),
 
 
+    CMD_EXEC_WIREWATCH ("wirewatch-3"),
+
+    TALER_TESTING_cmd_check_bank_transfer
+      ("check_bank_transfer-tip-1",
+       "http://localhost:8081/";,
+       "EUR:20.04", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO),
+
+    TALER_TESTING_cmd_tip_authorize ("authorize-tip-1",
+                                     merchant_url,
+                                     exchange_url,
+                                     is->ctx,
+                                     MHD_HTTP_OK,
+                                     "tip",
+                                     "tip 1",
+                                     "EUR:5.01"),
+
+    TALER_TESTING_cmd_tip_authorize ("authorize-tip-2",
+                                     merchant_url,
+                                     exchange_url,
+                                     is->ctx,
+                                     MHD_HTTP_OK,
+                                     "tip",
+                                     "tip 2",
+                                     "EUR:5.01"),
+
+    TALER_TESTING_cmd_tip_query ("query-tip-1",
+                                 merchant_url,
+                                 is->ctx,
+                                 MHD_HTTP_OK,
+                                 "tip"),
+
+    TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-2",
+                                              merchant_url,
+                                              is->ctx,
+                                              MHD_HTTP_OK,
+                                              "tip",
+                                              "EUR:0.0", // picked
+                                              "EUR:10.02", // auth
+                                              "EUR:20.04"),// ava
+
+    TALER_TESTING_cmd_tip_pickup ("pickup-tip-1",
+                                  merchant_url,
+                                  is->ctx,
+                                  MHD_HTTP_OK,
+                                  "authorize-tip-1",
+                                  pickup_amounts_1,
+                                  is->exchange),
+
+    TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-3",
+                                              merchant_url,
+                                              is->ctx,
+                                              MHD_HTTP_OK,
+                                              "tip",
+                                              "EUR:5.01", // picked
+                                              NULL, // auth
+                                              "EUR:15.03"),// ava
+
+    TALER_TESTING_cmd_tip_pickup ("pickup-tip-2",
+                                  merchant_url,
+                                  is->ctx,
+                                  MHD_HTTP_OK,
+                                  "authorize-tip-2",
+                                  pickup_amounts_1,
+                                  is->exchange),
+
+    TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-4",
+                                              merchant_url,
+                                              is->ctx,
+                                              MHD_HTTP_OK,
+                                              "tip",
+                                              "EUR:10.02", // pick
+                                              "EUR:10.02", // auth
+                                              "EUR:10.02"), // ava
+    TALER_TESTING_cmd_tip_authorize_with_ec
+      ("authorize-tip-3-insufficient-funds",
+       merchant_url,
+       exchange_url,
+       is->ctx,
+       MHD_HTTP_PRECONDITION_FAILED,
+       "dtip",
+       "tip 3",
+       "EUR:5.01",
+       TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS),
+
+    TALER_TESTING_cmd_tip_authorize_with_ec
+      ("authorize-tip-4-unknown-instance",
+       merchant_url,
+       exchange_url,
+       is->ctx,
+       MHD_HTTP_NOT_FOUND,
+       "unknown",
+       "tip 4",
+       "EUR:5.01",
+       TALER_EC_TIP_AUTHORIZE_INSTANCE_UNKNOWN),
+
+    TALER_TESTING_cmd_tip_authorize_with_ec
+      ("authorize-tip-5-notip-instance",
+       merchant_url,
+       exchange_url,
+       is->ctx,
+       MHD_HTTP_NOT_FOUND,
+       "default",
+       "tip 5",
+       "EUR:5.01",
+       TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP),
+
+
+    TALER_TESTING_cmd_tip_pickup_with_ec
+      ("pickup-tip-3-too-much",
+       merchant_url,
+       is->ctx,
+       MHD_HTTP_CONFLICT,
+       "authorize-tip-1",
+       pickup_amounts_1,
+       is->exchange,
+       TALER_EC_TIP_PICKUP_NO_FUNDS),
+
+    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
+
+    CMD_EXEC_AGGREGATOR ("aggregator-tip-1"),
+    TALER_TESTING_cmd_check_bank_transfer
+      ("check_bank_transfer-tip-498c",
+       "http://localhost:8081/";,
+       "EUR:4.98", EXCHANGE_ACCOUNT_NO, USER_ACCOUNT_NO),
+    TALER_TESTING_cmd_check_bank_empty
+      ("check_bank_empty-at-tips"),
+
+    /* pay again logic.  */
+    TALER_TESTING_cmd_fakebank_transfer
+      ("create-reserve-10",
+       "EUR:10.02",
+       fakebank_url,
+       USER_ACCOUNT_NO,
+       EXCHANGE_ACCOUNT_NO,
+       USER_LOGIN_NAME,
+       USER_LOGIN_PASS,
+       EXCHANGE_URL),
+
     CMD_EXEC_WIREWATCH ("wirewatch-10"),
 
     TALER_TESTING_cmd_check_bank_transfer
@@ -493,8 +665,6 @@ run (void *cls,
                                        "create-reserve-10",
                                        "EUR:5",
                                        MHD_HTTP_OK),
-
-
     TALER_TESTING_cmd_status ("withdraw-status-10",
                               is->exchange,
                               "create-reserve-10",
@@ -554,6 +724,7 @@ run (void *cls,
 
     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-10"),
 
+    /* pay abort */
     CMD_TRANSFER_TO_EXCHANGE ("create-reserve-11",
                               "EUR:10.02"),
 
@@ -686,7 +857,8 @@ main (int argc,
     ret = TALER_TESTING_setup_with_exchange (&run,
                                              NULL,
                                              CONFIG_FILE);
-    GNUNET_OS_process_kill (merchantd, SIGKILL); 
+
+    GNUNET_OS_process_kill (merchantd, SIGTERM); 
     GNUNET_OS_process_wait (merchantd); 
     GNUNET_OS_process_destroy (merchantd); 
     GNUNET_free (merchant_url);
diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c
index b85dcf6..7cae8c6 100644
--- a/src/lib/testing_api_cmd_refund.c
+++ b/src/lib/testing_api_cmd_refund.c
@@ -237,8 +237,8 @@ refund_lookup_cb (void *cls,
                        &h_coin_pub);
     GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put
       (map,
-       &h_coin_pub,
-       irefund_amount,
+       &h_coin_pub, // which
+       irefund_amount, // how much
        GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   };
 
@@ -265,7 +265,7 @@ refund_lookup_cb (void *cls,
 
     if ( NULL ==
        ( icoin_cmd = TALER_TESTING_interpreter_lookup_command
-         (rls->is, icoin_reference)))
+         (rls->is, icoin_reference)) )
     {
       GNUNET_break (0);
       TALER_LOG_ERROR ("Bad reference `%s'\n",
@@ -305,9 +305,9 @@ refund_lookup_cb (void *cls,
 
   GNUNET_free (coin_reference_dup);
   
-  if ( NULL ==
-     ( increase_cmd = TALER_TESTING_interpreter_lookup_command
-       (rls->is, rls->increase_reference)))
+  if (NULL ==
+    (increase_cmd = TALER_TESTING_interpreter_lookup_command
+      (rls->is, rls->increase_reference)))
     TALER_TESTING_FAIL (rls->is);
 
   if (GNUNET_OK != TALER_TESTING_get_trait_amount
diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c
index 111180a..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;
@@ -194,6 +208,37 @@ tip_authorize_cb (void *cls,
   TALER_TESTING_interpreter_next (tas->is);
 }
 
+/**
+ * Extract information from a command that is useful for other
+ * commands.
+ *
+ * @param cls closure
+ * @param ret[out] result (could be anything)
+ * @param trait name of the trait
+ * @param selector more detailed information about which object
+ *                 to return in case there were multiple generated
+ *                 by the command
+ * @return #GNUNET_OK on success
+ */
+static int
+tip_authorize_traits (void *cls,
+                      void **ret,
+                      const char *trait,
+                      unsigned int index)
+{
+  struct TipAuthorizeState *tas = cls;
+
+  struct TALER_TESTING_Trait traits[] = {
+    TALER_TESTING_make_trait_tip_id (0, &tas->tip_id),
+    TALER_TESTING_trait_end (),
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+  return GNUNET_SYSERR;
+}
 
 /**
  * Runs the command.  Note that upon return, the interpreter
@@ -256,8 +301,47 @@ tip_authorize_cleanup (void *cls,
  * FIXME
  */
 struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_authorize_with_ec
+  (const char *label,
+   const char *merchant_url,
+   const char *exchange_url,
+   struct GNUNET_CURL_Context *ctx,
+   unsigned int http_status,
+   const char *instance,
+   const char *justification,
+   const char *amount,
+   enum TALER_ErrorCode ec)
+{
+  struct TipAuthorizeState *tas;
+  struct TALER_TESTING_Command cmd;
+
+  tas = GNUNET_new (struct TipAuthorizeState);
+  tas->merchant_url = merchant_url;
+  tas->exchange_url = exchange_url;
+  tas->ctx = ctx;
+  tas->instance = instance;
+  tas->justification = justification;
+  tas->amount = amount;
+  tas->http_status = http_status;
+  tas->expected_ec = ec;
+
+  cmd.label = label;
+  cmd.cls = tas;
+  cmd.run = &tip_authorize_run;
+  cmd.cleanup = &tip_authorize_cleanup;
+  cmd.traits = &tip_authorize_traits;
+  
+  return cmd;
+}
+
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
 TALER_TESTING_cmd_tip_authorize (const char *label,
                                  const char *merchant_url,
+                                 const char *exchange_url,
                                  struct GNUNET_CURL_Context *ctx,
                                  unsigned int http_status,
                                  const char *instance,
@@ -269,6 +353,7 @@ TALER_TESTING_cmd_tip_authorize (const char *label,
 
   tas = GNUNET_new (struct TipAuthorizeState);
   tas->merchant_url = merchant_url;
+  tas->exchange_url = exchange_url;
   tas->ctx = ctx;
   tas->instance = instance;
   tas->justification = justification;
@@ -279,6 +364,7 @@ TALER_TESTING_cmd_tip_authorize (const char *label,
   cmd.cls = tas;
   cmd.run = &tip_authorize_run;
   cmd.cleanup = &tip_authorize_cleanup;
+  cmd.traits = &tip_authorize_traits;
   
   return cmd;
 }
@@ -397,6 +483,41 @@ tip_query_run (void *cls,
  * FIXME
  */
 struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_query_with_amounts
+  (const char *label,
+   const char *merchant_url,
+   struct GNUNET_CURL_Context *ctx,
+   unsigned int http_status,
+   const char *instance,
+   const char *expected_amount_picked_up,
+   const char *expected_amount_authorized,
+   const char *expected_amount_available)
+{
+  struct TipQueryState *tqs;
+  struct TALER_TESTING_Command cmd;
+
+  tqs = GNUNET_new (struct TipQueryState);
+  tqs->merchant_url = merchant_url;
+  tqs->ctx = ctx;
+  tqs->instance = instance;
+  tqs->http_status = http_status;
+  tqs->expected_amount_picked_up = expected_amount_picked_up;
+  tqs->expected_amount_authorized = expected_amount_authorized;
+  tqs->expected_amount_available = expected_amount_available;
+
+  cmd.cls = tqs;
+  cmd.label = label;
+  cmd.run = &tip_query_run;
+  cmd.cleanup = &tip_query_cleanup;
+  
+  return cmd;
+}
+
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
 TALER_TESTING_cmd_tip_query (const char *label,
                              const char *merchant_url,
                              struct GNUNET_CURL_Context *ctx,
@@ -410,6 +531,7 @@ TALER_TESTING_cmd_tip_query (const char *label,
   tqs->merchant_url = merchant_url;
   tqs->ctx = ctx;
   tqs->instance = instance;
+  tqs->http_status = http_status;
 
   cmd.cls = tqs;
   cmd.label = label;
@@ -555,7 +677,6 @@ pickup_cb (void *cls,
   if (num_reserve_sigs != tps->num_coins)
     TALER_TESTING_FAIL (tps->is);
 
-
   /* pickup successful, now withdraw! */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Obtained %u signatures for withdrawal"
@@ -595,14 +716,15 @@ tip_pickup_run (void *cls,
                 const struct TALER_TESTING_Command *cmd,
                 struct TALER_TESTING_Interpreter *is)
 {
+
   struct TipPickupState *tps = 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;
@@ -641,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);
 
@@ -696,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"
@@ -727,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,
@@ -745,6 +892,42 @@ tip_pickup_traits (void *cls,
  * FIXME
  */
 struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_pickup_with_ec
+  (const char *label,
+   const char *merchant_url,
+   struct GNUNET_CURL_Context *ctx,
+   unsigned int http_status,
+   const char *authorize_reference,
+   const char **amounts,
+   struct TALER_EXCHANGE_Handle *exchange,
+   enum TALER_ErrorCode ec)
+{
+  struct TipPickupState *tps;
+  struct TALER_TESTING_Command cmd;
+
+  tps = GNUNET_new (struct TipPickupState);
+  tps->merchant_url = merchant_url;
+  tps->ctx = ctx;
+  tps->authorize_reference = authorize_reference;
+  tps->amounts = amounts;
+  tps->exchange = exchange;
+  tps->http_status = http_status;
+  tps->expected_ec = ec;
+
+  cmd.cls = tps;
+  cmd.label = label;
+  cmd.run = &tip_pickup_run;
+  cmd.cleanup = &tip_pickup_cleanup;
+  cmd.traits = &tip_pickup_traits;
+  
+  return cmd;
+}
+
+
+/**
+ * FIXME
+ */
+struct TALER_TESTING_Command
 TALER_TESTING_cmd_tip_pickup
   (const char *label,
    const char *merchant_url,
@@ -763,6 +946,7 @@ TALER_TESTING_cmd_tip_pickup
   tps->authorize_reference = authorize_reference;
   tps->amounts = amounts;
   tps->exchange = exchange;
+  tps->http_status = http_status;
 
   cmd.cls = tps;
   cmd.label = 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]