gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: Worked on testing


From: gnunet
Subject: [taler-anastasis] branch master updated: Worked on testing
Date: Wed, 30 Oct 2019 22:55:51 +0100

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

dennis-neufeld pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 2f69241  Worked on testing
2f69241 is described below

commit 2f692412375b2bd28f50f17b7f07cf99e21e9fee
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Oct 30 21:55:18 2019 +0000

    Worked on testing
---
 src/backup-db/plugin_anastasis_postgres.c |  31 +++---
 src/backup-db/test_anastasis_db.c         | 179 +++++++++++++++---------------
 src/include/anastasis_database_lib.h      |  45 ++++++++
 src/include/anastasis_error_codes.h       |  12 +-
 4 files changed, 156 insertions(+), 111 deletions(-)

diff --git a/src/backup-db/plugin_anastasis_postgres.c 
b/src/backup-db/plugin_anastasis_postgres.c
index a87163b..f02d721 100644
--- a/src/backup-db/plugin_anastasis_postgres.c
+++ b/src/backup-db/plugin_anastasis_postgres.c
@@ -25,6 +25,7 @@
 #include <gnunet/gnunet_pq_lib.h>
 #include <taler/taler_pq_lib.h>
 #include "anastasis_database_plugin.h"
+#include "anastasis_database_lib.h"
 
 /**
  * How often do we re-try if we run into a DB serialization error?
@@ -276,7 +277,7 @@ postgres_store_recovery_document (void *cls,
                                            paid_until);
     break;
   default:
-    //FIXME: Some Action
+    // FIXME: Some Action
     return qs;
   }
 
@@ -321,7 +322,7 @@ postgres_store_recovery_document (void *cls,
   case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
     break;
   default:
-    //FIXME: Some Action
+    // FIXME: Some Action
     return qs;
   }
 
@@ -361,7 +362,7 @@ postgres_store_recovery_document (void *cls,
   case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
     break;
   default:
-    //FIXME: Some Action
+    // FIXME: Some Action
     return qs;
   }
 
@@ -397,7 +398,7 @@ postgres_store_recovery_document (void *cls,
     (*version)++;
     break;
   default:
-    //FIXME: Some Action
+    // FIXME: Some Action
     return qs;
   }
 
@@ -429,7 +430,7 @@ postgres_store_recovery_document (void *cls,
   case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
     break;
   default:
-    //FIXME: Some Action
+    // FIXME: Some Action
     return qs;
   }
 
@@ -503,8 +504,8 @@ postgres_record_payment (void *cls,
                                              paid_until);
       break;
     default:
-    //FIXME: Some Action
-    return qs;
+      // FIXME: Some Action
+      return qs;
     }
   }
   paid_until = GNUNET_TIME_absolute_add (paid_until,
@@ -551,7 +552,7 @@ postgres_record_payment (void *cls,
   case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
     break;
   default:
-    //FIXME: Some Action
+    // FIXME: Some Action
     return qs;
   }
 
@@ -582,8 +583,8 @@ postgres_record_payment (void *cls,
     case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
       break;
     default:
-    //FIXME: Some Action
-    return qs;
+      // FIXME: Some Action
+      return qs;
     }
   }
 
@@ -656,7 +657,7 @@ postgres_store_truth (void *cls,
   case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
     break;
   default:
-    //FIXME: Some Action
+    // FIXME: Some Action
     return qs;
   }
 
@@ -823,8 +824,8 @@ postgres_get_recovery_document (void *cls,
  * @param cls a configuration instance
  * @return NULL on error, otherwise a `struct TALER_ANASTASISDB_Plugin`
  */
-void *
-libtaler_plugin_anastasis_db_postgres_init (void *cls)
+struct ANASTASIS_DatabasePlugin *
+ANASTASIS_DB_plugin_load (void *cls)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg = cls;
   struct PostgresClosure *pg;
@@ -967,7 +968,7 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
   pg = GNUNET_new (struct PostgresClosure);
   pg->cfg = cfg;
   pg->conn = GNUNET_PQ_connect_with_cfg (cfg,
-                                         "anastasis",
+                                         "anastasis-db",
                                          es,
                                          ps);
   if (NULL == pg->conn)
@@ -1002,7 +1003,7 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
  * @return NULL (always)
  */
 void *
