gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated: implement tests for


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: implement tests for extended DB API
Date: Sun, 02 Apr 2017 22:34:48 +0200

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 b988eb9  implement tests for extended DB API
b988eb9 is described below

commit b988eb92fc9ea7fca8db7895e52af67a1a9231d7
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Apr 2 22:34:45 2017 +0200

    implement tests for extended DB API
---
 src/exchange/taler-exchange-httpd_db.c      |  2 +-
 src/exchangedb/plugin_exchangedb_postgres.c | 10 ++--
 src/exchangedb/test_exchangedb.c            | 88 ++++++++++++++++++++++++++++-
 src/include/taler_exchangedb_plugin.h       |  4 +-
 4 files changed, 92 insertions(+), 12 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_db.c 
b/src/exchange/taler-exchange-httpd_db.c
index 686c066..604de24 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -2363,7 +2363,7 @@ TEH_DB_execute_payback (struct MHD_Connection *connection,
   ret = TEH_plugin->insert_payback_request (TEH_plugin->cls,
                                             session,
                                             &reserve_pub,
-                                            coin,
+                                            &coin->coin_pub,
                                             coin_sig,
                                             coin_blind,
                                             &amount,
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 3095529..df0c1a5 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -516,7 +516,7 @@ postgres_create_tables (void *cls)
   /* Table for /payback information */
   SQLEXEC("CREATE TABLE IF NOT EXISTS payback "
           "(reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON 
DELETE CASCADE"
-          ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) ON 
DELETE CASCADE"
+          ",coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
           ",coin_sig BYTEA NOT NULL CHECK(LENGTH(coin_sig)=64)"
           ",coin_blind BYTEA NOT NULL CHECK(LENGTH(coin_blind)=32)"
           ",amount_val INT8 NOT NULL"
@@ -1454,8 +1454,6 @@ postgres_prepare (PGconn *db_conn)
            " WHERE payback.coin_pub=$1",
            1, NULL);
 
-
-
   /* Used in #postgres_get_reserve_by_h_blind() */
   PREPARE ("reserve_by_h_blind",
            "SELECT"
@@ -5625,7 +5623,7 @@ postgres_select_wire_out_above_serial_id (void *cls,
  * @param cls closure
  * @param session database connection
  * @param reserve_pub public key of the reserve that is being refunded
- * @param coin information about the coin
+ * @param coin_pub public key of the coin
  * @param coin_sig signature of the coin of type 
#TALER_SIGNATURE_WALLET_COIN_PAYBACK
  * @param coin_blind blinding key of the coin
  * @param amount total amount to be paid back
@@ -5639,7 +5637,7 @@ static int
 postgres_insert_payback_request (void *cls,
                                  struct TALER_EXCHANGEDB_Session *session,
                                  const struct TALER_ReservePublicKeyP 
*reserve_pub,
-                                 const struct TALER_CoinPublicInfo *coin,
+                                 const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
                                  const struct TALER_CoinSpendSignatureP 
*coin_sig,
                                  const struct TALER_DenominationBlindingKeyP 
*coin_blind,
                                  const struct TALER_Amount *amount,
@@ -5652,7 +5650,7 @@ postgres_insert_payback_request (void *cls,
   struct TALER_EXCHANGEDB_Reserve reserve;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (reserve_pub),
-    GNUNET_PQ_query_param_auto_from_type (&coin->coin_pub),
+    GNUNET_PQ_query_param_auto_from_type (coin_pub),
     GNUNET_PQ_query_param_auto_from_type (coin_sig),
     GNUNET_PQ_query_param_auto_from_type (coin_blind),
     TALER_PQ_query_param_amount (amount),
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index c7f9799..0fc0f92 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1336,6 +1336,9 @@ test_wire_out (struct TALER_EXCHANGEDB_Session *session,
 }
 
 
+
+
+
 /**
  * Main function that will be run by the scheduler.
  *
@@ -1346,6 +1349,9 @@ run (void *cls)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg = cls;
   struct TALER_EXCHANGEDB_Session *session;
+  struct TALER_CoinSpendSignatureP coin_sig;
+  struct GNUNET_TIME_Absolute deadline;
+  struct TALER_DenominationBlindingKeyP coin_blind;
   struct TALER_ReservePublicKeyP reserve_pub;
   struct DenomKeyPair *dkp;
   struct TALER_EXCHANGEDB_CollectableBlindcoin cbc;
@@ -1501,6 +1507,21 @@ run (void *cls)
           GNUNET_CRYPTO_rsa_verify (&cbc.h_coin_envelope,
                                     cbc2.sig.rsa_signature,
                                     dkp->pub.rsa_public_key));
+
+
+  RND_BLK (&coin_sig);
+  RND_BLK (&coin_blind);
+  FAILIF (GNUNET_OK !=
+          plugin->insert_payback_request (plugin->cls,
+                                          session,
+                                          &reserve_pub,
+                                          &deposit.coin.coin_pub,
+                                          &coin_sig,
+                                          &coin_blind,
+                                          &value,
+                                          &cbc.h_coin_envelope,
+                                          &deadline));
+
   result = 7;
   rh = plugin->get_reserve_history (plugin->cls,
                                     session,
@@ -1532,9 +1553,32 @@ run (void *cls)
                            &cbc.h_coin_envelope,
                            sizeof (cbc.h_coin_envelope)));
       break;
+    case TALER_EXCHANGEDB_RO_PAYBACK_COIN:
+      {
+        struct TALER_EXCHANGEDB_Payback *payback = rh_head->details.payback;
+
+        FAILIF (0 != memcmp (&payback->coin_sig,
+                             &coin_sig,
+                             sizeof (coin_sig)));
+        FAILIF (0 != memcmp (&payback->coin_blind,
+                             &coin_blind,
+                             sizeof (coin_blind)));
+        FAILIF (0 != memcmp (&payback->reserve_pub,
+                             &reserve_pub,
+                             sizeof (reserve_pub)));
+        FAILIF (0 != memcmp (&payback->coin_pub,
+                             &deposit.coin.coin_pub,
+                             sizeof (deposit.coin.coin_pub)));
+        FAILIF (0 != TALER_amount_cmp (&payback->value,
+                                       &value));
+      }
+      break;
+    case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
+      GNUNET_break (0); /* FIXME: #4956 */
+      break;
     }
   }
-  FAILIF (3 != cnt);
+  FAILIF (4 != cnt);
 
   auditor_row_cnt = 0;
   FAILIF (GNUNET_OK !=
@@ -1550,6 +1594,7 @@ run (void *cls)
                                                       &audit_reserve_out_cb,
                                                       NULL));
   FAILIF (3 != auditor_row_cnt);
+
   /* Tests for deposits */
   memset (&deposit, 0, sizeof (deposit));
   RND_BLK (&deposit.coin.coin_pub);
@@ -1567,7 +1612,8 @@ run (void *cls)
   result = 8;
   FAILIF (GNUNET_OK !=
           plugin->insert_deposit (plugin->cls,
-                                  session, &deposit));
+                                  session,
+                                  &deposit));
   FAILIF (GNUNET_YES !=
           plugin->have_deposit (plugin->cls,
                                 session,
@@ -1660,6 +1706,21 @@ run (void *cls)
           plugin->insert_refund (plugin->cls,
                                  session,
                                  &refund));
+
+
+  RND_BLK (&coin_sig);
+  RND_BLK (&coin_blind);
+  FAILIF (GNUNET_OK !=
+          plugin->insert_payback_request (plugin->cls,
+                                          session,
+                                          &reserve_pub,
+                                          &deposit.coin.coin_pub,
+                                          &coin_sig,
+                                          &coin_blind,
+                                          &value,
+                                          &cbc.h_coin_envelope,
+                                          &deadline));
+
   auditor_row_cnt = 0;
   FAILIF (GNUNET_OK !=
           plugin->select_refunds_above_serial_id (plugin->cls,
@@ -1747,12 +1808,33 @@ run (void *cls)
         matched |= 4;
         break;
       }
+    case TALER_EXCHANGEDB_TT_PAYBACK:
+      {
+        struct TALER_EXCHANGEDB_Payback *payback = tlp->details.payback;
+
+        FAILIF (0 != memcmp (&payback->coin_sig,
+                             &coin_sig,
+                             sizeof (coin_sig)));
+        FAILIF (0 != memcmp (&payback->coin_blind,
+                             &coin_blind,
+                             sizeof (coin_blind)));
+        FAILIF (0 != memcmp (&payback->reserve_pub,
+                             &reserve_pub,
+                             sizeof (reserve_pub)));
+        FAILIF (0 != memcmp (&payback->coin_pub,
+                             &deposit.coin.coin_pub,
+                             sizeof (deposit.coin.coin_pub)));
+        FAILIF (0 != TALER_amount_cmp (&payback->value,
+                                       &value));
+        matched |= 8;
+        break;
+      }
     default:
       FAILIF (1);
       break;
     }
   }
