gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated (1fc9595b -> f4ee88a


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (1fc9595b -> f4ee88a1)
Date: Wed, 04 Sep 2019 17:08:06 +0200

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

marcello pushed a change to branch master
in repository exchange.

    from 1fc9595b Calling bank legacy API in a test
     new a07d036c More on #5746.
     new f4ee88a1 5746.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |   1 +
 src/wire-plugins/Makefile.am                       |  20 +-
 src/wire-plugins/plugin_wire_taler-bank.c          |   2 -
 ...bank.c => test_wire_plugin_legacy_taler-bank.c} | 223 +++++++++------------
 ...onf => test_wire_plugin_legacy_taler-bank.conf} |   0
 5 files changed, 106 insertions(+), 140 deletions(-)
 copy src/wire-plugins/{test_wire_plugin_transactions_taler-bank.c => 
test_wire_plugin_legacy_taler-bank.c} (69%)
 copy src/wire-plugins/{test_wire_plugin_transactions_taler-bank.conf => 
test_wire_plugin_legacy_taler-bank.conf} (100%)

diff --git a/.gitignore b/.gitignore
index 7d9b47f6..a1639266 100644
--- a/.gitignore
+++ b/.gitignore
@@ -113,3 +113,4 @@ src/lib/test_exchange_api
 src/lib/test_auditor_api
 src/lib/test_exchange_api_overlapping_keys_bug
 src/lib/test_exchange_api_home/.local/share/taler/exchange/revocations/
+src/wire-plugins/test_wire_plugin_legacy_taler_bank
diff --git a/src/wire-plugins/Makefile.am b/src/wire-plugins/Makefile.am
index e46ef48f..83bb9f05 100644
--- a/src/wire-plugins/Makefile.am
+++ b/src/wire-plugins/Makefile.am
@@ -74,13 +74,10 @@ AM_TESTS_ENVIRONMENT=export 
TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=
 TESTS = \
  test_ebics_wireformat \
  test_wire_plugin \
- test_wire_plugin_transactions_taler_bank
-
-check_PROGRAMS= \
- test_ebics_wireformat \
- test_wire_plugin \
- test_wire_plugin_transactions_taler_bank
+ test_wire_plugin_transactions_taler_bank \
+ test_wire_plugin_legacy_taler_bank
 
+check_PROGRAMS= $(TESTS)
 
 test_ebics_wireformat_SOURCES = \
   test_ebics_wireformat.c
@@ -98,6 +95,17 @@ test_wire_plugin_LDADD = \
   $(top_builddir)/src/util/libtalerutil.la
 
 
+test_wire_plugin_legacy_taler_bank_SOURCES = \
+  test_wire_plugin_legacy_taler-bank.c
+test_wire_plugin_legacy_taler_bank_LDADD = \
+  -lgnunetjson \
+  -lgnunetutil \
+  -ljansson \
+  $(top_builddir)/src/wire/libtalerwire.la \
+  $(top_builddir)/src/bank-lib/libtalerbank.la \
+  $(top_builddir)/src/bank-lib/libtalerfakebank.la \
+  $(top_builddir)/src/util/libtalerutil.la
+
 test_wire_plugin_transactions_taler_bank_SOURCES = \
   test_wire_plugin_transactions_taler-bank.c
 test_wire_plugin_transactions_taler_bank_LDADD = \
diff --git a/src/wire-plugins/plugin_wire_taler-bank.c 
b/src/wire-plugins/plugin_wire_taler-bank.c
index f6656637..282856ec 100644
--- a/src/wire-plugins/plugin_wire_taler-bank.c
+++ b/src/wire-plugins/plugin_wire_taler-bank.c
@@ -920,8 +920,6 @@ bhist_cb (void *cls,
     break;
   }
   whh->hh = NULL;
-  taler_bank_get_history_cancel (NULL,
-                                 whh);
 }
 
 
diff --git a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c 
b/src/wire-plugins/test_wire_plugin_legacy_taler-bank.c
similarity index 69%
copy from src/wire-plugins/test_wire_plugin_transactions_taler-bank.c
copy to src/wire-plugins/test_wire_plugin_legacy_taler-bank.c
index 3d7fa76e..9c7c917f 100644
--- a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c
+++ b/src/wire-plugins/test_wire_plugin_legacy_taler-bank.c
@@ -14,9 +14,12 @@
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
 /**
- * @file wire/test_wire_plugin_transactions_taler-bank.c
- * @brief Tests performing actual transactions with the taler-bank wire plugin 
against FAKEBANK
+ * @file wire/test_wire_plugin_legacy_taler-bank.c
+ * @brief Tests legacy history-range API against the Fakebank.
+ *        Version for the real Python bank forthcoming.
+ *
  * @author Christian Grothoff
+ * @author Marcello Stanisci
  */
 #include "platform.h"
 #include "taler_util.h"