-plugin_anastasis_db_postgres_done (void *cls)
+ANASTASIS_DB_plugin_unload (void *cls)
 {
   struct ANASTASIS_DatabasePlugin *plugin = cls;
   struct PostgresClosure *pg = plugin->cls;
diff --git a/src/backup-db/test_anastasis_db.c 
b/src/backup-db/test_anastasis_db.c
index 3f238c1..fee1fb7 100644
--- a/src/backup-db/test_anastasis_db.c
+++ b/src/backup-db/test_anastasis_db.c
@@ -25,6 +25,7 @@
 #include <gnunet/gnunet_db_lib.h>
 #include <taler/taler_util.h>
 #include "anastasis_database_plugin.h"
+#include "anastasis_datanase_lib.h"
 
 #define FAILIF(cond)                            \
   do {                                          \
@@ -101,63 +102,61 @@ const unsigned int *version;
 static void
 run (void *cls)
 {
-
-    struct GNUNET_CONFIGURATION_Handle *cfg = cls;
-    struct GNUNET_TIME_Absolute fake_now;
-
-    if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
-    {
-        result = 77;
-        return;
-    }
-    if (GNUNET_OK != plugin->drop_tables (plugin->cls))
-    {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    "Dropping tables failed\n");
-        result = 77;
-        return;
-    }
-    TALER_MERCHANTDB_plugin_unload (plugin);
-    if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
-    {
-        result = 77;
-        return;
-    }
-
-    FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
-            plugin->store_recovery_document (plugin->cls,
-                                             accountPubP,
-                                             recovery_data,
-                                             recovery_data_size,
-                                             paymentSecretP,
-                                             version));
-    FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
-            plugin->record_payment (plugin->cls,
-                                    amount,
-                                    accountPubP,
-                                    &post_counter,
-                                    fake_now,
-                                    paymentSecretP));
-    FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
-            plugin->store_truth (plugin->cls,
-                                 uuid,
-                                 truth_data,
-                                 truth_data_size,
-                                 expiration,
-                                 version));
-
-    if (-1 == result)
-        result = 0;
-
-    drop:
-    GNUNET_break (GNUNET_OK ==
-                  plugin->drop_tables (plugin->cls));
-    TALER_MERCHANTDB_plugin_unload (plugin);
-    plugin = NULL;
-    if (NULL != deposit_proof)
-        json_decref (deposit_proof);
-    if (NULL != transfer_proof)
-        json_decref (transfer_proof);
+  struct GNUNET_TIME_Absolute fake_now;
+
+  if (NULL == (plugin = ANASTASIS_DB_plugin_load (cls)))
+  {
+    result = 77;
+    return;
+  }
+  if (GNUNET_OK != plugin->drop_tables (plugin->cls))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Dropping tables failed\n");
+    result = 77;
+    return;
+  }
+  ANASTASIS_DB_plugin_unload (plugin);
+  if (NULL == (plugin = ANASTASIS_DB_plugin_load (cls)))
+  {
+    result = 77;
+    return;
+  }
+
+  FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+          plugin->store_recovery_document (plugin->cls,
+                                           accountPubP,
+                                           recovery_data,
+                                           recovery_data_size,
+                                           paymentSecretP,
+                                           version));
+  FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+          plugin->record_payment (plugin->cls,
+                                  amount,
+                                  accountPubP,
+                                  &post_counter,
+                                  fake_now,
+                                  paymentSecretP));
+  FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+          plugin->store_truth (plugin->cls,
+                               uuid,
+                               truth_data,
+                               truth_data_size,
+                               expiration,
+                               version));
+
+  if (-1 == result)
+    result = 0;
+
+drop:
+  GNUNET_break (GNUNET_OK ==
+                plugin->drop_tables (plugin->cls));
+  ANASTASIS_DB_plugin_unload (plugin);
+  plugin = NULL;
+  if (NULL != deposit_proof)
+    json_decref (deposit_proof);
+  if (NULL != transfer_proof)
+    json_decref (transfer_proof);
 }
 
 
