gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 11/12: fix secret_share_payment_cb, fix configs


From: gnunet
Subject: [taler-anastasis] 11/12: fix secret_share_payment_cb, fix configs
Date: Mon, 07 Dec 2020 20:28:45 +0100

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

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

commit eb2926b567497289024aec900f3e814ca370ac1d
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Mon Dec 7 20:27:06 2020 +0100

    fix secret_share_payment_cb, fix configs
---
 src/backend/anastasis-httpd_policy_upload.c      |  4 +--
 src/cli/test_anastasis_reducer.conf              | 10 +++----
 src/cli/test_anastasis_reducer_1.conf            | 12 ++++-----
 src/cli/test_anastasis_reducer_2.conf            | 12 ++++-----
 src/cli/test_anastasis_reducer_3.conf            |  8 +++---
 src/cli/test_anastasis_reducer_enter_secret.sh   | 21 ++++++++++-----
 src/cli/test_anastasis_reducer_select_country.sh |  9 +++++++
 src/lib/anastasis.c                              |  1 -
 src/lib/anastasis_api_backup_redux.c             | 34 +++++++++++++++---------
 9 files changed, 69 insertions(+), 42 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index f90e60d..4c077ec 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -879,7 +879,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
           if (qs == 0)
           {
             // generate new payment identifier
-            GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+            GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
                                         &puc->payment_identifier,
                                         sizeof (
                                           struct ANASTASIS_PaymentSecretP));
@@ -907,7 +907,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
       if (! puc->payment_identifier_provided)
       {
         // generate new payment identifier
-        GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+        GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
                                     &puc->payment_identifier,
                                     sizeof (
                                       struct ANASTASIS_PaymentSecretP));
diff --git a/src/cli/test_anastasis_reducer.conf 
b/src/cli/test_anastasis_reducer.conf
index 9ac92a6..db12c75 100644
--- a/src/cli/test_anastasis_reducer.conf
+++ b/src/cli/test_anastasis_reducer.conf
@@ -37,12 +37,12 @@ DB = postgres
 # BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
-PAYMENT_BACKEND_URL = http://localhost:8080/
+PAYMENT_BACKEND_URL = http://localhost:9966/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
-#ANNUAL_FEE = TESTKUDOS:4.99
-ANNUAL_FEE = TESTKUDOS:0
+ANNUAL_FEE = TESTKUDOS:4.99
+#ANNUAL_FEE = TESTKUDOS:0
 #ANNUAL_FEE = EUR:0
 
 # Cost of authentication by question
@@ -64,7 +64,7 @@ FILE_COST = TESTKUDOS:1.0
 SERVER_SALT = AUfO1KGOKYIFlFQg
 
 # This specifies which database the postgres backend uses.
-[anastasisdb-postgres]
+[stasis-postgres]
 CONFIG = postgres:///anastasischeck
 
 ##########################################
@@ -77,7 +77,7 @@ INSTANCES = default tor
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
-PORT = 8080
+PORT = 9966
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
diff --git a/src/cli/test_anastasis_reducer_1.conf 
b/src/cli/test_anastasis_reducer_1.conf
index 517f1c8..5270e19 100644
--- a/src/cli/test_anastasis_reducer_1.conf
+++ b/src/cli/test_anastasis_reducer_1.conf
@@ -37,12 +37,12 @@ DB = postgres
 # BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
-PAYMENT_BACKEND_URL = http://localhost:8080/
+PAYMENT_BACKEND_URL = http://localhost:9966/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
-#ANNUAL_FEE = TESTKUDOS:1.99
-ANNUAL_FEE = TESTKUDOS:0
+ANNUAL_FEE = TESTKUDOS:1.99
+#ANNUAL_FEE = TESTKUDOS:0
 #ANNUAL_FEE = EUR:0
 
 # Cost of authentication by question
@@ -64,8 +64,8 @@ SUPPORTED_METHODS = question
 SERVER_SALT = BUfO1KGOKYIFlFQg
 
 # This specifies which database the postgres backend uses.
-[anastasisdb-postgres]
-CONFIG = postgres:///anastasischeck
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck1
 
 ##########################################
 # Configuration for the merchant backend #
@@ -77,7 +77,7 @@ INSTANCES = default tor
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
-PORT = 8080
+PORT = 9966
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
diff --git a/src/cli/test_anastasis_reducer_2.conf 
b/src/cli/test_anastasis_reducer_2.conf
index 8e8cc65..b5182a3 100644
--- a/src/cli/test_anastasis_reducer_2.conf
+++ b/src/cli/test_anastasis_reducer_2.conf
@@ -37,12 +37,12 @@ DB = postgres
 # BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