@@ -25,13 +28,11 @@
 #include "taler_fakebank_lib.h"
 #include <gnunet/gnunet_json_lib.h>
 
-
 /**
- * When does the test timeout? Right now, we expect this to be very
- * fast.
+ * How many wire transfers this test should accomplish, before
+ * delving into actual checks.
  */
-#define TIMEOUT GNUNET_TIME_UNIT_SECONDS
-
+#define NTRANSACTIONS 5
 
 /**
  * Destination account to use.
@@ -74,30 +75,19 @@ static struct TALER_WIRE_ExecuteHandle *eh;
 static struct TALER_FAKEBANK_Handle *fb;
 
 /**
- * Handle to the history request.
- */
-static struct TALER_WIRE_HistoryHandle *hh;
-
-/**
  * Handle to the history-range request (the "legacy" bank API).
  */
 static struct TALER_WIRE_HistoryHandle *hhr;
 
 /**
- * Handle for the timeout task.
- */
-static struct GNUNET_SCHEDULER_Task *tt;
-
-/**
- * Which serial ID do we expect to get from /history?
- */
-static uint64_t serial_target;
-
-/**
  * Wire transfer identifier we are using.
  */
 static struct TALER_WireTransferIdentifierRawP wtid;
 
+/**
+ * Number of total transaction to make it happen in the test.
+ */
+static int ntransactions = NTRANSACTIONS;
 
 /**
  * Function called on shutdown (regular, error or CTRL-C).
@@ -121,12 +111,6 @@ do_shutdown (void *cls)
                                           ph);
     ph = NULL;
   }
-  if (NULL != hh)
-  {
-    plugin->get_history_cancel (plugin->cls,
-                                hh);
-    hh = NULL;
-  }
 
   if (NULL != hhr)
   {
@@ -135,27 +119,8 @@ do_shutdown (void *cls)
     hhr = NULL;
   }
 
-  if (NULL != tt)
-  {
-    GNUNET_SCHEDULER_cancel (tt);
-    tt = NULL;
-  }
-  TALER_WIRE_plugin_unload (plugin);
-}
-
 
-/**
- * Function called on timeout.
- *
- * @param cls NULL
- */
-static void
-timeout_cb (void *cls)
-{
-  tt = NULL;
-  GNUNET_break (0);
-  global_ret = GNUNET_SYSERR;
-  GNUNET_SCHEDULER_shutdown ();
+  TALER_WIRE_plugin_unload (plugin);
 }
 
 
@@ -182,53 +147,29 @@ history_result_cb
   size_t row_off_size,
   const struct TALER_WIRE_TransferDetails *details)
 {
-  uint64_t *serialp;
-  uint64_t serialh;
-  struct TALER_Amount amount;
+  static int accumulator = 0;
 
-  hh = NULL;
   if ( (TALER_BANK_DIRECTION_NONE == dir) &&
        (GNUNET_OK == global_ret) )
   {
+    /* End-of-list, check all the transactions got accounted
+     * into the history.  */
+    
+    if (NTRANSACTIONS != accumulator)
+    {
+      GNUNET_break (0); 
+      TALER_LOG_ERROR
+        ("Unexpected # of transactions: %d, %d were expected.\n",
+         accumulator,
+         NTRANSACTIONS);
+      global_ret = GNUNET_NO; 
+    }
+
     GNUNET_SCHEDULER_shutdown ();
     return GNUNET_OK;
   }
-  if (sizeof (uint64_t) != row_off_size)
-  {
-    GNUNET_break (0);
-    global_ret = GNUNET_SYSERR;
-    GNUNET_SCHEDULER_shutdown ();
-    return GNUNET_SYSERR;
-  }
-  serialp = (uint64_t *) row_off;
-  serialh = GNUNET_ntohll (*serialp);
-  if (serialh != serial_target)
-  {
-    GNUNET_break (0);
-    global_ret = GNUNET_SYSERR;
-    GNUNET_SCHEDULER_shutdown ();
-    return GNUNET_SYSERR;
-  }
-  GNUNET_assert (GNUNET_OK ==
-                 TALER_string_to_amount ("KUDOS:5.01",
-                                         &amount));
-  if (0 != TALER_amount_cmp (&amount,
-                             &details->amount))
-  {
-    GNUNET_break (0);
-    global_ret = GNUNET_SYSERR;
-    GNUNET_SCHEDULER_shutdown ();
-    return GNUNET_SYSERR;
-  }
-  if (0 != GNUNET_memcmp (&wtid,
-                          &details->wtid))
-  {
-    GNUNET_break (0);
-    global_ret = GNUNET_SYSERR;
-    GNUNET_SCHEDULER_shutdown ();
-    return GNUNET_SYSERR;
-  }
-  global_ret = GNUNET_OK;
+
+  accumulator++;
   return GNUNET_OK;
 }
 