-  FAILIF (5 != matched);
+  FAILIF (13 != matched);
 
   plugin->free_coin_transaction_list (plugin->cls,
                                       tl);
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 37040d3..b578abf 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1949,7 +1949,7 @@ struct TALER_EXCHANGEDB_Plugin
    * @param cls closure
    * @param session database connection
    * @param reserve_pub public key of the reserve that is being refunded
-   * @param coin information about the coin
+   * @param coin_pub public key of the coin
    * @param coin_sig signature of the coin of type 
#TALER_SIGNATURE_WALLET_COIN_PAYBACK
    * @param coin_blind blinding key of the coin
    * @param h_blind_ev blinded envelope, as calculated by the exchange
@@ -1964,7 +1964,7 @@ struct TALER_EXCHANGEDB_Plugin
   (*insert_payback_request)(void *cls,
                             struct TALER_EXCHANGEDB_Session *session,
                             const struct TALER_ReservePublicKeyP *reserve_pub,
-                            const struct TALER_CoinPublicInfo *coin,
+                            const struct TALER_CoinSpendPublicKeyP *coin_pub,
                             const struct TALER_CoinSpendSignatureP *coin_sig,
                             const struct TALER_DenominationBlindingKeyP 
*coin_blind,
                             const struct TALER_Amount *amount,

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



reply via email to

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