gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: fix test


From: gnunet
Subject: [taler-anastasis] branch master updated: fix test
Date: Fri, 29 Nov 2019 19:33:33 +0100

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 65c7314  fix test
65c7314 is described below

commit 65c73140392d2c74cb08525e5b63a1964a308b74
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Nov 29 19:33:31 2019 +0100

    fix test
---
 src/stasis/plugin_anastasis_postgres.c | 85 ++++++++++++++++++++--------------
 src/stasis/test_anastasis_db.c         | 27 +++++------
 2 files changed, 65 insertions(+), 47 deletions(-)

diff --git a/src/stasis/plugin_anastasis_postgres.c 
b/src/stasis/plugin_anastasis_postgres.c
index f23484f..c053eca 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -131,6 +131,7 @@ postgres_preflight (void *cls)
   pg->transaction_name = NULL;
 }
 
+
 /**
  * Start a transaction.
  *
@@ -163,6 +164,7 @@ begin_transaction (void *cls,
   return GNUNET_OK;
 }
 
+
 /**
 * Roll back the current transaction of a database connection.
 *
@@ -188,6 +190,7 @@ rollback (void *cls)
   pg->transaction_name = NULL;
 }
 
+
 /**
  * Commit the current transaction of a database connection.
  *
@@ -424,7 +427,7 @@ postgres_store_recovery_document (void *cls,
     return qs;
   }
 
-  if (postcounter == 0 )
+  if (postcounter == 0)
   {
     rollback (pg);
     return ANASTASIS_EC_DB_STATUS_NOT_SUFFICIENT_POSTS;
@@ -491,7 +494,7 @@ postgres_store_recovery_document (void *cls,
     return ANASTASIS_DB_STATUS_SOFT_ERROR;
   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
     /* original error must have been a hard error, oddly enough */
-    //return ANASTASIS_DB_STATUS_HARD_ERROR;
+    // return ANASTASIS_DB_STATUS_HARD_ERROR;
     break;
   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     /* handle interesting case below */
@@ -542,6 +545,7 @@ postgres_store_recovery_document (void *cls,
   return qs;
 }
 
+
 /**
  * Increment account lifetime.
  *
@@ -668,6 +672,7 @@ postgres_increment_lifetime (void *cls,
   }
 }
 
+
 /**
  * Store payment. Used to begin a payment, not indicative
  * that the payment actually was made. (That is done
@@ -720,6 +725,7 @@ postgres_record_payment (void *cls,
   }
 }
 
+
 /**
  * Upload Truth, which contains the Truth and the KeyShare.
  *
@@ -838,6 +844,7 @@ postgres_get_escrow_challenge (void *cls,
                                                    rs);
 }
 
+
 /**
 * @param cls closure
 * @param uuid the identifier for the Truth
@@ -952,9 +959,9 @@ postgres_get_latest_recovery_document (void *cls,
   check_connection (pg);
   postgres_preflight (pg);
   qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
-                                                   
"latest_recoverydocument_select",
-                                                   params,
-                                                   rs);
+                                                 
"latest_recoverydocument_select",
+                                                 params,
+                                                 rs);
   switch (qs)
   {
   case GNUNET_DB_STATUS_HARD_ERROR:
@@ -1043,6 +1050,7 @@ postgres_get_recovery_document (void *cls,
   }
 }
 
+
 /**
  * Initialize Postgres database subsystem.
  *
@@ -1077,15 +1085,16 @@ libanastasis_plugin_db_postgres_init (void *cls)
                             "  payment_identifier BYTEA NOT NULL 
CHECK(LENGTH(payment_identifier)=32),"
                             "  transaction_time TIMESTAMP NOT NULL DEFAULT 
NOW()"
                             ");"),
-    GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS 
anastasis_recoverydocument"
-                            "( user_id BYTEA NOT NULL REFERENCES 
anastasis_user(user_id),"
-                            " version INT4 NOT NULL,"
-                            " account_sig BYTEA NOT NULL 
CHECK(LENGTH(account_sig)=64),"
-                            " prev_hash BYTEA NOT NULL 
CHECK(LENGTH(prev_hash)=64),"
-                            " recovery_data_hash BYTEA NOT NULL 
CHECK(length(recovery_data_hash)=64),"
-                            " recovery_data BYTEA NOT NULL,"
-                            " PRIMARY KEY (user_id, version)"
-                            ");"),
+    GNUNET_PQ_make_execute (
+      "CREATE TABLE IF NOT EXISTS anastasis_recoverydocument"
+      "( user_id BYTEA NOT NULL REFERENCES anastasis_user(user_id),"
+      " version INT4 NOT NULL,"
+      " account_sig BYTEA NOT NULL CHECK(LENGTH(account_sig)=64),"
+      " prev_hash BYTEA NOT NULL CHECK(LENGTH(prev_hash)=64),"
+      " recovery_data_hash BYTEA NOT NULL 
CHECK(length(recovery_data_hash)=64),"
+      " recovery_data BYTEA NOT NULL,"
+      " PRIMARY KEY (user_id, version)"
+      ");"),
     GNUNET_PQ_EXECUTE_STATEMENT_END
   };
   struct GNUNET_PQ_PreparedStatement ps[] = {
@@ -1151,33 +1160,40 @@ libanastasis_plugin_db_postgres_init (void *cls)
                             1),
     GNUNET_PQ_make_prepare ("latest_recoverydocument_select",
                             "SELECT "
-                            "recovery_data "
-                            "FROM anastasis_recoverydocument "
-                            "WHERE user_id =$1 "
-                            "ORDER BY version DESC "
-                            "LIMIT 1;",
+                            " version"
+                            ",account_sig"
+                            ",prev_hash"
+                            ",recovery_data_hash"
+                            ",recovery_data"
+                            " FROM anastasis_recoverydocument"
+                            " WHERE user_id =$1 "
+                            " ORDER BY version DESC"
+                            " LIMIT 1;",
                             1),
     GNUNET_PQ_make_prepare ("latest_recovery_version_select",
-                            "SELECT "
-                            "version "
-                            "FROM anastasis_recoverydocument "
-                            "WHERE user_id =$1 "
-                            "ORDER BY version DESC "
-                            "LIMIT 1;",
+                            "SELECT"
+                            " version"
+                            " FROM anastasis_recoverydocument"
+                            " WHERE user_id=$1"
+                            " ORDER BY version DESC"
+                            " LIMIT 1;",
                             1),
     GNUNET_PQ_make_prepare ("recoverydocument_select",
                             "SELECT "
-                            "recovery_data "
-                            "FROM anastasis_recoverydocument "
-                            "WHERE user_id =$1 "
-                            "AND version=$2;",
+                            " account_sig"
+                            ",prev_hash"
+                            ",recovery_data_hash"
+                            ",recovery_data"
+                            " FROM anastasis_recoverydocument"
+                            " WHERE user_id=$1"
+                            " AND version=$2;",
                             2),
     GNUNET_PQ_make_prepare ("postcounter_select",
-                            "SELECT "
-                            "post_counter "
-                            "FROM anastasis_payment "
-                            "WHERE user_id =$1 "
-                            "AND payment_identifier=$2;",
+                            "SELECT"
+                            " post_counter"
+                            " FROM anastasis_payment"
+                            " WHERE user_id=$1"
+                            "  AND payment_identifier=$2;",
                             2),
     GNUNET_PQ_make_prepare ("postcounter_update",
                             "UPDATE "
@@ -1260,4 +1276,5 @@ libanastasis_plugin_db_postgres_done (void *cls)
   return NULL;
 }
 
+
 /* end of plugin_anastasisdb_postgres.c */
