gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 249/277: made a testing trait for order claim nonce


From: gnunet
Subject: [taler-merchant] 249/277: made a testing trait for order claim nonce
Date: Sun, 05 Jul 2020 20:52:42 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit ebfa7888c0cbb461cf70a8d809b1d183011713ce
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Wed Jun 24 00:08:31 2020 -0400

    made a testing trait for order claim nonce
---
 src/include/taler_merchant_testing_lib.h    | 31 ++++++++++++
 src/testing/Makefile.am                     |  1 +
 src/testing/testing_api_cmd_claim_order.c   | 13 +++--
 src/testing/testing_api_cmd_post_orders.c   |  7 +--
 src/testing/testing_api_trait_claim_nonce.c | 76 +++++++++++++++++++++++++++++
 5 files changed, 116 insertions(+), 12 deletions(-)

diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index af14955..3ae227c 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -1243,6 +1243,37 @@ TALER_TESTING_get_trait_merchant_sig (
   struct TALER_MerchantSignatureP **merchant_sig);
 
 
+/**
+ * Offer an order claim nonce.
+ *
+ * @param index which nonce to offer if there are
+ *        multiple on offer.
+ * @param nonce set to the offered nonce.
+ * @return the trait
+ */
+struct TALER_TESTING_Trait
+TALER_TESTING_make_trait_claim_nonce (unsigned int index,
+                                      const struct
+                                      GNUNET_CRYPTO_EddsaPublicKey *nonce);
+
+
+/**
+ * Obtain an order claim nonce from a @a cmd.
+ *
+ * @param cmd command to extract the trait from.
+ * @param index which nonce to pick if @a
+ *        cmd has multiple on offer
+ * @param nonce[out] set to the wanted data.
+ *
+ * @return #GNUNET_OK on success
+ */
+int
+TALER_TESTING_get_trait_claim_nonce (const struct TALER_TESTING_Command *cmd,
+                                     unsigned int index,
+                                     const struct
+                                     GNUNET_CRYPTO_EddsaPublicKey **nonce);
+
+
 /**
  * Obtain a reference to a proposal command.  Any command that
  * works with proposals, might need to offer their reference to
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 1c9fcb2..6e52b33 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -49,6 +49,7 @@ libtalermerchanttesting_la_SOURCES = \
   testing_api_cmd_wallet_get_order.c \
   testing_api_cmd_wallet_get_tip.c \
   testing_api_helpers.c \
+  testing_api_trait_claim_nonce.c \
   testing_api_trait_merchant_sig.c \
   testing_api_trait_string.c \
   testing_api_trait_hash.c \
diff --git a/src/testing/testing_api_cmd_claim_order.c 
b/src/testing/testing_api_cmd_claim_order.c
index 0cdfff0..f47ddcc 100644
--- a/src/testing/testing_api_cmd_claim_order.c
+++ b/src/testing/testing_api_cmd_claim_order.c
@@ -186,11 +186,9 @@ order_claim_run (void *cls,
 {
   struct OrderClaimState *pls = cls;
   const char *order_id;
-  const struct TALER_MerchantPublicKeyP *nonce;
+  const struct GNUNET_CRYPTO_EddsaPublicKey *nonce;
   /* Only used if we do NOT use the nonce from traits.  */
-  struct TALER_MerchantPublicKeyP dummy_nonce;
-#define GET_TRAIT_NONCE(cmd,ptr) \
-  TALER_TESTING_get_trait_merchant_pub (cmd, 1, ptr)
+  struct GNUNET_CRYPTO_EddsaPublicKey dummy_nonce;
 
   pls->is = is;
   if (NULL != pls->order_id)
