gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: add support for purse deposits i


From: gnunet
Subject: [taler-exchange] branch master updated: add support for purse deposits in coin history checking
Date: Thu, 09 Nov 2023 22:27:27 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 41780a7f add support for purse deposits in coin history checking
41780a7f is described below

commit 41780a7f4ad1e4d68c57ca10f6521b89156772d6
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Thu Nov 9 22:27:20 2023 +0100

    add support for purse deposits in coin history checking
---
 src/lib/exchange_api_coins_history.c        | 13 +++---
 src/testing/testing_api_cmd_coin_history.c  | 10 +++--
 src/testing/testing_api_cmd_purse_deposit.c | 67 +++++++++++++++++++++--------
 3 files changed, 62 insertions(+), 28 deletions(-)

diff --git a/src/lib/exchange_api_coins_history.c 
b/src/lib/exchange_api_coins_history.c
index b74e1a9b..875a5b57 100644
--- a/src/lib/exchange_api_coins_history.c
+++ b/src/lib/exchange_api_coins_history.c
@@ -802,11 +802,10 @@ TALER_EXCHANGE_parse_coin_history (
     json_t *transaction = json_array_get (history,
                                           off);
     enum GNUNET_GenericReturnValue add;
-    struct TALER_Amount amount;
     const char *type;
     struct GNUNET_JSON_Specification spec_glob[] = {
       TALER_JSON_spec_amount_any ("amount",
-                                  &amount),
+                                  &rh->amount),
       GNUNET_JSON_spec_string ("type",
                                &type),
       GNUNET_JSON_spec_end ()
@@ -821,7 +820,7 @@ TALER_EXCHANGE_parse_coin_history (
       return GNUNET_SYSERR;
     }
     if (GNUNET_YES !=
-        TALER_amount_cmp_currency (&amount,
+        TALER_amount_cmp_currency (&rh->amount,
                                    total_in))
     {
       GNUNET_break_op (0);
@@ -830,7 +829,7 @@ TALER_EXCHANGE_parse_coin_history (
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Operation of type %s with amount %s\n",
                 type,
-                TALER_amount2s (&amount));
+                TALER_amount2s (&rh->amount));
     add = GNUNET_SYSERR;
     for (unsigned int i = 0; NULL != map[i].type; i++)
     {
@@ -840,7 +839,7 @@ TALER_EXCHANGE_parse_coin_history (
         rh->type = map[i].ctt;
         add = map[i].helper (&pc,
                              rh,
-                             &amount,
+                             &rh->amount,
                              transaction);
         break;
       }
@@ -860,7 +859,7 @@ TALER_EXCHANGE_parse_coin_history (
       if (0 >
           TALER_amount_add (total_out,
                             total_out,
-                            &amount))
+                            &rh->amount))
       {
         /* overflow in history already!? inconceivable! Bad exchange! */
         GNUNET_break_op (0);
@@ -872,7 +871,7 @@ TALER_EXCHANGE_parse_coin_history (
       if (0 >
           TALER_amount_add (total_in,
                             total_in,
-                            &amount))
+                            &rh->amount))
       {
         /* overflow in refund history? inconceivable! Bad exchange! */
         GNUNET_break_op (0);
diff --git a/src/testing/testing_api_cmd_coin_history.c 
b/src/testing/testing_api_cmd_coin_history.c
index 23903745..bd0fc4fb 100644
--- a/src/testing/testing_api_cmd_coin_history.c
+++ b/src/testing/testing_api_cmd_coin_history.c
@@ -166,8 +166,12 @@ history_entry_cmp (
        fundamentally not available in the initiating command */
     return 0;
   case TALER_EXCHANGE_CTT_PURSE_DEPOSIT:
-    if (0 != GNUNET_memcmp (&h1->details.purse_deposit.coin_sig,
-                            &h2->details.purse_deposit.coin_sig))
+    /* coin_sig is not initialized */
+    if (0 != GNUNET_memcmp (&h1->details.purse_deposit.purse_pub,
+                            &h2->details.purse_deposit.purse_pub))
+      return 1;
+    if (0 != strcmp (h1->details.purse_deposit.exchange_base_url,
+                     h2->details.purse_deposit.exchange_base_url))
       return 1;
     return 0;
   case TALER_EXCHANGE_CTT_PURSE_REFUND:
@@ -414,7 +418,7 @@ coin_history_cb (void *cls,
       return;
     }
 #if FIXME
-    for (unsigned int i = 0; i<rs->details.ok.history_len; i++)
+    for (unsigned int i = 0; i<hlen; i++)
     {
       if (found[i])
         continue;
diff --git a/src/testing/testing_api_cmd_purse_deposit.c 
b/src/testing/testing_api_cmd_purse_deposit.c
index 8533e25c..048c6d73 100644
--- a/src/testing/testing_api_cmd_purse_deposit.c
+++ b/src/testing/testing_api_cmd_purse_deposit.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2022 Taler Systems SA
+  Copyright (C) 2022, 2023 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
@@ -38,6 +38,16 @@ struct Coin
    */
   char *command_ref;
 
+  /**
+   * Entry in the coin's history generated by this operation.
+   */
+  struct TALER_EXCHANGE_CoinHistoryEntry che;
+
+  /**
+   * Public key of the deposited coin.
+   */
+  struct TALER_CoinSpendPublicKeyP coin_pub;
+
   /**
    * index of the specific coin in the traits of @e command_ref.
    */
@@ -274,7 +284,7 @@ deposit_run (void *cls,
   ds->purse_pub = *purse_pub;
   for (unsigned int i = 0; i<ds->num_coin_references; i++)
   {
-    const struct Coin *cr = &ds->coin_references[i];
+    struct Coin *cr = &ds->coin_references[i];
     struct TALER_EXCHANGE_PurseDeposit *pd = &deposits[i];
     const struct TALER_TESTING_Command *coin_cmd;
     const struct TALER_CoinSpendPrivateKeyP *coin_priv;
@@ -307,6 +317,16 @@ deposit_run (void *cls,
       TALER_TESTING_interpreter_fail (is);
       return;
     }
+    GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
+                                        &cr->coin_pub.eddsa_pub);
+    cr->che.type = TALER_EXCHANGE_CTT_PURSE_DEPOSIT;
+    cr->che.amount = cr->deposit_with_fee;
+    cr->che.details.purse_deposit.purse_pub = *purse_pub;
+    cr->che.details.purse_deposit.exchange_base_url
+      = TALER_TESTING_get_exchange_url (is);
+    TALER_age_commitment_hash (
+      &age_commitment_proof->commitment,
+      &cr->che.details.purse_deposit.phac);
     pd->age_commitment_proof = age_commitment_proof;
     pd->denom_sig = *denom_pub_sig;
     pd->coin_priv = *coin_priv;
@@ -379,21 +399,31 @@ deposit_traits (void *cls,
                 unsigned int index)
 {
   struct PurseDepositState *ds = cls;
-  struct TALER_TESTING_Trait traits[] = {
-    /* history entry MUST be first due to response code logic below! */
-    TALER_TESTING_make_trait_reserve_history (0,
-                                              &ds->reserve_history),
-    TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
-    TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
-    TALER_TESTING_trait_end ()
-  };
-
-  return TALER_TESTING_get_trait (ds->purse_complete
-                                  ? &traits[0]   /* we have reserve history */
-                                  : &traits[1],  /* skip reserve history */
-                                  ret,
-                                  trait,
-                                  index);
+
+  if (index >= ds->num_coin_references)
+    return GNUNET_NO;
+  {
+    const struct Coin *co = &ds->coin_references[index];
+    struct TALER_TESTING_Trait traits[] = {
+      /* history entry MUST be first due to response code logic below! */
+      TALER_TESTING_make_trait_reserve_history (0,
+                                                &ds->reserve_history),
+      TALER_TESTING_make_trait_coin_history (index,
+                                             &co->che),
+      TALER_TESTING_make_trait_coin_pub (index,
+                                         &co->coin_pub),
+      TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
+      TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
+      TALER_TESTING_trait_end ()
+    };
+
+    return TALER_TESTING_get_trait (ds->purse_complete
+                                    ? &traits[0]   /* we have reserve history 
*/
+                                    : &traits[1],  /* skip reserve history */
+                                    ret,
+                                    trait,
+                                    index);
+  }
 }
 
 
@@ -431,7 +461,8 @@ TALER_TESTING_cmd_purse_deposit_coins (
     {
       struct Coin *c = &ds->coin_references[i++];
 
-      GNUNET_assert (NULL != (val = va_arg (ap, const char *)));
+      GNUNET_assert (NULL != (val = va_arg (ap,
+                                            const char *)));
       GNUNET_assert (GNUNET_OK ==
                      TALER_TESTING_parse_coin_reference (
                        ref,

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