gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated: check return value


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: check return value from TALER_string_to_amount, even in test
Date: Mon, 03 Jun 2019 00:38:10 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new f5198e9  check return value from TALER_string_to_amount, even in test
f5198e9 is described below

commit f5198e99297bc56854309818bafd5f397c6eabf1
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Jun 3 00:38:07 2019 +0200

    check return value from TALER_string_to_amount, even in test
---
 src/backend/taler-merchant-httpd_check-payment.c |  5 +-
 src/lib/testing_api_cmd_track.c                  | 86 ++++++++++++++++--------
 2 files changed, 62 insertions(+), 29 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_check-payment.c 
b/src/backend/taler-merchant-httpd_check-payment.c
index 902087f..340770f 100644
--- a/src/backend/taler-merchant-httpd_check-payment.c
+++ b/src/backend/taler-merchant-httpd_check-payment.c
@@ -141,7 +141,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
   if (NULL == contract_url)
   {
     final_contract_url = TALER_url_absolute_mhd (connection,
-                                                "/public/proposal",
+                                                 "/public/proposal",
                                                  "instance", instance_str,
                                                  "order_id", order_id,
                                                  NULL);
@@ -331,7 +331,8 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
 
 do_pay:
   {
-    char *url = TALER_url_absolute_mhd (connection, "public/trigger-pay",
+    char *url = TALER_url_absolute_mhd (connection,
+                                        "public/trigger-pay",
                                         "contract_url", final_contract_url,
                                         "session_id", session_id,
                                         "resource_url", resource_url,
diff --git a/src/lib/testing_api_cmd_track.c b/src/lib/testing_api_cmd_track.c
index 210263a..f6dc2d2 100644
--- a/src/lib/testing_api_cmd_track.c
+++ b/src/lib/testing_api_cmd_track.c
@@ -67,7 +67,7 @@ struct TrackTransactionState
    * behaviour if _multiple_ wire transfers were
    * issued to pay this contract back.
    */
-  const char *wtid_str; 
+  const char *wtid_str;
 
   /**
    * Binary form of @a wtid_str, expected by other commands
@@ -101,7 +101,7 @@ struct TrackTransferState
    */
   struct TALER_TESTING_Interpreter *is;
 
-  /** 
+  /**
    * Base URL of the merchant serving the request.
    */
   const char *merchant_url;
@@ -111,7 +111,6 @@ struct TrackTransferState
    */
   unsigned int http_status;
 
-
   /**
    * Reference for a "check bank" CMD.  It offers the
    * WTID to track.
@@ -161,22 +160,22 @@ track_transaction_cb (void *cls,
     /* Only storing first element's wtid, as this works around
      * the disability of the real bank to provide a "bank check"
      * CMD as the fakebank does.  */
-  
+
     if (NULL == (wtid_str = json_object_get
       (json_array_get (json, 0), "wtid")))
     {
       TALER_TESTING_interpreter_fail (tts->is);
-      return; 
+      return;
     }
-  
+
     if (NULL == (exchange_url = json_object_get
       (json_array_get (json, 0), "exchange")))
     {
-    
+
       TALER_TESTING_interpreter_fail (tts->is);
       return;
     }
-  
+
     tts->exchange_url = GNUNET_strdup
       (json_string_value (exchange_url));
     tts->wtid_str = GNUNET_strdup
@@ -245,20 +244,35 @@ track_transfer_cb
       struct TALER_Amount amount_iter;
       struct TALER_Amount deposit_fee_iter;
       struct TALER_Amount sum;
-
       size_t index;
       json_t *value;
 
       amount_str = json_string_value
         (json_object_get (json,
                           "total"));
-      TALER_string_to_amount (amount_str,
-                              &total);
+      if (GNUNET_OK !=
+          TALER_string_to_amount (amount_str,
+                                  &total))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Failed to parse amount `%s'\n",
+                    amount_str);
+        TALER_TESTING_FAIL (tts->is);
+        return;
+      }
       amount_str = json_string_value
         (json_object_get (json,
                           "wire_fee"));
-      TALER_string_to_amount (amount_str,
-                              &wire_fee);
+      if (GNUNET_OK !=
+          TALER_string_to_amount (amount_str,
+                                  &wire_fee))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Failed to parse amount `%s'\n",
+                    amount_str);
+        TALER_TESTING_FAIL (tts->is);
+        return;
+      }
       TALER_amount_get_zero (total.currency,
                              &sum);
       deposits = json_object_get (json,
@@ -268,24 +282,43 @@ track_transfer_cb
         amount_str = json_string_value
           (json_object_get (value,
                             "deposit_value"));
-        TALER_string_to_amount (amount_str,
-                                &amount_iter);
+        if (GNUNET_OK !=
+            TALER_string_to_amount (amount_str,
+                                    &amount_iter))
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Failed to parse amount `%s'\n",
+                      amount_str);
+          TALER_TESTING_FAIL (tts->is);
+          return;
+        }
         amount_str = json_string_value
           (json_object_get (value,
                             "deposit_fee"));
-        TALER_string_to_amount (amount_str,
-                                &deposit_fee_iter);
-        TALER_amount_add (&sum,
-                          &sum,
-                          &amount_iter);
-        TALER_amount_subtract (&sum,
-                               &sum,
-                               &deposit_fee_iter);
+        if (GNUNET_OK !=
+            TALER_string_to_amount (amount_str,
+                                    &deposit_fee_iter))
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Failed to parse amount `%s'\n",
+                      amount_str);
+          TALER_TESTING_FAIL (tts->is);
+          return;
+        }
+        GNUNET_assert (GNUNET_SYSERR !=
+                       TALER_amount_add (&sum,
+                                         &sum,
+                                         &amount_iter));
+        GNUNET_assert (GNUNET_SYSERR !=
+                       TALER_amount_subtract (&sum,
+                                              &sum,
+                                              &deposit_fee_iter));
       }
 
-      TALER_amount_subtract (&sum,
-                             &sum,
-                             &wire_fee);
+      GNUNET_assert (GNUNET_SYSERR !=
+                     TALER_amount_subtract (&sum,
+                                            &sum,
+                                            &wire_fee));
       if (0 != TALER_amount_cmp (&sum,
                                  &total))
       {
@@ -366,7 +399,6 @@ track_transaction_run (void *cls,
   const struct TALER_TESTING_Command *pay_cmd;
 
   tts->is = is;
-
   if ( NULL ==
      ( pay_cmd = TALER_TESTING_interpreter_lookup_command
       (is, tts->pay_reference)))

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



reply via email to

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