diff --git a/src/stasis/test_anastasis_db.c b/src/stasis/test_anastasis_db.c
index 5958d1e..842cc64 100644
--- a/src/stasis/test_anastasis_db.c
+++ b/src/stasis/test_anastasis_db.c
@@ -156,7 +156,7 @@ static uint32_t docVersion;
 /**
  * Version of the latest Recoverydocument
  */
-static uint32_t *res_version;
+static uint32_t res_version;
 
 
 /**
@@ -194,11 +194,11 @@ run (void *cls)
   size_t keysharesize;
   const char *str = "AHV123456789";
   struct GNUNET_CRYPTO_EccSignaturePurpose purp;
-  
+
   GNUNET_CRYPTO_eddsa_private_key_from_string (str,
                                                sizeof (str),
                                                &accountPrivP.priv);
-                                
+
   GNUNET_CRYPTO_eddsa_key_get_public (&accountPrivP.priv,
                                       &accountPubP.pub);
 
@@ -209,14 +209,14 @@ run (void *cls)
   GNUNET_CRYPTO_hash (recovery_data,
                       sizeof (recovery_data),
                       &recoveryDataHash);
-  
+
   purp.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose));
   purp.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
   GNUNET_CRYPTO_eddsa_sign (&accountPrivP.priv,
                             &purp,
                             &accountSig.eddsa_sig);
   RND_BLK (&paymentSecretP);
-  
+
   int truth_val = 300;
   truth_data = &truth_val;
   RND_BLK (truth_data);
@@ -238,17 +238,17 @@ run (void *cls)
                                       &accountPubP,
                                       &paymentSecretP,
                                       rel_time));
-  
+
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->lookup_account (plugin->cls,
                                   &accountPubP));
-  
+
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->record_payment (plugin->cls,
                                   &accountPubP,
                                   post_counter,
                                   &paymentSecretP));
-  
+
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->store_truth (plugin->cls,
                                &uuid,
@@ -258,7 +258,7 @@ run (void *cls)
                                key_share,
                                sizeof (&key_share),
                                rel_time));
-  
+
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->store_recovery_document (plugin->cls,
                                            &accountPubP,
@@ -269,7 +269,7 @@ run (void *cls)
                                            sizeof (&recovery_data),
                                            &paymentSecretP,
                                            &docVersion));
-  
+
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_escrow_challenge (plugin->cls,
                                         &uuid,
@@ -282,7 +282,7 @@ run (void *cls)
                                  &uuid,
                                  &res_key_share,
                                  &keysharesize));
-  
+
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_recovery_document (plugin->cls,
                                          &accountPubP,
@@ -292,7 +292,7 @@ run (void *cls)
                                          recversion,
                                          &recoverydatasize,
                                          &res_recovery_data));
-  
+
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_latest_recovery_document (plugin->cls,
                                                 &accountPubP,
@@ -301,7 +301,7 @@ run (void *cls)
                                                 &res_recovery_data_hash,
                                                 &recoverydatasize,
                                                 &res_recovery_data,
-                                                res_version));
+                                                &res_version));
   if (-1 == result)
     result = 0;
 
@@ -353,4 +353,5 @@ main (int argc,
   return result;
 }
 
+
 /* end of test_anastasis_db.c */

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



reply via email to

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