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 (3b2b43c -> 15ff300)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (3b2b43c -> 15ff300)
Date: Wed, 05 Jul 2017 12:17:25 +0200

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

marcello pushed a change to branch master
in repository merchant.

    from 3b2b43c  merge conflict resolution
     new 71d4d4c  moving definitions to header file
     new 15ff300  Finishing #5087.

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:
 doc/version.texi                          |  2 +-
 src/backend/taler-merchant-httpd_refund.c | 27 +---------
 src/backend/taler-merchant-httpd_refund.h | 20 +++++++
 src/lib/Makefile.am                       |  2 +-
 src/lib/test_merchant_api.c               | 87 +++++++++++++++----------------
 5 files changed, 66 insertions(+), 72 deletions(-)

diff --git a/doc/version.texi b/doc/version.texi
index 2a18a25..fc2400a 100644
--- a/doc/version.texi
+++ b/doc/version.texi
@@ -1,4 +1,4 @@
address@hidden UPDATED 2 June 2017
address@hidden UPDATED 7 June 2017
 @set UPDATED-MONTH June 2017
 @set EDITION 0.3.0
 @set VERSION 0.3.0
diff --git a/src/backend/taler-merchant-httpd_refund.c 
b/src/backend/taler-merchant-httpd_refund.c
index b196870..ba79bf9 100644
--- a/src/backend/taler-merchant-httpd_refund.c
+++ b/src/backend/taler-merchant-httpd_refund.c
@@ -25,9 +25,7 @@
 #include "taler-merchant-httpd.h"
 #include "taler-merchant-httpd_parsing.h"
 #include "taler-merchant-httpd_responses.h"
-
-#define REFUND_CONFIRMATION 0
-
+#include "taler-merchant-httpd_refund.h"
 
 /**
  * How often do we retry the non-trivial refund INSERT database
@@ -35,27 +33,6 @@
  */
 #define MAX_RETRIES 5
 