-PAYMENT_BACKEND_URL = http://localhost:8080/
+PAYMENT_BACKEND_URL = http://localhost:9966/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
-#ANNUAL_FEE = TESTKUDOS:4.99
-ANNUAL_FEE = TESTKUDOS:0
+ANNUAL_FEE = TESTKUDOS:4.99
+#ANNUAL_FEE = TESTKUDOS:0
 #ANNUAL_FEE = EUR:0
 
 # Cost of authentication by question
@@ -64,8 +64,8 @@ SUPPORTED_METHODS = question
 SERVER_SALT = CUfO1KGOKYIFlFQg
 
 # This specifies which database the postgres backend uses.
-[anastasisdb-postgres]
-CONFIG = postgres:///anastasischeck
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck2
 
 ##########################################
 # Configuration for the merchant backend #
@@ -77,7 +77,7 @@ INSTANCES = default tor
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
-PORT = 8080
+PORT = 9966
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
diff --git a/src/cli/test_anastasis_reducer_3.conf 
b/src/cli/test_anastasis_reducer_3.conf
index d609307..064fc35 100644
--- a/src/cli/test_anastasis_reducer_3.conf
+++ b/src/cli/test_anastasis_reducer_3.conf
@@ -37,7 +37,7 @@ DB = postgres
 # BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
-PAYMENT_BACKEND_URL = http://localhost:8080/
+PAYMENT_BACKEND_URL = http://localhost:9966/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
@@ -64,8 +64,8 @@ UPLOAD_LIMIT_MB = 1
 SUPPORTED_METHODS = question
 
 # This specifies which database the postgres backend uses.
-[anastasisdb-postgres]
-CONFIG = postgres:///anastasischeck
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck3
 
 ##########################################
 # Configuration for the merchant backend #
@@ -77,7 +77,7 @@ INSTANCES = default tor
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
-PORT = 8080
+PORT = 9966
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh 
b/src/cli/test_anastasis_reducer_enter_secret.sh
index 7573822..fbca9ff 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -33,7 +33,7 @@ CONF_2=`mktemp test_reducerXXXXXX_2.conf`
 CONF_3=`mktemp test_reducerXXXXXX_3.conf`
 CONF_4=`mktemp test_reducerXXXXXX_4.conf`
 SFILE=ressources/test_reducer_stateSESTATE
-TFILE=ressources/test_reducer_stateBFSTATE
+TFILE=ressources/test_reducer_statePPSTATE
 
 trap cleanup EXIT
 
@@ -63,6 +63,9 @@ echo " FOUND"
 # elsewhere
 TALER_DB=talercheck
 ANASTASIS_DB=anastasischeck
+ANASTASIS_DB_1=anastasischeck1
+ANASTASIS_DB_2=anastasischeck2
+ANASTASIS_DB_3=anastasischeck3
 
 # delete existing wallet database
 rm -f $WALLET_DB
@@ -84,6 +87,12 @@ dropdb $TALER_DB >/dev/null 2>/dev/null || true
 createdb $TALER_DB || exit_skip "Could not create database $TALER_DB"
 dropdb $ANASTASIS_DB >/dev/null 2>/dev/null || true
 createdb $ANASTASIS_DB || exit_skip "Could not create database $ANASTASIS_DB"
+dropdb $ANASTASIS_DB_1 >/dev/null 2>/dev/null || true
+createdb $ANASTASIS_DB_1 || exit_skip "Could not create database 
$ANASTASIS_DB_1"
+dropdb $ANASTASIS_DB_2 >/dev/null 2>/dev/null || true
+createdb $ANASTASIS_DB_2 || exit_skip "Could not create database 
$ANASTASIS_DB_2"
+dropdb $ANASTASIS_DB_3 >/dev/null 2>/dev/null || true
+createdb $ANASTASIS_DB_3 || exit_skip "Could not create database 
$ANASTASIS_DB_3"
 
 # obtain key configuration data
 MASTER_PRIV_FILE=`taler-config -f -c $CONF -s EXCHANGE -o MASTER_PRIV_FILE`
@@ -133,10 +142,10 @@ taler-exchange-wirewatch -c $CONF 2> 
taler-exchange-wirewatch.log &
 taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log &
 
 echo "Launching anastasis service"
-anastasis-httpd -c $CONF_1 2> anastasis-httpd_1.log &
-anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
-anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
-anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
+valgrind anastasis-httpd -c $CONF_1 2> anastasis-httpd_1.log &
+valgrind anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
+valgrind anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
+valgrind anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
 
 # Wait for anastasis service to be available
 for n in `seq 1 50`
@@ -191,7 +200,7 @@ touch $TFILE
   enter_secret $SFILE $TFILE
 
 STATE=`jq -r -e .backup_state < $TFILE`