@@ -248,43 +189,7 @@ confirmation_cb (void *cls,
                  int success,
                  const void *row_id,
                  size_t row_id_size,
-                 const char *emsg)
-{
-  uint64_t tmp;
-  eh = NULL;
-  if (GNUNET_OK != success)
-  {
-    GNUNET_break (0);
-    global_ret = GNUNET_SYSERR;
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-
-  memcpy (&tmp,
-          row_id,
-          row_id_size);
-
-  serial_target = GNUNET_ntohll (tmp);
-
-  hh = plugin->get_history (plugin->cls,
-                            my_account,
-                            TALER_BANK_DIRECTION_BOTH,
-                            NULL,
-                            0,
-                            5,
-                            &history_result_cb,
-                            NULL);
-
-  GNUNET_assert
-    (NULL != (hhr = plugin->get_history_range
-       (plugin->cls,
-        my_account,
-        TALER_BANK_DIRECTION_BOTH,
-        GNUNET_TIME_UNIT_ZERO_ABS,
-        GNUNET_TIME_UNIT_FOREVER_ABS,
-        &history_result_cb,
-        NULL)));
-}
+                 const char *emsg);
 
 
 /**
@@ -314,6 +219,62 @@ prepare_cb (void *cls,
                                  NULL);
 }
 
+/**
+ * Function called with the result from the execute step.
+ *
+ * @param cls closure
+ * @param success #GNUNET_OK on success,
+ *        #GNUNET_SYSERR on failure
+ * @param row_id ID of the fresh transaction,
+ *        in _network_ byte order.
+ * @param emsg NULL on success, otherwise an error message
+ */
+static void
+confirmation_cb (void *cls,
+                 int success,
+                 const void *row_id,
+                 size_t row_id_size,
+                 const char *emsg)
+{
+  struct TALER_Amount amount;
+
+  eh = NULL;
+  if (GNUNET_OK != success)
+  {
+    GNUNET_break (0);
+    global_ret = GNUNET_SYSERR;
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+
+  if (0 >= --ntransactions)
+  {
+    GNUNET_assert
+      (NULL != (hhr = plugin->get_history_range
+         (plugin->cls,
+          my_account,
+          TALER_BANK_DIRECTION_BOTH,
+          GNUNET_TIME_UNIT_ZERO_ABS,
+          GNUNET_TIME_UNIT_FOREVER_ABS,
+          &history_result_cb,
+          NULL)));
+    return;
+  }
+
+  /* Issue a new wire transfer!  */
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_string_to_amount ("KUDOS:5.01",
+                                         &amount));
+  ph = plugin->prepare_wire_transfer (plugin->cls,
+                                      my_account,
+                                      dest_account,
+                                      &amount,
+                                      "https://exchange.net/";,
+                                      &wtid,
+                                      &prepare_cb,
+                                      NULL);
+}
+
 
 /**
  * Run the test.
@@ -324,12 +285,9 @@ static void
 run (void *cls)
 {
   struct TALER_Amount amount;
-
   GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
                                  NULL);
-  tt = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
-                                     &timeout_cb,
-                                     NULL);
+
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
                               &wtid,
                               sizeof (wtid));
@@ -337,6 +295,7 @@ run (void *cls)
                  TALER_string_to_amount ("KUDOS:5.01",
                                          &amount));
   fb = TALER_FAKEBANK_start (8088);
+
   ph = plugin->prepare_wire_transfer (plugin->cls,
                                       my_account,
                                       dest_account,
@@ -353,13 +312,13 @@ main (int argc,
       const char *const argv[])
 {
 
-  GNUNET_log_setup ("test-wire-plugin-transactions-test",
+  GNUNET_log_setup ("test-wire-plugin-legacy-test",
                     "WARNING",
                     NULL);
   cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONFIGURATION_load (cfg,
-                                            
"test_wire_plugin_transactions_taler-bank.conf"));
+                                            
"test_wire_plugin_legacy_taler-bank.conf"));
   global_ret = GNUNET_OK;
   plugin = TALER_WIRE_plugin_load (cfg,
                                    "taler_bank");
@@ -372,4 +331,4 @@ main (int argc,
   return 0;
 }
 
-/* end of test_wire_plugin_transactions_taler-bank.c */
+/* end of test_wire_plugin_legacy_taler-bank.c */
diff --git a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.conf 
b/src/wire-plugins/test_wire_plugin_legacy_taler-bank.conf
similarity index 100%
copy from src/wire-plugins/test_wire_plugin_transactions_taler-bank.conf
copy to src/wire-plugins/test_wire_plugin_legacy_taler-bank.conf

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



reply via email to

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