-
-/**
- * We confirm with a signature that the refund has been successfully
- * done. Even though the frontend doesn't usually do crypto, this signature
- * may turn useful in court.
- */
-struct RefundConfirmationP
-{
-  
-  /**
-   * Purpose is simply set to zero, see macro REFUND_CONFIRMATION above
-   */
-  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
-  /**
-   * Hashing the order id, as frontends don't handle contract terms
-   */
-  struct GNUNET_HashCode h_order_id GNUNET_PACKED;
-
-};
-
 struct ProcessRefundData
 {
   /**
@@ -286,7 +263,7 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
   json_decref (root);
   GNUNET_JSON_parse_free (spec);
 
-  confirmation.purpose.purpose = REFUND_CONFIRMATION;
+  confirmation.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND_OK);
   confirmation.purpose.size = htonl (sizeof (struct RefundConfirmationP));
 
   if (GNUNET_OK !=
diff --git a/src/backend/taler-merchant-httpd_refund.h 
b/src/backend/taler-merchant-httpd_refund.h
index 64da3f9..c19d69e 100644
--- a/src/backend/taler-merchant-httpd_refund.h
+++ b/src/backend/taler-merchant-httpd_refund.h
@@ -26,6 +26,26 @@
 #include "taler-merchant-httpd.h"
 
 /**
+ * We confirm with a signature that the refund has been successfully
+ * done. Even though the frontend doesn't usually do crypto, this signature
+ * may turn useful in court.
+ */
+struct RefundConfirmationP
+{
+  
+  /**
+   * Set to TALER_SIGNATURE_MERCHANT_REFUND_OK.
+   */
+  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+  /**
+   * Hashing the order id, as frontends don't handle contract terms
+   */
+  struct GNUNET_HashCode h_order_id GNUNET_PACKED;
+
+};
+
+/**
  * Handle request for increasing the refund associated with
  * a contract.
  *
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 1955dd7..aebf74b 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -1,5 +1,5 @@
 # This Makefile.am is in the public domain
-AM_CPPFLAGS = -I$(top_srcdir)/src/include
+AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/backend
 
 if USE_COVERAGE
   AM_CFLAGS = --coverage -O0
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 1b1968b..f7fe943 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -26,6 +26,7 @@
 #include <taler/taler_util.h>
 #include <taler/taler_signatures.h>
 #include "taler_merchant_service.h"
+#include "taler-merchant-httpd_refund.h"
 #include "taler_merchantdb_lib.h"
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet/gnunet_curl_lib.h>
@@ -1242,25 +1243,14 @@ refund_lookup_cb (void *cls,
   const struct Command *increase_ref;
   const struct Command *coin_ref;
   struct TALER_Amount refund_amount;
-  struct TALER_Amount resp_refund_amount;
   struct TALER_Amount refund_fee;
-  struct TALER_Amount resp_refund_fee;
   struct TALER_Amount coin_amount;
   struct TALER_CoinSpendPublicKeyP coin_pub;
-  struct TALER_CoinSpendPublicKeyP resp_coin_pub;
-  struct GNUNET_CRYPTO_EddsaPublicKey merchant_pub;
-  struct GNUNET_CRYPTO_EddsaPublicKey resp_merchant_pub;
+  struct TALER_MerchantPublicKeyP merchant_pub;
   struct json_t *resp_element;
-  const char *error_name;
-  unsigned int error_line;
-
-  struct GNUNET_JSON_Specification spec[] = {
-   GNUNET_JSON_spec_fixed_auto ("coin_pub", &resp_coin_pub),
-   GNUNET_JSON_spec_fixed_auto ("merchant_pub", &resp_merchant_pub),
-   TALER_JSON_spec_amount ("refund_amount", &resp_refund_amount),
-   TALER_JSON_spec_amount ("refund_fee", &resp_refund_fee),
-   GNUNET_JSON_spec_end ()  
-  };
+  struct json_t *mock_element;
+  struct TALER_RefundRequestPS rr;
+  struct GNUNET_CRYPTO_EddsaSignature sig;
 
   if (MHD_HTTP_OK != http_status)
   {
@@ -1270,10 +1260,6 @@ refund_lookup_cb (void *cls,
     return;
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "/refund lookup:\n%s\n",
-              json_dumps (obj, JSON_INDENT (2)));
-
   increase_ref = find_command (is, cmd->details.refund_lookup.increase_ref);
   GNUNET_assert (NULL != increase_ref);
 
@@ -1300,31 +1286,44 @@ refund_lookup_cb (void *cls,
 
   GNUNET_assert (NULL != (resp_element = json_array_get (obj, 0)));
   
-  GNUNET_assert (GNUNET_OK == GNUNET_JSON_parse (resp_element,
-                                                 spec,
-                                                 &error_name,
-                                                 &error_line));
   GNUNET_CRYPTO_eddsa_key_get_public (instance_priv,
-                                      &merchant_pub);
-
-  if (0 != memcmp (&refund_amount,
-                   &resp_refund_amount,
-                   sizeof (struct TALER_Amount)) ||
-      0 != memcmp (&refund_fee,
-                   &resp_refund_fee,
-                   sizeof (struct TALER_Amount)) ||
-      0 != memcmp (&coin_pub,
-                   &resp_coin_pub,
-                   sizeof (struct TALER_CoinSpendPublicKeyP)) ||
-      0 != memcmp (&merchant_pub,
-                   &resp_merchant_pub,
-                   sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
-  /*FIXME: match doable with json_equal() now!*/
+                                      &merchant_pub.eddsa_pub);
+
+  rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND);
+  rr.purpose.size = htonl (sizeof (struct TALER_RefundRequestPS));
+
+  rr.h_contract_terms = pay_ref->details.pay.h_contract_terms;
+  rr.coin_pub = coin_pub;
+  rr.merchant = merchant_pub;
+  rr.rtransaction_id = GNUNET_htonll (instance_idx + 1);
+  TALER_amount_hton (&rr.refund_amount,
+                     &refund_amount);
+  TALER_amount_hton (&rr.refund_fee,
+                     &refund_fee);
+
+  GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (instance_priv,
+                                                        &rr.purpose,
+                                                        &sig));
+  GNUNET_assert (NULL != (mock_element = json_pack ("{s:o, s:o, s:o, s:o, s:o, 
s:I, s:o}",
+                  "coin_pub", GNUNET_JSON_from_data_auto (&coin_pub),
+                  "merchant_pub", GNUNET_JSON_from_data_auto (&merchant_pub),
+                  "refund_amount", TALER_JSON_from_amount (&refund_amount),
+                  "refund_fee", TALER_JSON_from_amount (&refund_fee),
+                  "h_contract_terms", GNUNET_JSON_from_data_auto 
(&pay_ref->details.pay.h_contract_terms),
+                  "rtransaction_id", (json_int_t) instance_idx + 1,
+                  "merchant_sig", GNUNET_JSON_from_data_auto (&sig))));
+
+  if (1 != json_equal (mock_element, resp_element))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
-                "Bad refund given\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Got unexpected refund\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "resp: %s\n",
+                json_dumps (resp_element, JSON_INDENT (2)));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "mock: %s\n",
+                json_dumps (mock_element, JSON_INDENT (2)));
     fail (is);
-  
   }
 
   cmd->details.refund_lookup.rlo = NULL;
@@ -1332,7 +1331,6 @@ refund_lookup_cb (void *cls,
 }
 
 
-
 /**
  * Function called with the result of a /pay operation.
  *
@@ -1353,7 +1351,6 @@ pay_cb (void *cls,
   struct Command *cmd = &is->commands[is->ip];
   struct PaymentResponsePS mr;
   struct GNUNET_CRYPTO_EddsaSignature sig;
-  struct GNUNET_HashCode h_contract_terms;
   const char *error_name;
   unsigned int error_line;
 
@@ -1373,7 +1370,7 @@ pay_cb (void *cls,
     /* Check signature */
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_fixed_auto ("sig", &sig),
-      GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &h_contract_terms),
+      GNUNET_JSON_spec_fixed_auto ("h_contract_terms", 
&cmd->details.pay.h_contract_terms),
       GNUNET_JSON_spec_end ()
     };
     if (GNUNET_OK !=
@@ -1392,7 +1389,7 @@ pay_cb (void *cls,
     }
     mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
     mr.purpose.size = htonl (sizeof (mr));
-    mr.h_contract_terms = h_contract_terms;
+    mr.h_contract_terms = cmd->details.pay.h_contract_terms;
     if (GNUNET_OK !=
         GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
                                     &mr.purpose,

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



reply via email to

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