gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 15/24: fix trait usage


From: gnunet
Subject: [taler-merchant] 15/24: fix trait usage
Date: Wed, 17 Nov 2021 12:44:38 +0100

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

grothoff pushed a commit to branch master
in repository merchant.

commit 874a89a648c9f06e54a9e5a3bdc987a87ef8247b
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Nov 4 21:02:35 2021 +0100

    fix trait usage
---
 src/testing/testing_api_cmd_merchant_get_tip.c | 18 ++++-----
 src/testing/testing_api_cmd_tip_pickup.c       | 53 ++++++++++++--------------
 2 files changed, 33 insertions(+), 38 deletions(-)

diff --git a/src/testing/testing_api_cmd_merchant_get_tip.c 
b/src/testing/testing_api_cmd_merchant_get_tip.c
index 791fc731..81be677d 100644
--- a/src/testing/testing_api_cmd_merchant_get_tip.c
+++ b/src/testing/testing_api_cmd_merchant_get_tip.c
@@ -210,15 +210,13 @@ merchant_get_tip_cb (void *cls,
           const struct TALER_Amount *total;
 
           if (GNUNET_OK !=
-              TALER_TESTING_get_trait_amounts (pickup_cmd,
-                                               pickups[i].num_planchets,
-                                               &total))
+              TALER_TESTING_get_trait_amount (pickup_cmd,
+                                              &total))
             TALER_TESTING_FAIL (gts->is);
 
           if ( (GNUNET_OK !=
                 TALER_amount_cmp_currency (total,
-                                           &pickups[i].
-                                           requested_amount)) ||
+                                           &pickups[i].requested_amount)) ||
                (0 != TALER_amount_cmp (total,
                                        &pickups[i].requested_amount)))
           {
@@ -232,10 +230,12 @@ merchant_get_tip_cb (void *cls,
                                                total));
         }
       }
-      if ((GNUNET_OK != TALER_amount_cmp_currency (&expected_total_picked_up,
-                                                   total_picked_up)) ||
-          (0 != TALER_amount_cmp (&expected_total_picked_up,
-                                  total_picked_up)))
+      if ( (GNUNET_OK !=
+            TALER_amount_cmp_currency (&expected_total_picked_up,
+                                       total_picked_up)) ||
+           (0 !=
+            TALER_amount_cmp (&expected_total_picked_up,
+                              total_picked_up)) )
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                     "Tip picked up amount does not match\n");
diff --git a/src/testing/testing_api_cmd_tip_pickup.c 
b/src/testing/testing_api_cmd_tip_pickup.c
index 1c72f02b..cd73c53d 100644
--- a/src/testing/testing_api_cmd_tip_pickup.c
+++ b/src/testing/testing_api_cmd_tip_pickup.c
@@ -323,44 +323,39 @@ tip_pickup_cleanup (void *cls,
 }
 
 
-static int
+static enum GNUNET_GenericReturnValue
 tip_pickup_traits (void *cls,
                    const void **ret,
                    const char *trait,
                    unsigned int index)
 {
   struct TipPickupState *tps = cls;
-  #define NUM_TRAITS (tps->num_coins * 5) + 4
-  struct TALER_TESTING_Trait traits[NUM_TRAITS];
 
-  for (unsigned int i = 0; i<tps->num_coins; i++)
+  if (index >= tps->num_coins)
+    return GNUNET_SYSERR;
   {
-    traits[i] = TALER_TESTING_make_trait_planchet_secrets (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_amounts (i,
-                                        &tps->amounts_obj[i]);
+    struct TALER_TESTING_Trait traits[] = {
+      TALER_TESTING_make_trait_planchet_secrets (index,
+                                                 &tps->psa[index]),
+      TALER_TESTING_make_trait_coin_priv (index,
+                                          &tps->psa[index].coin_priv),
+      TALER_TESTING_make_trait_denom_pub (index,
+                                          tps->dks[index]),
+      TALER_TESTING_make_trait_denom_sig (index,
+                                          &tps->sigs[index]),
+      TALER_TESTING_make_trait_amounts (index,
+                                        &tps->amounts_obj[index]),
+      TALER_TESTING_make_trait_amount (&tps->total_amount),
+      TALER_TESTING_make_trait_num_planchets (&tps->num_coins),
+      TALER_TESTING_make_trait_exchange_url (&tps->exchange_url),
+      TALER_TESTING_trait_end ()
+    };
+
+    return TALER_TESTING_get_trait (traits,
+                                    ret,
+                                    trait,
+                                    index);
   }
-  traits[NUM_TRAITS - 4]
-    = TALER_TESTING_make_trait_amount (&tps->total_amount);
-  traits[NUM_TRAITS - 3]
-    = TALER_TESTING_make_trait_num_planchets (&tps->num_coins);
-  traits[NUM_TRAITS - 2]
-    = TALER_TESTING_make_trait_exchange_url (&tps->exchange_url);
-  traits[NUM_TRAITS - 1] = TALER_TESTING_trait_end ();
-  return TALER_TESTING_get_trait (traits,
-                                  ret,
-                                  trait,
-                                  index);
 }
 
 

-- 
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]