gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: -fix new payment logic


From: gnunet
Subject: [taler-anastasis] branch master updated: -fix new payment logic
Date: Sun, 11 Jul 2021 18:34:52 +0200

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 6b3d181  -fix new payment logic
6b3d181 is described below

commit 6b3d1816fe611844d7374cdafcf1f02cb9fd6333
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Jul 11 18:34:50 2021 +0200

    -fix new payment logic
---
 src/backend/anastasis-httpd_policy_upload.c        | 22 +++++++++++++++++-
 src/backend/anastasis-httpd_truth_upload.c         | 26 +++++++++++++++++++---
 ...tasis_reducer_recovery_enter_user_attributes.sh | 10 +++++----
 src/stasis/plugin_anastasis_postgres.c             |  2 +-
 4 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index 1c09a3c..da99db5 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -424,8 +424,28 @@ check_payment_cb (void *cls,
       enum GNUNET_DB_QueryStatus qs;
       unsigned int years;
       struct GNUNET_TIME_Relative paid_until;
+      const json_t *contract;
+      struct TALER_Amount amount;
+      struct GNUNET_JSON_Specification cspec[] = {
+        TALER_JSON_spec_amount ("amount",
+                                &amount),
+        GNUNET_JSON_spec_end ()
+      };
 
-      years = TALER_amount_divide2 (&osr->details.paid.deposit_total,
+      contract = osr->details.paid.contract_terms;
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (contract,
+                             cspec,
+                             NULL, NULL))
+      {
+        GNUNET_break (0);
+        puc->resp = TALER_MHD_make_error (
+          TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID,
+          "no amount given");
+        puc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+        return; /* continue as planned */
+      }
+      years = TALER_amount_divide2 (&amount,
                                     &AH_annual_fee);
       paid_until = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
                                                   years);
diff --git a/src/backend/anastasis-httpd_truth_upload.c 
b/src/backend/anastasis-httpd_truth_upload.c
index 56000f8..f9a609f 100644
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth_upload.c
@@ -319,8 +319,28 @@ check_payment_cb (void *cls,
         enum GNUNET_DB_QueryStatus qs;
         unsigned int years;
         struct GNUNET_TIME_Relative paid_until;
-
-        years = TALER_amount_divide2 (&osr->details.paid.deposit_total,
+        const json_t *contract;
+        struct TALER_Amount amount;
+        struct GNUNET_JSON_Specification cspec[] = {
+          TALER_JSON_spec_amount ("amount",
+                                  &amount),
+          GNUNET_JSON_spec_end ()
+        };
+
+        contract = osr->details.paid.contract_terms;
+        if (GNUNET_OK !=
+            GNUNET_JSON_parse (contract,
+                               cspec,
+                               NULL, NULL))
+        {
+          GNUNET_break (0);
+          tuc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+          tuc->resp = TALER_MHD_make_error (
+            TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID,
+            "contract terms in database are malformed");
+          break;
+        }
+        years = TALER_amount_divide2 (&amount,
                                       &AH_truth_upload_fee);
         paid_until = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
                                                     years);
@@ -338,7 +358,7 @@ check_payment_cb (void *cls,
           &tuc->truth_uuid,
           &osr->details.paid.deposit_total,
           paid_until);
-        if (qs < 0)
+        if (qs <= 0)
         {
           GNUNET_break (0);
           tuc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
diff --git a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh 
b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
index 403bc89..646050a 100755
--- a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
@@ -364,7 +364,6 @@ echo -e "Payments done"
 
 export B2FILE
 export B1FILE
-bash
 
 echo -en "Try to upload again ..."
 $PREFIX anastasis-reducer pay $B2FILE $B1FILE
@@ -477,24 +476,27 @@ echo " OK"
 
 echo -n "Checking recovered secret ..."
 # finally: check here that we recovered the secret...
-
+export R2FILE
+export R1FILE
+bash
 STATE=`jq -r -e .recovery_state < $R2FILE`
 if test "$STATE" != "RECOVERY_FINISHED"
 then
-    jq < $R2FILE
+    jq -e . $R2FILE
     exit_fail "Expected new state to be 'RECOVERY_FINISHED', got '$STATE'"
 fi
 
 SECRET=`jq -r -e .core_secret.value < $R2FILE`
 if test "$SECRET" != "VERYHARDT0GVESSSECRET"
 then
-    jq < $R2FILE
+    jq -e . $R2FILE
     exit_fail "Expected recovered secret to be 'VERYHARDT0GVESSSECRET', got 
'$SECRET'"
 fi
 
 MIME=`jq -r -e .core_secret.mime < $R2FILE`
 if test "$MIME" != "text/plain"
 then
+    jq -e . $R2FILE
     exit_fail "Expected recovered mime to be 'text/plain', got '$MIME'"
 fi
 
diff --git a/src/stasis/plugin_anastasis_postgres.c 
b/src/stasis/plugin_anastasis_postgres.c
index ded8d0c..d18456a 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -983,9 +983,9 @@ postgres_store_truth (
   };
 
 
-  GNUNET_TIME_round_abs (&expiration);
   expiration = GNUNET_TIME_absolute_add (expiration,
                                          truth_expiration);
+  GNUNET_TIME_round_abs (&expiration);
   check_connection (pg);
   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
                                              "truth_insert",

-- 
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]