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 errors


From: gnunet
Subject: [taler-anastasis] branch master updated: Worked on errors
Date: Wed, 06 Nov 2019 20:46:56 +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 fff76b4  Worked on errors
fff76b4 is described below

commit fff76b42804f09b5815f52468d6db0f16c7249a9
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Nov 6 19:46:33 2019 +0000

    Worked on errors
---
 src/backup-db/Makefile.am                 |  3 +-
 src/backup-db/plugin_anastasis_postgres.c | 24 +++++++++++-----
 src/backup-db/test_anastasis_db.c         | 46 ++++++++++++++++---------------
 3 files changed, 43 insertions(+), 30 deletions(-)

diff --git a/src/backup-db/Makefile.am b/src/backup-db/Makefile.am
index 7a43872..20c34c3 100644
--- a/src/backup-db/Makefile.am
+++ b/src/backup-db/Makefile.am
@@ -49,7 +49,8 @@ test_anastasis_db_postgres_LDFLAGS = \
   libanastasisdb.la \
   -lgnunetutil \
   -lgnunetpq \
-  -ltalerutil 
+  -ltalerutil \
+  -ltalerpq 
 
 TESTS = \
   test_anastasis_db_postgres
diff --git a/src/backup-db/plugin_anastasis_postgres.c 
b/src/backup-db/plugin_anastasis_postgres.c
index 21e3a0e..95a1de2 100644
--- a/src/backup-db/plugin_anastasis_postgres.c
+++ b/src/backup-db/plugin_anastasis_postgres.c
@@ -148,6 +148,7 @@ begin_transaction (void *cls,
     GNUNET_PQ_EXECUTE_STATEMENT_END
   };
 
