gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -more work on coin history testi


From: gnunet
Subject: [taler-exchange] branch master updated: -more work on coin history testing
Date: Thu, 09 Nov 2023 14:11:42 +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 5ebc9d46 -more work on coin history testing
5ebc9d46 is described below

commit 5ebc9d465458541f28b3673620a172a4a7fb24c2
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Thu Nov 9 14:11:38 2023 +0100

    -more work on coin history testing
---
 src/include/taler_exchange_service.h        |  9 +++++++--
 src/testing/testing_api_cmd_batch_deposit.c | 26 ++++++++++++++++++++++++++
 src/testing/testing_api_cmd_coin_history.c  |  7 +++++--
 src/testing/testing_api_cmd_deposit.c       | 10 ++++++++--
 src/testing/testing_api_cmd_refresh.c       | 26 +++++++++++++++++++++++++-
 5 files changed, 71 insertions(+), 7 deletions(-)

diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 8f5f4c4d..d2bf918d 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -3277,11 +3277,16 @@ struct TALER_EXCHANGE_RefreshData
    */
   struct TALER_CoinSpendPrivateKeyP melt_priv;
 
-  /*
-   * age commitment and proof and its hash that went into the original coin,
+  /**
+   * age commitment and proof that went into the original coin,
    * might be NULL.
    */
   const struct TALER_AgeCommitmentProof *melt_age_commitment_proof;
+
+  /**
+   * Hash of age commitment and proof that went into the original coin,
+   * might be NULL.
+   */
   const struct TALER_AgeCommitmentHash *melt_h_age_commitment;
 
   /**
diff --git a/src/testing/testing_api_cmd_batch_deposit.c 
b/src/testing/testing_api_cmd_batch_deposit.c
index ef54e6a0..21d73bf5 100644
--- a/src/testing/testing_api_cmd_batch_deposit.c
+++ b/src/testing/testing_api_cmd_batch_deposit.c
@@ -74,6 +74,12 @@ struct Coin
    */
   const struct TALER_TESTING_Command *coin_cmd;
 
+  /**
+   * Expected entry in the coin history created by this
+   * coin.
+   */
+  struct TALER_EXCHANGE_CoinHistoryEntry che;
+
   /**
    * Index of the coin at @e coin_cmd.
    */
@@ -369,6 +375,19 @@ batch_deposit_run (void *cls,
                                coin_priv,
                                &cdd->coin_sig);
     coin->coin_sig = cdd->coin_sig;
+    coin->che.type = TALER_EXCHANGE_CTT_DEPOSIT;
+    coin->che.amount = coin->amount;
+    coin->che.details.deposit.h_wire = h_wire;
+    coin->che.details.deposit.h_contract_terms = h_contract_terms;
+    coin->che.details.deposit.no_h_policy = true;
+    coin->che.details.deposit.no_wallet_data_hash = true;
+    coin->che.details.deposit.wallet_timestamp = ds->wallet_timestamp;
+    coin->che.details.deposit.merchant_pub = merchant_pub;
+    coin->che.details.deposit.refund_deadline = ds->refund_deadline;
+    coin->che.details.deposit.sig = cdd->coin_sig;
+    coin->che.details.deposit.no_hac = GNUNET_is_zero (&cdd->h_age_commitment);
+    coin->che.details.deposit.hac = cdd->h_age_commitment;
+    coin->che.details.deposit.deposit_fee = denom_pub->fees.deposit;
   }
 
   GNUNET_assert (NULL == ds->dh);