@@ -211,8 +209,9 @@ order_claim_run (void *cls,
     if (NULL == order_cmd)
       TALER_TESTING_FAIL (is);
     if (GNUNET_OK !=
-        GET_TRAIT_NONCE (order_cmd,
-                         &nonce))
+        TALER_TESTING_get_trait_claim_nonce (order_cmd,
+                                             0,
+                                             &nonce))
     {
       GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
                                   &dummy_nonce,
@@ -229,7 +228,7 @@ order_claim_run (void *cls,
   pls->och = TALER_MERCHANT_order_claim (is->ctx,
                                          pls->merchant_url,
                                          order_id,
-                                         &nonce->eddsa_pub,
+                                         nonce,
                                          &order_claim_cb,
                                          pls);
   GNUNET_assert (NULL != pls->och);
diff --git a/src/testing/testing_api_cmd_post_orders.c 
b/src/testing/testing_api_cmd_post_orders.c
index 8bdd786..8e1cc3f 100644
--- a/src/testing/testing_api_cmd_post_orders.c
+++ b/src/testing/testing_api_cmd_post_orders.c
@@ -115,17 +115,14 @@ orders_traits (void *cls,
                unsigned int index)
 {
   struct OrdersState *ps = cls;
-  // FIXME: wtf is this?
-#define MAKE_TRAIT_NONCE(ptr)  \
-  TALER_TESTING_make_trait_merchant_pub ( \
-    1, (struct TALER_MerchantPublicKeyP *) (ptr))
+
   struct TALER_TESTING_Trait traits[] = {
     TALER_TESTING_make_trait_order_id (0, ps->order_id),
     TALER_TESTING_make_trait_contract_terms (0, ps->contract_terms),
     TALER_TESTING_make_trait_h_contract_terms (0, &ps->h_contract_terms),
     TALER_TESTING_make_trait_merchant_sig (0, &ps->merchant_sig),
     TALER_TESTING_make_trait_merchant_pub (0, &ps->merchant_pub),
-    MAKE_TRAIT_NONCE (&ps->nonce),
+    TALER_TESTING_make_trait_claim_nonce (0, &ps->nonce),
     TALER_TESTING_trait_end ()
   };
 
diff --git a/src/testing/testing_api_trait_claim_nonce.c 
b/src/testing/testing_api_trait_claim_nonce.c
new file mode 100644
index 0000000..9649479
--- /dev/null
+++ b/src/testing/testing_api_trait_claim_nonce.c
@@ -0,0 +1,76 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2020 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as
+  published by the Free Software Foundation; either version 3, or
+  (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public
+  License along with TALER; see the file COPYING.  If not, see
+  <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file lib/testing_api_trait_claim_nonce.c
+ * @brief offer a trait that is the nonce used to claim an order.
+ * @author Jonathan Buchanan
+ */
+#include "platform.h"
+#include <taler/taler_signatures.h>
+#include <taler/taler_exchange_service.h>
+#include <taler/taler_testing_lib.h>
+
+#define TALER_TESTING_TRAIT_CLAIM_NONCE "nonce"
+
+/**
+ * Obtain an order claim nonce from a @a cmd.
+ *
+ * @param cmd command to extract the trait from.
+ * @param index which nonce to pick if @a
+ *        cmd has multiple on offer
+ * @param nonce[out] set to the wanted data.
+ *
+ * @return #GNUNET_OK on success
+ */
+int
+TALER_TESTING_get_trait_claim_nonce
+  (const struct TALER_TESTING_Command *cmd,
+  unsigned int index,
+  const struct GNUNET_CRYPTO_EddsaPublicKey **nonce)
+{
+  return cmd->traits (cmd->cls,
+                      (const void **) nonce,
+                      TALER_TESTING_TRAIT_CLAIM_NONCE,
+                      index);
+}
+
+
+/**
+ * Offer an order claim nonce.
+ *
+ * @param index which nonce to offer if there are
+ *        multiple on offer.
+ * @param nonce set to the offered nonce.
+ * @return the trait
+ */
+struct TALER_TESTING_Trait
+TALER_TESTING_make_trait_claim_nonce
+  (unsigned int index,
+  const struct GNUNET_CRYPTO_EddsaPublicKey *nonce)
+{
+  struct TALER_TESTING_Trait ret = {
+    .index = index,
+    .trait_name = TALER_TESTING_TRAIT_CLAIM_NONCE,
+    .ptr = (const void *) nonce
+  };
+  return ret;
+}
+
+
+/* end of testing_api_trait_claim_nonce.c */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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