gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -add batch withdraw to test suit


From: gnunet
Subject: [taler-exchange] branch master updated: -add batch withdraw to test suite
Date: Mon, 30 May 2022 17:51:41 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new ab4aa4dc -add batch withdraw to test suite
ab4aa4dc is described below

commit ab4aa4dcfd3477971b3fb0c81a4caffff953c145
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon May 30 17:51:39 2022 +0200

    -add batch withdraw to test suite
---
 src/json/json_helper.c                 | 11 ++++--
 src/lib/exchange_api_batch_withdraw.c  |  3 ++
 src/lib/exchange_api_batch_withdraw2.c |  2 +-
 src/testing/test_exchange_api.c        | 71 +++++++++++++++++++++++++++++++++-
 4 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index 4896fb59..50d4705d 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -347,6 +347,7 @@ TALER_JSON_spec_denom_pub (const char *field,
     .ptr = pk
   };
 
+  pk->cipher = TALER_DENOMINATION_INVALID;
   return ret;
 }
 
@@ -463,6 +464,7 @@ TALER_JSON_spec_denom_sig (const char *field,
     .ptr = sig
   };
 
+  sig->cipher = TALER_DENOMINATION_INVALID;
   return ret;
 }
 
@@ -582,6 +584,7 @@ TALER_JSON_spec_blinded_denom_sig (
     .ptr = sig
   };
 
+  sig->cipher = TALER_DENOMINATION_INVALID;
   return ret;
 }
 
@@ -705,6 +708,7 @@ TALER_JSON_spec_blinded_planchet (const char *field,
     .ptr = blinded_planchet
   };
 
+  blinded_planchet->cipher = TALER_DENOMINATION_INVALID;
   return ret;
 }
 