+  check_connection (pg);
   postgres_preflight (pg);
   pg->transaction_name = name;
   if (GNUNET_OK !=
@@ -231,7 +232,7 @@ postgres_store_recovery_document (void *cls,
                                   const struct
                                   ANASTASIS_PaymentSecretP *payment_secret,
                                   uint32_t *version)
-{
+{ 
   struct PostgresClosure *pg = cls;
   enum ANASTASIS_DB_QueryStatus qs;
   uint32_t postcounter;
@@ -244,7 +245,7 @@ postgres_store_recovery_document (void *cls,
     GNUNET_break (0);
     return ANASTASIS_DB_STATUS_HARD_ERROR;
   }
-
+  
   /* Check if user has paid */
   {
     struct GNUNET_PQ_QueryParam params[] = {
@@ -262,6 +263,9 @@ postgres_store_recovery_document (void *cls,
                                                    params,
                                                    rs);
   }
+  
+  struct GNUNET_TIME_Relative time_remaining;
+
   switch (qs)
   {
   case ANASTASIS_DB_STATUS_HARD_ERROR:
@@ -274,17 +278,16 @@ postgres_store_recovery_document (void *cls,
   case ANASTASIS_DB_STATUS_SUCCESS_NO_RESULTS:
     return ANASTASIS_EC_DB_STATUS_UNKNOWN_USER;
   case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
-    paid_until = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (),
-                                           paid_until);
+    time_remaining = GNUNET_TIME_absolute_get_remaining (paid_until);
     break;
   default:
     // FIXME: Some Action
+    rollback (pg);
     return qs;
   }
 
   // rollback if user hasn't paid
-  if (GNUNET_TIME_absolute_get_difference (GNUNET_TIME_absolute_get (),
-                                           paid_until).rel_value_us == 0)
+  if (GNUNET_TIME_round_rel (&time_remaining) == 0)
   {
     rollback (pg);
     return ANASTASIS_EC_DB_STATUS_PAYMENT_EXPIRED;
@@ -324,6 +327,7 @@ postgres_store_recovery_document (void *cls,
     break;
   default:
     // FIXME: Some Action
+    rollback (pg);
     return qs;
   }
 
@@ -364,6 +368,7 @@ postgres_store_recovery_document (void *cls,
     break;
   default:
     // FIXME: Some Action
+    rollback (pg);
     return qs;
   }
 
@@ -400,13 +405,14 @@ postgres_store_recovery_document (void *cls,
     break;
   default:
     // FIXME: Some Action
+    rollback (pg);
     return qs;
   }
 
   {
     struct GNUNET_PQ_QueryParam params[] = {
       GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
-      GNUNET_PQ_query_param_auto_from_type (version),
+      GNUNET_PQ_query_param_uint32 (version),
       GNUNET_PQ_query_param_fixed_size (data, data_size),
       GNUNET_PQ_query_param_end
     };
@@ -432,6 +438,7 @@ postgres_store_recovery_document (void *cls,
     break;
   default:
     // FIXME: Some Action
+    rollback (pg);
     return qs;
   }
 
@@ -506,6 +513,7 @@ postgres_record_payment (void *cls,
       break;
     default:
       // FIXME: Some Action
+      rollback (pg);
       return qs;
     }
   }
@@ -554,6 +562,7 @@ postgres_record_payment (void *cls,
     break;
   default:
     // FIXME: Some Action
+    rollback (pg);
     return qs;
   }
 
@@ -585,6 +594,7 @@ postgres_record_payment (void *cls,
       break;
     default:
       // FIXME: Some Action
+      rollback (pg);
       return qs;
     }
   }
diff --git a/src/backup-db/test_anastasis_db.c 
b/src/backup-db/test_anastasis_db.c
index 5c00557..3f06bf2 100644
--- a/src/backup-db/test_anastasis_db.c
+++ b/src/backup-db/test_anastasis_db.c
@@ -149,7 +149,6 @@ static void
 run (void *cls)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg = cls;
-  struct GNUNET_TIME_Relative rel_time;
 
   if (NULL == (plugin = ANASTASIS_DB_plugin_load (cfg)))
   {
@@ -171,12 +170,13 @@ run (void *cls)
   }
 
   uint32_t recversion = 1;
+  
   RND_BLK (&accountPubP);
 
   int rec_val = 100;
   recovery_data = &rec_val;
   RND_BLK (recovery_data);
-  
+
   RND_BLK (&paymentSecretP);
 
   int truth_val = 300;
@@ -191,22 +191,24 @@ run (void *cls)
   mime_type = "Picture";
   TALER_string_to_amount ("EUR:30",&amount);
   uuid = (struct ANASTASIS_uuid) {"550e8400-e29b-11d4-a716-446655440000"};
+  struct GNUNET_TIME_Relative rel_time;
+  rel_time.rel_value_us = (uint64_t) 50 * 1000LL;
 
-  FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
-          plugin->store_recovery_document (plugin->cls,
-                                           &accountPubP,
-                                           &recovery_data,
-                                           sizeof (&recovery_data),
-                                           &paymentSecretP,
-                                           version));
- 
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->record_payment (plugin->cls,
                                   &amount,
                                   &accountPubP,
                                   post_counter,
                                   rel_time,
-                                  &paymentSecretP));
+                                  &paymentSecretP));   
+
+  FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
+          plugin->store_recovery_document (plugin->cls,
+                                           &accountPubP,
+                                           &recovery_data,
+                                           sizeof (&recovery_data),
+                                           &paymentSecretP,
+                                           version));  
 
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->store_truth (plugin->cls,
@@ -220,23 +222,23 @@ run (void *cls)
 
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_escrow_challenge (plugin->cls,
-                               &uuid,
-                               truth,
-                               truthsize,
-                               res_mime_type));
+                                        &uuid,
+                                        truth,
+                                        truthsize,
+                                        res_mime_type));
 
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_key_share (plugin->cls,
-                               &uuid,
-                               res_key_share,
-                               keysharesize));
+                                 &uuid,
+                                 res_key_share,
+                                 keysharesize));
 
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_latest_recovery_document (plugin->cls,
-                               &accountPubP,
-                               recoverydatasize,
-                               res_recovery_data,
-                               res_version));
+                                                &accountPubP,
+                                                recoverydatasize,
+                                                res_recovery_data,
+                                                res_version));
 
   FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_recovery_document (plugin->cls,

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



reply via email to

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