@@ -165,40 +164,40 @@ int
 main (int argc,
       char *const argv[])
 {
-    const char *plugin_name;
-    char *config_filename;
-    char *testname;
-    struct GNUNET_CONFIGURATION_Handle *cfg;
-
-    result = -1;
-    if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
-    {
-        GNUNET_break (0);
-        return -1;
-    }
-    GNUNET_log_setup (argv[0], "DEBUG", NULL);
-    plugin_name++;
-    (void) GNUNET_asprintf (&testname,
-                            "test-merchantdb-%s",
-                            plugin_name);
-    (void) GNUNET_asprintf (&config_filename,
-                            "%s.conf",
-                            testname);
-    cfg = GNUNET_CONFIGURATION_create ();
-    if (GNUNET_OK !=
-        GNUNET_CONFIGURATION_parse (cfg,
-                                    config_filename))
-    {
-        GNUNET_break (0);
-        GNUNET_free (config_filename);
-        GNUNET_free (testname);
-        return 2;
-    }
-    GNUNET_SCHEDULER_run (&run, cfg);
-    GNUNET_CONFIGURATION_destroy (cfg);
+  const char *plugin_name;
+  char *config_filename;
+  char *testname;
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+
+  result = -1;
+  if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
+  {
+    GNUNET_break (0);
+    return -1;
+  }
+  GNUNET_log_setup (argv[0], "DEBUG", NULL);
+  plugin_name++;
+  (void) GNUNET_asprintf (&testname,
+                          "test-anastasis-db-%s",
+                          plugin_name);
+  (void) GNUNET_asprintf (&config_filename,
+                          "%s.conf",
+                          testname);
+  cfg = GNUNET_CONFIGURATION_create ();
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_parse (cfg,
+                                  config_filename))
+  {
+    GNUNET_break (0);
     GNUNET_free (config_filename);
     GNUNET_free (testname);
-    return result;
+    return 2;
+  }
+  GNUNET_SCHEDULER_run (&run, cfg);
+  GNUNET_CONFIGURATION_destroy (cfg);
+  GNUNET_free (config_filename);
+  GNUNET_free (testname);
+  return result;
 }
 
-/* end of test_merchantdb.c */
\ No newline at end of file
+/* end of test_anastasis_db.c */
\ No newline at end of file
diff --git a/src/include/anastasis_database_lib.h 
b/src/include/anastasis_database_lib.h
new file mode 100644
index 0000000..b0199ad
--- /dev/null
+++ b/src/include/anastasis_database_lib.h
@@ -0,0 +1,45 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2014-2017 Inria & GNUnet e.V.
+
+  TALER is free software; you can redistribute it and/or modify it under the
+  terms of the GNU General Public License as published by the Free Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * 
+ */
+#ifndef ANASTASIS_DB_LIB_H
+#define ANASTASIS_DB_LIB_H
+
+#include <taler/taler_util.h>
+#include "anastasis_database_plugin.h"
+
+/**
+ * Initialize the plugin.
+ *
+ * @param cfg configuration to use
+ * @return NULL on failure
+ */
+struct ANASTASIS_DatabasePlugin *
+ANASTASIS_DB_plugin_load (void *cls);
+
+
+/**
+ * Shutdown the plugin.
+ *
+ * @param plugin plugin to unload
+ */
+void
+ANASTASIS_DB_plugin_unload (void *cls);
+
+#endif  /* ANASTASIS_DB_LIB_H */
+
+/* end of anastasis_database_lib.h */
\ No newline at end of file
diff --git a/src/include/anastasis_error_codes.h 
b/src/include/anastasis_error_codes.h
index 3fa89b7..45ce6e8 100644
--- a/src/include/anastasis_error_codes.h
+++ b/src/include/anastasis_error_codes.h
@@ -63,14 +63,14 @@ enum ANASTASIS_DB_QueryStatus
    */
   ANASTASIS_DB_STATUS_UNKNOWN_USER = 6000,
 
-   /**
-   * The Users Payment had not sufficient posts left
-   */
+  /**
+  * The Users Payment had not sufficient posts left
+  */
   ANASTASIS_DB_STATUS_NOT_SUFFICIENT_POSTS = 6001,
 
-   /**
-   * The Payment from the User has expired.
-   */
+  /**
+  * The Payment from the User has expired.
+  */
   ANASTASIS_DB_STATUS_PAYMENT_EXPIRED = 6002
 };
 

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



reply via email to

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