@@ -780,9 +784,9 @@ parse_exchange_withdraw_values (void *cls,
 
 
 struct GNUNET_JSON_Specification
-TALER_JSON_spec_exchange_withdraw_values (const char *field,
-                                          struct TALER_ExchangeWithdrawValues *
-                                          ewv)
+TALER_JSON_spec_exchange_withdraw_values (
+  const char *field,
+  struct TALER_ExchangeWithdrawValues *ewv)
 {
   struct GNUNET_JSON_Specification ret = {
     .parser = &parse_exchange_withdraw_values,
@@ -790,6 +794,7 @@ TALER_JSON_spec_exchange_withdraw_values (const char *field,
     .ptr = ewv
   };
 
+  ewv->cipher = TALER_DENOMINATION_INVALID;
   return ret;
 }
 
diff --git a/src/lib/exchange_api_batch_withdraw.c 
b/src/lib/exchange_api_batch_withdraw.c
index ce5de3fc..295695d8 100644
--- a/src/lib/exchange_api_batch_withdraw.c
+++ b/src/lib/exchange_api_batch_withdraw.c
@@ -161,6 +161,9 @@ handle_reserve_batch_withdraw_finished (
   struct TALER_EXCHANGE_PrivateCoinDetails coins[wh->num_coins];
 
   wh->wh2 = NULL;
+  memset (coins,
+          0,
+          sizeof (coins));
   if (blind_sigs_length != wh->num_coins)
   {
     GNUNET_break_op (0);
diff --git a/src/lib/exchange_api_batch_withdraw2.c 
b/src/lib/exchange_api_batch_withdraw2.c
index 314bca0c..52da9b40 100644
--- a/src/lib/exchange_api_batch_withdraw2.c
+++ b/src/lib/exchange_api_batch_withdraw2.c
@@ -129,7 +129,7 @@ reserve_batch_withdraw_ok (struct 
TALER_EXCHANGE_BatchWithdraw2Handle *wh,
     };
 
     if (GNUNET_OK !=
-        GNUNET_JSON_parse (json,
+        GNUNET_JSON_parse (j,
                            spec,
                            NULL, NULL))
     {
diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c
index 54cc0e7f..ea929460 100644
--- a/src/testing/test_exchange_api.c
+++ b/src/testing/test_exchange_api.c
@@ -1037,7 +1037,7 @@ run (void *cls,
      * config, then withdraw two coin, partially spend one, and
      * then have the rest paid back.  Check deposit of other coin
      * fails.  Do not use EUR:5 here as the EUR:5 coin was
-     * revoked and we did not bother to create a new one... *///
+     * revoked and we did not bother to create a new one... */
     CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-2",
                               "EUR:2.02"),
     TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2",
@@ -1128,6 +1128,73 @@ run (void *cls,
     TALER_TESTING_cmd_end ()
   };
 
+  /**
+   * Test batch withdrawal plus spending.
+   */
+  struct TALER_TESTING_Command batch_withdraw[] = {
+    /**
+     * Move money to the exchange's bank account.
+     */
+    CMD_TRANSFER_TO_EXCHANGE ("create-batch-reserve-1",
+                              "EUR:6.02"),
+    TALER_TESTING_cmd_reserve_poll ("poll-batch-reserve-1",
+                                    "create-batch-reserve-1",
+                                    "EUR:6.02",
+                                    GNUNET_TIME_UNIT_MINUTES,
+                                    MHD_HTTP_OK),
+    TALER_TESTING_cmd_check_bank_admin_transfer 
("check-create-batch-reserve-1",
+                                                 "EUR:6.02",
+                                                 bc.user42_payto,
+                                                 bc.exchange_payto,
+                                                 "create-batch-reserve-1"),
+    /*
+     * Make a reserve exist, according to the previous
+     * transfer.
+     */
+    CMD_EXEC_WIREWATCH ("wirewatch-batch-1"),
+    TALER_TESTING_cmd_reserve_poll_finish ("finish-poll-batch-reserve-1",
+                                           GNUNET_TIME_UNIT_SECONDS,
+                                           "poll-batch-reserve-1"),
+    /**
+     * Withdraw EUR:5 AND EUR:1.
+     */
+    TALER_TESTING_cmd_batch_withdraw ("batch-withdraw-coin-1",
+                                      "create-batch-reserve-1",
+                                      0,  /* age restriction off */
+                                      MHD_HTTP_OK,
+                                      "EUR:5",
+                                      "EUR:1",
+                                      NULL),
+    /**
+     * Check the reserve is depleted.
+     */
+    TALER_TESTING_cmd_status ("status-batch-1",
+                              "create-batch-reserve-1",
+                              "EUR:0",
+                              MHD_HTTP_OK),
+    /**
+     * Spend the coins.
+     */
+    TALER_TESTING_cmd_deposit ("deposit-batch-simple-1",
+                               "batch-withdraw-coin-1",
+                               0,
+                               bc.user42_payto,
+                               "{\"items\":[{\"name\":\"ice 
cream\",\"value\":5}]}",
+                               GNUNET_TIME_UNIT_ZERO,
+                               "EUR:5",
+                               MHD_HTTP_OK),
+    TALER_TESTING_cmd_deposit ("deposit-batch-simple-2",
+                               "batch-withdraw-coin-1",
+                               1,
+                               bc.user42_payto,
+                               "{\"items\":[{\"name\":\"ice 
cream\",\"value\":1}]}",
+                               GNUNET_TIME_UNIT_ZERO,
+                               "EUR:1",
+                               MHD_HTTP_OK),
+    TALER_TESTING_cmd_end ()
+  };
+
+
 #define RESERVE_OPEN_CLOSE_CHUNK 4
 #define RESERVE_OPEN_CLOSE_ITERATIONS 3
 
@@ -1204,6 +1271,8 @@ run (void *cls,
                                aggregation),
       TALER_TESTING_cmd_batch ("refund",
                                refund),
+      TALER_TESTING_cmd_batch ("batch-withdraw",
+                               batch_withdraw),
       TALER_TESTING_cmd_batch ("recoup",
                                recoup),
       TALER_TESTING_cmd_batch ("reserve-open-close",

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