gnunet-svn
[Top][All Lists]
Advanced

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

[taler-sync] branch master updated: only use prev hash if it succeeded


From: gnunet
Subject: [taler-sync] branch master updated: only use prev hash if it succeeded
Date: Sat, 30 Nov 2019 00:23:49 +0100

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

grothoff pushed a commit to branch master
in repository sync.

The following commit(s) were added to refs/heads/master by this push:
     new 7f69911  only use prev hash if it succeeded
7f69911 is described below

commit 7f699113231130004c4535036f1de48edafe81aa
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Nov 30 00:23:46 2019 +0100

    only use prev hash if it succeeded
---
 src/lib/test_sync_api.c                 | 13 +++++++++++++
 src/lib/testing_api_cmd_backup_upload.c |  6 +++++-
 src/sync/sync-httpd_backup_post.c       |  7 +++++++
 src/syncdb/plugin_syncdb_postgres.c     | 13 +++++++++++++
 4 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/src/lib/test_sync_api.c b/src/lib/test_sync_api.c
index cae8068..25cd08f 100644
--- a/src/lib/test_sync_api.c
+++ b/src/lib/test_sync_api.c
@@ -185,8 +185,10 @@ run (void *cls,
       "create-reserve-1",
       "EUR:5",
       MHD_HTTP_OK),
+    /* Failed download: no backup exists */
     SYNC_TESTING_cmd_backup_nx ("backup-download-nx",
                                 sync_url),
+    /* Failed upload: need to pay */
     SYNC_TESTING_cmd_backup_upload ("backup-upload-1",
                                     sync_url,
                                     NULL /* prev upload */,
@@ -194,11 +196,13 @@ run (void *cls,
                                     MHD_HTTP_PAYMENT_REQUIRED,
                                     "Test-1",
                                     strlen ("Test-1")),
+    /* what would we have to pay? */
     TALER_TESTING_cmd_proposal_lookup ("fetch-proposal",
                                        merchant_url,
                                        MHD_HTTP_OK,
                                        "backup-upload-1",
                                        NULL),
+    /* make the payment */
     TALER_TESTING_cmd_pay ("pay-account",
                            merchant_url,
                            MHD_HTTP_OK,
@@ -207,6 +211,15 @@ run (void *cls,
                            "EUR:5",
                            "EUR:4.99", /* must match ANNUAL_FEE in config! */
                            "EUR:0.01"),
+    /* now upload should succeed */
+    SYNC_TESTING_cmd_backup_upload ("backup-upload-2",
+                                    sync_url,
+                                    "backup-upload-1",
+                                    SYNC_TESTING_UO_NONE,
+                                    MHD_HTTP_NO_CONTENT,
+                                    "Test-1",
+                                    strlen ("Test-1")),
+
     TALER_TESTING_cmd_end ()
   };
 
diff --git a/src/lib/testing_api_cmd_backup_upload.c 
b/src/lib/testing_api_cmd_backup_upload.c
index 6ed228a..bdbd374 100644
--- a/src/lib/testing_api_cmd_backup_upload.c
+++ b/src/lib/testing_api_cmd_backup_upload.c
@@ -186,6 +186,9 @@ backup_upload_cb (void *cls,
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     "Order ID from Sync service is `%s'\n",
                     bus->payment_order_id);
+        memset (&bus->curr_hash,
+                0,
+                sizeof (struct GNUNET_HashCode));
       }
       break;
     case SYNC_US_CONFLICTING_BACKUP:
@@ -338,7 +341,8 @@ backup_upload_run (void *cls,
   bus->uo = SYNC_upload (is->ctx,
                          bus->sync_url,
                          &bus->sync_priv,
-                         ( (NULL != bus->prev_upload) ||
+                         ( ( (NULL != bus->prev_upload) &&
+                             (0 != GNUNET_is_zero (&bus->prev_hash)) ) ||
                            (0 != (SYNC_TESTING_UO_PREV_HASH_WRONG
                                   & bus->uopt)) )
                          ? &bus->prev_hash
diff --git a/src/sync/sync-httpd_backup_post.c 
b/src/sync/sync-httpd_backup_post.c
index 6562b0e..f203691 100644
--- a/src/sync/sync-httpd_backup_post.c
+++ b/src/sync/sync-httpd_backup_post.c
@@ -824,6 +824,13 @@ sync_handler_backup_post (struct MHD_Connection 
*connection,
     *upload_data_size = 0;
     return MHD_YES;
   }
+  else if ( (0 == bc->upload_off) &&
+            (0 != bc->upload_size) &&
+            (NULL == bc->resp) )
+  {
+    /* wait for upload */
+    return MHD_YES;
+  }
   if (NULL != bc->resp)
   {
     int ret;
diff --git a/src/syncdb/plugin_syncdb_postgres.c 
b/src/syncdb/plugin_syncdb_postgres.c
index 61b192c..4273d75 100644
--- a/src/syncdb/plugin_syncdb_postgres.c
+++ b/src/syncdb/plugin_syncdb_postgres.c
@@ -1181,6 +1181,19 @@ libsync_plugin_db_postgres_init (void *cls)
     GNUNET_free (pg);
     return NULL;
   }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "taler",
+                                             "CURRENCY",
+                                             &pg->currency))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               "taler",
+                               "CURRENCY");
+    GNUNET_PQ_disconnect (pg->conn);
+    GNUNET_free (pg);
+    return NULL;
+  }
   plugin = GNUNET_new (struct SYNC_DatabasePlugin);
   plugin->cls = pg;
   plugin->drop_tables = &postgres_drop_tables;

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



reply via email to

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