-if test "$STATE" != "BACKUP_FINISHED"
+if test "$STATE" != "POLICIES_PAYING"
 then
     exit_fail "Expected new state to be BACKUP_FINISHED, got $STATE"
 fi
diff --git a/src/cli/test_anastasis_reducer_select_country.sh 
b/src/cli/test_anastasis_reducer_select_country.sh
index d4f8498..dfa8593 100755
--- a/src/cli/test_anastasis_reducer_select_country.sh
+++ b/src/cli/test_anastasis_reducer_select_country.sh
@@ -51,6 +51,9 @@ echo " FOUND"
 # Will be dropped, do NOT use anything that might be used
 # elsewhere
 TARGET_DB=anastasischeck
+TARGET_DB_1=anastasischeck1
+TARGET_DB_2=anastasischeck2
+TARGET_DB_3=anastasischeck3
 
 # Configuration file will be edited, so we create one
 # from the template.
@@ -62,6 +65,12 @@ cp test_anastasis_reducer_3.conf $CONF_4
 # reset database
 dropdb $TARGET_DB >/dev/null 2>/dev/null || true
 createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
+dropdb $TARGET_DB_1 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_1 || exit_skip "Could not create database $TARGET_DB_1"
+dropdb $TARGET_DB_2 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_2 || exit_skip "Could not create database $TARGET_DB_2"
+dropdb $TARGET_DB_3 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_3 || exit_skip "Could not create database $TARGET_DB_3"
 
 # Launch services
 echo "Launching anastasis service"
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 1626796..cb2b4a5 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -1666,7 +1666,6 @@ policy_store_cb (void *cls,
                 ec,
                 http_status);
       pss->src = NULL;
-      ANASTASIS_secret_share_cancel (pss->ss);
     }
     return;
   }
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 809408b..04fc979 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -1184,13 +1184,15 @@ done_policy_review (json_t *state,
 
 
 /**
- * Check if all uploads passed (status code 204).
+ * Check if all uploads have response code 204 or 402.
  *
  * @param uploads json array representing uploads (truth, recovery document)
- * @return true if all uploads passed, else false
+ * @param pass if true, all response codes must be 204 to return true
+ * @return true if all response codes are 204 or 402, else false
  */
 static bool
-check_uploads (json_t *uploads)
+check_uploads (json_t *uploads,
+               bool pass)
 {
   GNUNET_assert (json_is_array (uploads));
   size_t index;
@@ -1200,7 +1202,10 @@ check_uploads (json_t *uploads)
   {
     int status = json_integer_value (json_object_get (upload,
                                                       "status"));
-    if (status != 204)
+    if (pass && (status != 204))
+      return false;
+    if ((status != 204)&&
+        (status != 402) )
     {
       return false;
     }
@@ -1334,7 +1339,7 @@ secret_share_payment_cb (void *cls,
   {
     const char *url = json_string_value (
       json_object_get (upload,
-                       "backend_url"));
+                       "provider_url"));
     if (0 == strcmp (url, server_url))
     {
       GNUNET_assert (0 ==
@@ -1376,10 +1381,13 @@ secret_share_payment_cb (void *cls,
   set_state (sss->state,
              ANASTASIS_backup_state_to_string (
                ANASTASIS_BACKUP_STATE_POLICIES_PAYING));
-  sss->cb (sss->cb_cls,
-           ANASTASIS_EC_NONE,
-           sss->state);
-  sss->cb = NULL;
+  if (check_uploads (rec_doc_uploads, false))
+  {
+    sss->cb (sss->cb_cls,
+             ANASTASIS_EC_NONE,
+             sss->state);
+    sss->cb = NULL;
+  }
   // FIXME: payment
 }
 
@@ -1441,12 +1449,14 @@ secret_share_result_cb (void *cls,
                 http_status);
     if (http_status == sss->http_status)
     {
-      if (check_uploads (rec_doc_uploads))
+      if (check_uploads (rec_doc_uploads, true))
       {
         set_state (sss->state,
                    ANASTASIS_backup_state_to_string (
                      ANASTASIS_BACKUP_STATE_BACKUP_FINISHED));
-
+      }
+      if (check_uploads (rec_doc_uploads, false))
+      {
         sss->cb (sss->cb_cls,
                  ANASTASIS_EC_NONE,
                  sss->state);
@@ -1611,7 +1621,7 @@ truth_upload_cb (void *cls,
                                   json_integer ((json_int_t) 204)));
   tus->truth = t;
 
-  if (check_uploads (truth_uploads) &&
+  if (check_uploads (truth_uploads, true) &&
       (json_array_size (
          json_object_get (tus->state, "truths"))
        == (size_t) tus_arr_length))

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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