@@ -460,6 +479,7 @@ batch_deposit_traits (void *cls,
   struct Coin *coin = &ds->coins[index];
   /* Will point to coin cmd internals. */
   const struct TALER_CoinSpendPrivateKeyP *coin_spent_priv;
+  struct TALER_CoinSpendPublicKeyP coin_spent_pub;
   const struct TALER_AgeCommitmentProof *age_commitment_proof;
 
   if (index >= ds->num_coins)
@@ -486,6 +506,10 @@ batch_deposit_traits (void *cls,
     TALER_TESTING_interpreter_fail (ds->is);
     return GNUNET_NO;
   }
+
+  GNUNET_CRYPTO_eddsa_key_get_public (&coin_spent_priv->eddsa_priv,
+                                      &coin_spent_pub.eddsa_pub);
+
   {
     struct TALER_TESTING_Trait traits[] = {
       /* First two traits are only available if
@@ -500,6 +524,8 @@ batch_deposit_traits (void *cls,
       TALER_TESTING_make_trait_merchant_priv (&ds->merchant_priv),
       TALER_TESTING_make_trait_age_commitment_proof (index,
                                                      age_commitment_proof),
+      TALER_TESTING_make_trait_coin_pub (index,
+                                         &coin_spent_pub),
       TALER_TESTING_make_trait_coin_priv (index,
                                           coin_spent_priv),
       TALER_TESTING_make_trait_coin_sig (index,
diff --git a/src/testing/testing_api_cmd_coin_history.c 
b/src/testing/testing_api_cmd_coin_history.c
index d4b95fb4..38905b35 100644
--- a/src/testing/testing_api_cmd_coin_history.c
+++ b/src/testing/testing_api_cmd_coin_history.c
@@ -132,9 +132,12 @@ history_entry_cmp (
       return 1;
     return 0;
   case TALER_EXCHANGE_CTT_MELT:
-    if (0 != GNUNET_memcmp (&h1->details.melt.sig,
-                            &h2->details.melt.sig))
+    if (0 != GNUNET_memcmp (&h1->details.melt.h_age_commitment,
+                            &h2->details.melt.h_age_commitment))
       return 1;
+    /* Note: most other fields are not initialized
+       in the trait as they are hard to extract from
+       the API */
     return 0;
   case TALER_EXCHANGE_CTT_REFUND:
     if (0 != GNUNET_memcmp (&h1->details.refund.sig,
diff --git a/src/testing/testing_api_cmd_deposit.c 
b/src/testing/testing_api_cmd_deposit.c
index 0b908cc6..41aa1c99 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2018-2021 Taler Systems SA
+  Copyright (C) 2018-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
@@ -568,6 +568,7 @@ deposit_traits (void *cls,
   const struct TALER_TESTING_Command *coin_cmd;
   /* Will point to coin cmd internals. */
   const struct TALER_CoinSpendPrivateKeyP *coin_spent_priv;
+  struct TALER_CoinSpendPublicKeyP coin_spent_pub;
   const struct TALER_AgeCommitmentProof *age_commitment_proof;
   const struct TALER_AgeCommitmentHash *h_age_commitment;
 
@@ -605,10 +606,13 @@ deposit_traits (void *cls,
     return GNUNET_NO;
   }
 
+  GNUNET_CRYPTO_eddsa_key_get_public (&coin_spent_priv->eddsa_priv,
+                                      &coin_spent_pub.eddsa_pub);
+
   {
     struct TALER_TESTING_Trait traits[] = {
       /* First two traits are only available if
-         ds->traits is #GNUNET_YES */
+         ds->traits is true */
       TALER_TESTING_make_trait_exchange_pub (0,
                                              &ds->exchange_pub),
       TALER_TESTING_make_trait_exchange_sig (0,
@@ -618,6 +622,8 @@ deposit_traits (void *cls,
                                              &ds->che),
       TALER_TESTING_make_trait_coin_priv (0,
                                           coin_spent_priv),
+      TALER_TESTING_make_trait_coin_pub (0,
+                                         &coin_spent_pub),
       TALER_TESTING_make_trait_coin_sig (0,
                                          &ds->coin_sig),
       TALER_TESTING_make_trait_age_commitment_proof (0,
diff --git a/src/testing/testing_api_cmd_refresh.c 
b/src/testing/testing_api_cmd_refresh.c
index c5e20f2a..c1555a90 100644
--- a/src/testing/testing_api_cmd_refresh.c
+++ b/src/testing/testing_api_cmd_refresh.c
@@ -117,6 +117,12 @@ struct RefreshMeltState
    */
   struct TALER_EXCHANGE_MeltHandle *rmh;
 
+  /**
+   * Expected entry in the coin history created by this
+   * operation.
+   */
+  struct TALER_EXCHANGE_CoinHistoryEntry che;
+
   /**
    * Interpreter state.
    */
@@ -144,6 +150,11 @@ struct RefreshMeltState
    */
   const struct TALER_CoinSpendPrivateKeyP *melt_priv;
 
+  /**
+   * Public key of the dirty coin being melted.
+   */
+  struct TALER_CoinSpendPublicKeyP melt_pub;
+
   /**
    * Task scheduled to try later.
    */
@@ -1147,6 +1158,8 @@ melt_run (void *cls,
     } /* end for */
 
     rms->refresh_data.melt_priv = *rms->melt_priv;
+    GNUNET_CRYPTO_eddsa_key_get_public (&rms->melt_priv->eddsa_priv,
+                                        &rms->melt_pub.eddsa_pub);
     rms->refresh_data.melt_amount = melt_amount;
     rms->refresh_data.melt_sig = *melt_sig;
     rms->refresh_data.melt_pk = *melt_denom_pub;
@@ -1165,6 +1178,13 @@ melt_run (void *cls,
     GNUNET_assert ((NULL == age_commitment_proof) ||
                    (0 < age_commitment_proof->commitment.num));
 
+    rms->che.type = TALER_EXCHANGE_CTT_MELT;
+    rms->che.amount = melt_amount;
+    if (NULL != age_commitment_proof)
+      rms->che.details.melt.h_age_commitment = *h_age_commitment;
+    else
+      rms->che.details.melt.no_hac = true;
+
     rms->rmh = TALER_EXCHANGE_melt (
       TALER_TESTING_interpreter_get_context (is),
       TALER_TESTING_get_exchange_url (is),
@@ -1253,8 +1273,12 @@ melt_traits (void *cls,
     struct TALER_TESTING_Trait traits[] = {
       TALER_TESTING_make_trait_denom_pub (index,
                                           &rms->fresh_pks[index]),
-      TALER_TESTING_make_trait_coin_priv (index,
+      TALER_TESTING_make_trait_coin_priv (0,
                                           rms->melt_priv),
+      TALER_TESTING_make_trait_coin_pub (0,
+                                         &rms->melt_pub),
+      TALER_TESTING_make_trait_coin_history (0,
+                                             &rms->che),
       TALER_TESTING_make_trait_age_commitment_proof (
         index,
         rms->refresh_data.melt_age_commitment_proof),

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