gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: prepare test_kyc_api to test #76


From: gnunet
Subject: [taler-merchant] branch master updated: prepare test_kyc_api to test #7684
Date: Mon, 10 Apr 2023 23:31:12 +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 ad925ccc prepare test_kyc_api to test #7684
ad925ccc is described below

commit ad925ccc324ca2b84676a39d63b776ba337da492
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Apr 10 23:30:59 2023 +0200

    prepare test_kyc_api to test #7684
---
 src/backenddb/Makefile.am                    |   5 +-
 src/backenddb/pg_helper.h                    |  15 +
 src/backenddb/pg_lookup_transfers.c          | 453 ++++++++++++++++++++++++++
 src/backenddb/pg_lookup_transfers.h          |  60 ++++
 src/backenddb/pg_template.c                  |   6 +-
 src/backenddb/pg_template.h                  |   6 +-
 src/backenddb/plugin_merchantdb_postgres.c   | 462 +--------------------------
 src/testing/test_kyc_api.c                   | 117 ++++++-
 src/testing/testing_api_cmd_post_transfers.c |   8 +
 9 files changed, 656 insertions(+), 476 deletions(-)

diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am
index d233b95b..a21c209b 100644
--- a/src/backenddb/Makefile.am
+++ b/src/backenddb/Makefile.am
@@ -38,7 +38,7 @@ lib_LTLIBRARIES = \
 
 libtalermerchantdb_la_SOURCES = \
   merchantdb_plugin.c \
-  merchantdb_helper.c pg_helper.h
+  merchantdb_helper.c
 
 libtalermerchantdb_la_LIBADD = \
   $(LIBGCRYPT_LIBS) \
@@ -54,7 +54,8 @@ libtalermerchantdb_la_LDFLAGS = \
   -no-undefined
 
 libtaler_plugin_merchantdb_postgres_la_SOURCES = \
-  plugin_merchantdb_postgres.c
+  pg_lookup_transfers.h pg_lookup_transfers.c \
+  plugin_merchantdb_postgres.c  pg_helper.h
 libtaler_plugin_merchantdb_postgres_la_LIBADD = \
   $(LTLIBINTL)
 libtaler_plugin_merchantdb_postgres_la_LDFLAGS = \
diff --git a/src/backenddb/pg_helper.h b/src/backenddb/pg_helper.h
index d2e9035b..b058d2f4 100644
--- a/src/backenddb/pg_helper.h
+++ b/src/backenddb/pg_helper.h
@@ -54,6 +54,10 @@ struct PostgresClosure
    */
   const char *transaction_name;
 
+  /**
+   * How many times have we connected to the DB.
+   */
+  uint64_t prep_gen;
 
 };
 
@@ -113,4 +117,15 @@ struct PostgresClosure
     field,pg->currency,amountp)
 
 
+/**
+ * Check that the database connection is still up
+ * and automatically reconnects unless we are
+ * already inside of a transaction.
+ *
+ * @param pg connection to check
+ */
+void
+check_connection (struct PostgresClosure *pg);
+
+
 #endif
diff --git a/src/backenddb/pg_lookup_transfers.c 
b/src/backenddb/pg_lookup_transfers.c
new file mode 100644
index 00000000..02faca2b
--- /dev/null
+++ b/src/backenddb/pg_lookup_transfers.c
@@ -0,0 +1,453 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2022 Taler Systems SA
+
+   TALER is free software; you can redistribute it and/or modify it under the
+   terms of the GNU General Public License as published by the Free Software
+   Foundation; either version 3, or (at your option) any later version.
+
+   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with
+   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file backenddb/pg_lookup_transfers.c
+ * @brief Implementation of the lookup_transfers function for Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <taler/taler_error_codes.h>
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "pg_lookup_transfers.h"
+#include "pg_helper.h"
+
+
+/**
+ * Closure for #lookup_transfers_cb().
+ */
+struct LookupTransfersContext
+{
+  /**
+   * Function to call on results.
+   */
+  TALER_MERCHANTDB_TransferCallback cb;
+
+  /**
+   * Closure for @e cb.
+   */
+  void *cb_cls;
+
+  /**
+   * Postgres context.
+   */
+  struct PostgresClosure *pg;
+
+  /**
+   * Transaction status (set).
+   */
+  enum GNUNET_DB_QueryStatus qs;
+
+  /**
+   * Filter to apply by verification status.
+   */
+  enum TALER_EXCHANGE_YesNoAll verified;
+};
+
+
+/**
+ * Function to be called with the results of a SELECT statement
+ * that has returned @a num_results results.
+ *
+ * @param cls of type `struct LookupTransfersContext *`
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+lookup_transfers_cb (void *cls,
+                     PGresult *result,
+                     unsigned int num_results)
+{
+  struct LookupTransfersContext *ltc = cls;
+  struct PostgresClosure *pg = ltc->pg;
+
+  for (unsigned int i = 0; i<num_results; i++)
+  {
+    struct TALER_Amount credit_amount;
+    struct TALER_WireTransferIdentifierRawP wtid;
+    char *payto_uri;
+    char *exchange_url;
+    uint64_t transfer_serial_id;
+    struct GNUNET_TIME_Timestamp execution_time;
+    enum TALER_EXCHANGE_YesNoAll verified;
+    uint8_t verified8;
+    uint8_t confirmed8;
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      TALER_PQ_RESULT_SPEC_AMOUNT ("credit_amount",
+                                   &credit_amount),
+      GNUNET_PQ_result_spec_auto_from_type ("wtid",
+                                            &wtid),
+      GNUNET_PQ_result_spec_string ("payto_uri",
+                                    &payto_uri),
+      GNUNET_PQ_result_spec_string ("exchange_url",
+                                    &exchange_url),
+      GNUNET_PQ_result_spec_uint64 ("credit_serial",
+                                    &transfer_serial_id),
+      GNUNET_PQ_result_spec_timestamp ("execution_time",
+                                       &execution_time),
+      GNUNET_PQ_result_spec_auto_from_type ("verified",
+                                            &verified8),
+      GNUNET_PQ_result_spec_auto_from_type ("confirmed",
+                                            &confirmed8),
+      GNUNET_PQ_result_spec_end
+    };
+
+    if (GNUNET_OK !=
+        GNUNET_PQ_extract_result (result,
+                                  rs,
+                                  i))
+    {
+      GNUNET_break (0);
+      ltc->qs = GNUNET_DB_STATUS_HARD_ERROR;
+      return;
+    }
+    if (0 == verified8)
+      verified = TALER_EXCHANGE_YNA_NO;
+    else
+      verified = TALER_EXCHANGE_YNA_YES;
+    if ( (ltc->verified == TALER_EXCHANGE_YNA_ALL) ||
+         (ltc->verified == verified) )
+    {
+      ltc->cb (ltc->cb_cls,
+               &credit_amount,
+               &wtid,
+               payto_uri,
+               exchange_url,
+               transfer_serial_id,
+               execution_time,
+               TALER_EXCHANGE_YNA_YES == verified,
+               0 != confirmed8);
+    }
+    GNUNET_PQ_cleanup_result (rs);
+  }
+  ltc->qs = num_results;
+}
+
+
+enum GNUNET_DB_QueryStatus
+TMH_PG_lookup_transfers (void *cls,
+                         const char *instance_id,
+                         const char *payto_uri,
+                         struct GNUNET_TIME_Timestamp before,
+                         struct GNUNET_TIME_Timestamp after,
+                         int64_t limit,
+                         uint64_t offset,
+                         enum TALER_EXCHANGE_YesNoAll verified,
+                         TALER_MERCHANTDB_TransferCallback cb,
+                         void *cb_cls)
+{
+  struct PostgresClosure *pg = cls;
+  uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
+  struct LookupTransfersContext ltc = {
+    .cb = cb,
+    .cb_cls = cb_cls,
+    .pg = pg,
+    .verified = verified
+  };
+  enum GNUNET_DB_QueryStatus qs;
+  bool by_time;
+
+  by_time = ( (! GNUNET_TIME_absolute_is_never (before.abs_time)) ||
+              (! GNUNET_TIME_absolute_is_zero (after.abs_time)) );
+  check_connection (pg);
+  if (by_time)
+  {
+    if (NULL != payto_uri)
+    {
+      struct GNUNET_PQ_QueryParam params[] = {
+        GNUNET_PQ_query_param_string (instance_id),
+        GNUNET_PQ_query_param_timestamp (&before),
+        GNUNET_PQ_query_param_timestamp (&after),
+        GNUNET_PQ_query_param_uint64 (&offset),
+        GNUNET_PQ_query_param_uint64 (&plimit),
+        GNUNET_PQ_query_param_string (payto_uri),
+        GNUNET_PQ_query_param_end
+      };
+
+      PREPARE (pg,
+               "lookup_transfers_time_payto_asc",
+               "SELECT"
+               " mt.credit_amount_val"
+               ",mt.credit_amount_frac"
+               ",wtid"
+               ",merchant_accounts.payto_uri"
+               ",exchange_url"
+               ",credit_serial"
+               ",merchant_transfer_signatures.execution_time"
+               ",verified"
+               ",confirmed"
+               " FROM merchant_transfers mt"
+               "  JOIN merchant_accounts USING (account_serial)"
+               "  JOIN merchant_transfer_signatures USING (credit_serial)"
+               " WHERE execution_time < $2"
+               "   AND execution_time >= $3"
+               "   AND credit_serial > $4"
+               "   AND payto_uri = $6"
+               "   AND merchant_serial ="
+               "     (SELECT merchant_serial"
+               "        FROM merchant_instances"
+               "       WHERE merchant_id=$1)"
+               " ORDER BY credit_serial ASC"
+               " LIMIT $5");
+      PREPARE (pg,
+               "lookup_transfers_time_payto_desc",
+               "SELECT"
+               " mt.credit_amount_val"
+               ",mt.credit_amount_frac"
+               ",wtid"
+               ",merchant_accounts.payto_uri"
+               ",exchange_url"
+               ",credit_serial"
+               ",merchant_transfer_signatures.execution_time"
+               ",verified"
+               ",confirmed"
+               " FROM merchant_transfers mt"
+               "  JOIN merchant_accounts USING (account_serial)"
+               "  JOIN merchant_transfer_signatures USING (credit_serial)"
+               " WHERE execution_time < $2"
+               "   AND execution_time >= $3"
+               "   AND credit_serial < $4"
+               "   AND payto_uri = $6"
+               "   AND merchant_serial ="
+               "     (SELECT merchant_serial"
+               "        FROM merchant_instances"
+               "       WHERE merchant_id=$1)"
+               " ORDER BY credit_serial DESC"
+               " LIMIT $5");
+      qs = GNUNET_PQ_eval_prepared_multi_select (
+        pg->conn,
+        (limit > 0)
+        ? "lookup_transfers_time_payto_asc"
+        : "lookup_transfers_time_payto_desc",
+        params,
+        &lookup_transfers_cb,
+        &ltc);
+    }
+    else
+    {
+      struct GNUNET_PQ_QueryParam params[] = {
+        GNUNET_PQ_query_param_string (instance_id),
+        GNUNET_PQ_query_param_timestamp (&before),
+        GNUNET_PQ_query_param_timestamp (&after),
+        GNUNET_PQ_query_param_uint64 (&offset),
+        GNUNET_PQ_query_param_uint64 (&plimit),
+        GNUNET_PQ_query_param_end
+      };
+
+      PREPARE (pg,
+               "lookup_transfers_time_asc",
+               "SELECT"
+               " mt.credit_amount_val"
+               ",mt.credit_amount_frac"
+               ",wtid"
+               ",merchant_accounts.payto_uri"
+               ",exchange_url"
+               ",credit_serial"
+               ",merchant_transfer_signatures.execution_time"
+               ",verified"
+               ",confirmed"
+               " FROM merchant_transfers mt"
+               "  JOIN merchant_accounts USING (account_serial)"
+               "  JOIN merchant_transfer_signatures USING (credit_serial)"
+               " WHERE execution_time < $2"
+               "   AND execution_time >= $3"
+               "   AND credit_serial > $4"
+               "   AND merchant_serial ="
+               "     (SELECT merchant_serial"
+               "        FROM merchant_instances"
+               "       WHERE merchant_id=$1)"
+               " ORDER BY credit_serial ASC"
+               " LIMIT $5");
+      PREPARE (pg,
+               "lookup_transfers_time_desc",
+               "SELECT"
+               " mt.credit_amount_val"
+               ",mt.credit_amount_frac"
+               ",wtid"
+               ",merchant_accounts.payto_uri"
+               ",exchange_url"
+               ",credit_serial"
+               ",merchant_transfer_signatures.execution_time"
+               ",verified"
+               ",confirmed"
+               " FROM merchant_transfers mt"
+               "  JOIN merchant_accounts USING (account_serial)"
+               "  JOIN merchant_transfer_signatures USING (credit_serial)"
+               " WHERE execution_time < $2"
+               "   AND execution_time >= $3"
+               "   AND credit_serial < $4"
+               "   AND merchant_serial ="
+               "     (SELECT merchant_serial"
+               "        FROM merchant_instances"
+               "       WHERE merchant_id=$1)"
+               " ORDER BY credit_serial DESC"
+               " LIMIT $5");
+      qs = GNUNET_PQ_eval_prepared_multi_select (
+        pg->conn,
+        (limit > 0)
+        ? "lookup_transfers_time_asc"
+        : "lookup_transfers_time_desc",
+        params,
+        &lookup_transfers_cb,
+        &ltc);
+    }
+  }
+  else
+  {
+    if (NULL != payto_uri)
+    {
+      struct GNUNET_PQ_QueryParam params[] = {
+        GNUNET_PQ_query_param_string (instance_id),
+        GNUNET_PQ_query_param_uint64 (&offset),
+        GNUNET_PQ_query_param_uint64 (&plimit),
+        GNUNET_PQ_query_param_string (payto_uri),
+        GNUNET_PQ_query_param_end
+      };
+
+      PREPARE (pg,
+               "lookup_transfers_payto_asc",
+               "SELECT"
+               " mt.credit_amount_val"
+               ",mt.credit_amount_frac"
+               ",wtid"
+               ",merchant_accounts.payto_uri"
+               ",exchange_url"
+               ",credit_serial"
+               ",CASE WHEN (merchant_transfer_signatures.execution_time) IS 
NULL"
+               "   THEN 9223372036854775807" /* largest BIGINT possible */
+               "   ELSE merchant_transfer_signatures.execution_time"
+               " END AS execution_time"
+               ",verified"
+               ",confirmed"
+               " FROM merchant_transfers mt"
+               "  JOIN merchant_accounts USING (account_serial)"
+               "  LEFT JOIN merchant_transfer_signatures USING (credit_serial)"
+               " WHERE credit_serial > $2"
+               "   AND payto_uri = $4"
+               "   AND merchant_serial ="
+               "     (SELECT merchant_serial"
+               "        FROM merchant_instances"
+               "       WHERE merchant_id=$1)"
+               " ORDER BY credit_serial ASC"
+               " LIMIT $3");
+      PREPARE (pg,
+               "lookup_transfers_payto_desc",
+               "SELECT"
+               " mt.credit_amount_val"
+               ",mt.credit_amount_frac"
+               ",wtid"
+               ",merchant_accounts.payto_uri"
+               ",exchange_url"
+               ",credit_serial"
+               ",CASE WHEN (merchant_transfer_signatures.execution_time) IS 
NULL"
+               "   THEN 9223372036854775807" /* largest BIGINT possible */
+               "   ELSE merchant_transfer_signatures.execution_time"
+               " END AS execution_time"
+               ",verified"
+               ",confirmed"
+               " FROM merchant_transfers mt"
+               "  JOIN merchant_accounts USING (account_serial)"
+               "  LEFT JOIN merchant_transfer_signatures USING (credit_serial)"
+               " WHERE credit_serial < $2"
+               "   AND payto_uri = $4"
+               "   AND merchant_serial ="
+               "     (SELECT merchant_serial"
+               "        FROM merchant_instances"
+               "       WHERE merchant_id=$1)"
+               " ORDER BY credit_serial DESC"
+               " LIMIT $3");
+      qs = GNUNET_PQ_eval_prepared_multi_select (
+        pg->conn,
+        (limit > 0)
+        ? "lookup_transfers_payto_asc"
+        : "lookup_transfers_payto_desc",
+        params,
+        &lookup_transfers_cb,
+        &ltc);
+    }
+    else
+    {
+      struct GNUNET_PQ_QueryParam params[] = {
+        GNUNET_PQ_query_param_string (instance_id),
+        GNUNET_PQ_query_param_uint64 (&offset),
+        GNUNET_PQ_query_param_uint64 (&plimit),
+        GNUNET_PQ_query_param_end
+      };
+
+      PREPARE (pg,
+               "lookup_transfers_desc",
+               "SELECT"
+               " mt.credit_amount_val"
+               ",mt.credit_amount_frac"
+               ",wtid"
+               ",merchant_accounts.payto_uri"
+               ",exchange_url"
+               ",credit_serial"
+               ",CASE WHEN (merchant_transfer_signatures.execution_time) IS 
NULL"
+               "   THEN 9223372036854775807" /* largest BIGINT possible */
+               "   ELSE merchant_transfer_signatures.execution_time"
+               " END AS execution_time"
+               ",verified"
+               ",confirmed"
+               " FROM merchant_transfers mt"
+               "  JOIN merchant_accounts USING (account_serial)"
+               "  LEFT JOIN merchant_transfer_signatures USING (credit_serial)"
+               " WHERE credit_serial < $2"
+               "   AND merchant_serial ="
+               "     (SELECT merchant_serial"
+               "        FROM merchant_instances"
+               "       WHERE merchant_id=$1)"
+               " ORDER BY credit_serial DESC"
+               " LIMIT $3");
+      PREPARE (pg,
+               "lookup_transfers_asc",
+               "SELECT"
+               " mt.credit_amount_val"
+               ",mt.credit_amount_frac"
+               ",wtid"
+               ",merchant_accounts.payto_uri"
+               ",exchange_url"
+               ",credit_serial"
+               ",CASE WHEN (merchant_transfer_signatures.execution_time) IS 
NULL"
+               "   THEN 9223372036854775807" /* largest BIGINT possible */
+               "   ELSE merchant_transfer_signatures.execution_time"
+               " END AS execution_time"
+               ",verified"
+               ",confirmed"
+               " FROM merchant_transfers mt"
+               "  JOIN merchant_accounts USING (account_serial)"
+               "  LEFT JOIN merchant_transfer_signatures USING (credit_serial)"
+               " WHERE credit_serial > $2"
+               "   AND merchant_serial ="
+               "     (SELECT merchant_serial"
+               "        FROM merchant_instances"
+               "       WHERE merchant_id=$1)"
+               " ORDER BY credit_serial ASC"
+               " LIMIT $3");
+      qs = GNUNET_PQ_eval_prepared_multi_select (
+        pg->conn,
+        (limit > 0)
+        ? "lookup_transfers_asc"
+        : "lookup_transfers_desc",
+        params,
+        &lookup_transfers_cb,
+        &ltc);
+    }
+  }
+  if (0 >= qs)
+    return qs;
+  return ltc.qs;
+}
diff --git a/src/backenddb/pg_lookup_transfers.h 
b/src/backenddb/pg_lookup_transfers.h
new file mode 100644
index 00000000..5a522256
--- /dev/null
+++ b/src/backenddb/pg_lookup_transfers.h
@@ -0,0 +1,60 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2022 Taler Systems SA
+
+   TALER is free software; you can redistribute it and/or modify it under the
+   terms of the GNU General Public License as published by the Free Software
+   Foundation; either version 3, or (at your option) any later version.
+
+   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with
+   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file backenddb/pg_lookup_transfers.h
+ * @brief implementation of the lookup_transfers function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef PG_LOOKUP_TRANSFERS_H
+#define PG_LOOKUP_TRANSFERS_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "taler_merchantdb_plugin.h"
+
+/**
+ * Lookup transfers. Note that filtering by @a verified status is done
+ * outside of SQL, as we already have 8 prepared statements and adding
+ * a filter on verified would further double the number of statements for
+ * a likely rather ineffective filter. So we apply that filter in
+ * #lookup_transfers_cb().
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup payments for
+ * @param payto_uri account that we are interested in transfers to
+ * @param before timestamp for the earliest transfer we care about
+ * @param after timestamp for the last transfer we care about
+ * @param limit number of entries to return, negative for descending in 
execution time,
+ *                positive for ascending in execution time
+ * @param offset transfer_serial number of the transfer we want to offset from
+ * @param verified filter transfers by verification status
+ * @param cb function to call with detailed transfer data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+enum GNUNET_DB_QueryStatus
+TMH_PG_lookup_transfers (void *cls,
+                         const char *instance_id,
+                         const char *payto_uri,
+                         struct GNUNET_TIME_Timestamp before,
+                         struct GNUNET_TIME_Timestamp after,
+                         int64_t limit,
+                         uint64_t offset,
+                         enum TALER_EXCHANGE_YesNoAll verified,
+                         TALER_MERCHANTDB_TransferCallback cb,
+                         void *cb_cls);
+
+#endif
diff --git a/src/backenddb/pg_template.c b/src/backenddb/pg_template.c
index 30ea64d0..23035677 100644
--- a/src/backenddb/pg_template.c
+++ b/src/backenddb/pg_template.c
@@ -19,8 +19,8 @@
  * @author Christian Grothoff
  */
 #include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
+#include <taler/taler_error_codes.h>
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
 #include "pg_template.h"
 #include "pg_helper.h"
diff --git a/src/backenddb/pg_template.h b/src/backenddb/pg_template.h
index 81415a41..30c6bce7 100644
--- a/src/backenddb/pg_template.h
+++ b/src/backenddb/pg_template.h
@@ -21,9 +21,9 @@
 #ifndef PG_TEMPLATE_H
 #define PG_TEMPLATE_H
 
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_merchantdb_plugin.h"
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include <taler/taler_merchantdb_plugin.h>
 
 
 #endif
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index ff7e1dd3..b49bc54a 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -30,6 +30,8 @@
 #include <taler/taler_mhd_lib.h>
 #include "taler_merchantdb_plugin.h"
 #include "pg_helper.h"
+#include "pg_lookup_transfers.h"
+
 
 /**
  * How often do we re-try if we run into a DB serialization error?
@@ -176,14 +178,7 @@ postgres_preflight (void *cls)
 }
 
 
-/**
- * Check that the database connection is still up
- * and automatically reconnects unless we are
- * already inside of a transaction.
- *
- * @param pg connection to check
- */
-static void
+void
 check_connection (struct PostgresClosure *pg)
 {
   if (NULL != pg->transaction_name)
@@ -4859,253 +4854,6 @@ postgres_lookup_transfer_details (
 }
 
 
-/**
- * Closure for #lookup_transfers_cb().
- */
-struct LookupTransfersContext
-{
-  /**
-   * Function to call on results.
-   */
-  TALER_MERCHANTDB_TransferCallback cb;
-
-  /**
-   * Closure for @e cb.
-   */
-  void *cb_cls;
-
-  /**
-   * Postgres context.
-   */
-  struct PostgresClosure *pg;
-
-  /**
-   * Transaction status (set).
-   */
-  enum GNUNET_DB_QueryStatus qs;
-
-  /**
-   * Filter to apply by verification status.
-   */
-  enum TALER_EXCHANGE_YesNoAll verified;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls of type `struct LookupTransfersContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lookup_transfers_cb (void *cls,
-                     PGresult *result,
-                     unsigned int num_results)
-{
-  struct LookupTransfersContext *ltc = cls;
-  struct PostgresClosure *pg = ltc->pg;
-
-  for (unsigned int i = 0; i<num_results; i++)
-  {
-    struct TALER_Amount credit_amount;
-    struct TALER_WireTransferIdentifierRawP wtid;
-    char *payto_uri;
-    char *exchange_url;
-    uint64_t transfer_serial_id;
-    struct GNUNET_TIME_Timestamp execution_time;
-    enum TALER_EXCHANGE_YesNoAll verified;
-    uint8_t verified8;
-    uint8_t confirmed8;
-    struct GNUNET_PQ_ResultSpec rs[] = {
-      TALER_PQ_RESULT_SPEC_AMOUNT ("credit_amount",
-                                   &credit_amount),
-      GNUNET_PQ_result_spec_auto_from_type ("wtid",
-                                            &wtid),
-      GNUNET_PQ_result_spec_string ("payto_uri",
-                                    &payto_uri),
-      GNUNET_PQ_result_spec_string ("exchange_url",
-                                    &exchange_url),
-      GNUNET_PQ_result_spec_uint64 ("credit_serial",
-                                    &transfer_serial_id),
-      GNUNET_PQ_result_spec_timestamp ("execution_time",
-                                       &execution_time),
-      GNUNET_PQ_result_spec_auto_from_type ("verified",
-                                            &verified8),
-      GNUNET_PQ_result_spec_auto_from_type ("confirmed",
-                                            &confirmed8),
-      GNUNET_PQ_result_spec_end
-    };
-
-    if (GNUNET_OK !=
-        GNUNET_PQ_extract_result (result,
-                                  rs,
-                                  i))
-    {
-      GNUNET_break (0);
-      ltc->qs = GNUNET_DB_STATUS_HARD_ERROR;
-      return;
-    }
-    if (0 == verified8)
-      verified = TALER_EXCHANGE_YNA_NO;
-    else
-      verified = TALER_EXCHANGE_YNA_YES;
-    if ( (ltc->verified == TALER_EXCHANGE_YNA_ALL) ||
-         (ltc->verified == verified) )
-    {
-      ltc->cb (ltc->cb_cls,
-               &credit_amount,
-               &wtid,
-               payto_uri,
-               exchange_url,
-               transfer_serial_id,
-               execution_time,
-               TALER_EXCHANGE_YNA_YES == verified,
-               0 != confirmed8);
-    }
-    GNUNET_PQ_cleanup_result (rs);
-  }
-  ltc->qs = num_results;
-}
-
-
-/**
- * Lookup transfers. Note that filtering by @a verified status is done
- * outside of SQL, as we already have 8 prepared statements and adding
- * a filter on verified would further double the number of statements for
- * a likely rather ineffective filter. So we apply that filter in
- * #lookup_transfers_cb().
- *
- * @param cls closure
- * @param instance_id instance to lookup payments for
- * @param payto_uri account that we are interested in transfers to
- * @param before timestamp for the earliest transfer we care about
- * @param after timestamp for the last transfer we care about
- * @param limit number of entries to return, negative for descending in 
execution time,
- *                positive for ascending in execution time
- * @param offset transfer_serial number of the transfer we want to offset from
- * @param verified filter transfers by verification status
- * @param cb function to call with detailed transfer data
- * @param cb_cls closure for @a cb
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_transfers (void *cls,
-                           const char *instance_id,
-                           const char *payto_uri,
-                           struct GNUNET_TIME_Timestamp before,
-                           struct GNUNET_TIME_Timestamp after,
-                           int64_t limit,
-                           uint64_t offset,
-                           enum TALER_EXCHANGE_YesNoAll verified,
-                           TALER_MERCHANTDB_TransferCallback cb,
-                           void *cb_cls)
-{
-  struct PostgresClosure *pg = cls;
-  uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
-  struct LookupTransfersContext ltc = {
-    .cb = cb,
-    .cb_cls = cb_cls,
-    .pg = pg,
-    .verified = verified
-  };
-  enum GNUNET_DB_QueryStatus qs;
-  bool by_time;
-
-  by_time = ( (! GNUNET_TIME_absolute_is_never (before.abs_time)) ||
-              (! GNUNET_TIME_absolute_is_zero (after.abs_time)) );
-  check_connection (pg);
-  if (by_time)
-  {
-    if (NULL != payto_uri)
-    {
-      struct GNUNET_PQ_QueryParam params[] = {
-        GNUNET_PQ_query_param_string (instance_id),
-        GNUNET_PQ_query_param_timestamp (&before),
-        GNUNET_PQ_query_param_timestamp (&after),
-        GNUNET_PQ_query_param_uint64 (&offset),
-        GNUNET_PQ_query_param_uint64 (&plimit),
-        GNUNET_PQ_query_param_string (payto_uri),
-        GNUNET_PQ_query_param_end
-      };
-
-      qs = GNUNET_PQ_eval_prepared_multi_select (
-        pg->conn,
-        (limit > 0)
-        ? "lookup_transfers_time_payto_asc"
-        : "lookup_transfers_time_payto_desc",
-        params,
-        &lookup_transfers_cb,
-        &ltc);
-    }
-    else
-    {
-      struct GNUNET_PQ_QueryParam params[] = {
-        GNUNET_PQ_query_param_string (instance_id),
-        GNUNET_PQ_query_param_timestamp (&before),
-        GNUNET_PQ_query_param_timestamp (&after),
-        GNUNET_PQ_query_param_uint64 (&offset),
-        GNUNET_PQ_query_param_uint64 (&plimit),
-        GNUNET_PQ_query_param_end
-      };
-
-      qs = GNUNET_PQ_eval_prepared_multi_select (
-        pg->conn,
-        (limit > 0)
-        ? "lookup_transfers_time_asc"
-        : "lookup_transfers_time_desc",
-        params,
-        &lookup_transfers_cb,
-        &ltc);
-    }
-  }
-  else
-  {
-    if (NULL != payto_uri)
-    {
-      struct GNUNET_PQ_QueryParam params[] = {
-        GNUNET_PQ_query_param_string (instance_id),
-        GNUNET_PQ_query_param_uint64 (&offset),
-        GNUNET_PQ_query_param_uint64 (&plimit),
-        GNUNET_PQ_query_param_string (payto_uri),
-        GNUNET_PQ_query_param_end
-      };
-
-      qs = GNUNET_PQ_eval_prepared_multi_select (
-        pg->conn,
-        (limit > 0)
-        ? "lookup_transfers_payto_asc"
-        : "lookup_transfers_payto_desc",
-        params,
-        &lookup_transfers_cb,
-        &ltc);
-    }
-    else
-    {
-      struct GNUNET_PQ_QueryParam params[] = {
-        GNUNET_PQ_query_param_string (instance_id),
-        GNUNET_PQ_query_param_uint64 (&offset),
-        GNUNET_PQ_query_param_uint64 (&plimit),
-        GNUNET_PQ_query_param_end
-      };
-
-      qs = GNUNET_PQ_eval_prepared_multi_select (
-        pg->conn,
-        (limit > 0)
-        ? "lookup_transfers_asc"
-        : "lookup_transfers_desc",
-        params,
-        &lookup_transfers_cb,
-        &ltc);
-    }
-  }
-  if (0 >= qs)
-    return qs;
-  return ltc.qs;
-}
-
-
 /**
  * Store information about wire fees charged by an exchange,
  * including signature (so we have proof).
@@ -9702,206 +9450,6 @@ postgres_connect (void *cls)
                             "  JOIN merchant_transfers USING (credit_serial)"
                             " WHERE merchant_transfers.wtid=$2"
                             "   AND merchant_transfers.exchange_url=$1"),
-    /* for postgres_lookup_transfers() */
-    GNUNET_PQ_make_prepare ("lookup_transfers_time_payto_asc",
-                            "SELECT"
-                            " mt.credit_amount_val"
-                            ",mt.credit_amount_frac"
-                            ",wtid"
-                            ",merchant_accounts.payto_uri"
-                            ",exchange_url"
-                            ",credit_serial"
-                            ",merchant_transfer_signatures.execution_time"
-                            ",verified"
-                            ",confirmed"
-                            " FROM merchant_transfers mt"
-                            "  JOIN merchant_accounts USING (account_serial)"
-                            "  JOIN merchant_transfer_signatures USING 
(credit_serial)"
-                            " WHERE execution_time < $2"
-                            "   AND execution_time >= $3"
-                            "   AND credit_serial > $4"
-                            "   AND payto_uri = $6"
-                            "   AND merchant_serial ="
-                            "     (SELECT merchant_serial"
-                            "        FROM merchant_instances"
-                            "       WHERE merchant_id=$1)"
-                            " ORDER BY credit_serial ASC"
-                            " LIMIT $5"),
-    /* for postgres_lookup_transfers() */
-    GNUNET_PQ_make_prepare ("lookup_transfers_time_asc",
-                            "SELECT"
-                            " mt.credit_amount_val"
-                            ",mt.credit_amount_frac"
-                            ",wtid"
-                            ",merchant_accounts.payto_uri"
-                            ",exchange_url"
-                            ",credit_serial"
-                            ",merchant_transfer_signatures.execution_time"
-                            ",verified"
-                            ",confirmed"
-                            " FROM merchant_transfers mt"
-                            "  JOIN merchant_accounts USING (account_serial)"
-                            "  JOIN merchant_transfer_signatures USING 
(credit_serial)"
-                            " WHERE execution_time < $2"
-                            "   AND execution_time >= $3"
-                            "   AND credit_serial > $4"
-                            "   AND merchant_serial ="
-                            "     (SELECT merchant_serial"
-                            "        FROM merchant_instances"
-                            "       WHERE merchant_id=$1)"
-                            " ORDER BY credit_serial ASC"
-                            " LIMIT $5"),
-    /* for postgres_lookup_transfers() */
-    GNUNET_PQ_make_prepare ("lookup_transfers_payto_asc",
-                            "SELECT"
-                            " mt.credit_amount_val"
-                            ",mt.credit_amount_frac"
-                            ",wtid"
-                            ",merchant_accounts.payto_uri"
-                            ",exchange_url"
-                            ",credit_serial"
-                            ",CASE WHEN 
(merchant_transfer_signatures.execution_time) IS NULL"
-                            "   THEN 9223372036854775807" /* largest BIGINT 
possible */
-                            "   ELSE 
merchant_transfer_signatures.execution_time"
-                            " END AS execution_time"
-                            ",verified"
-                            ",confirmed"
-                            " FROM merchant_transfers mt"
-                            "  JOIN merchant_accounts USING (account_serial)"
-                            "  LEFT JOIN merchant_transfer_signatures USING 
(credit_serial)"
-                            " WHERE credit_serial > $2"
-                            "   AND payto_uri = $4"
-                            "   AND merchant_serial ="
-                            "     (SELECT merchant_serial"
-                            "        FROM merchant_instances"
-                            "       WHERE merchant_id=$1)"
-                            " ORDER BY credit_serial ASC"
-                            " LIMIT $3"),
-    /* for postgres_lookup_transfers() */
-    GNUNET_PQ_make_prepare ("lookup_transfers_asc",
-                            "SELECT"
-                            " mt.credit_amount_val"
-                            ",mt.credit_amount_frac"
-                            ",wtid"
-                            ",merchant_accounts.payto_uri"
-                            ",exchange_url"
-                            ",credit_serial"
-                            ",CASE WHEN 
(merchant_transfer_signatures.execution_time) IS NULL"
-                            "   THEN 9223372036854775807" /* largest BIGINT 
possible */
-                            "   ELSE 
merchant_transfer_signatures.execution_time"
-                            " END AS execution_time"
-                            ",verified"
-                            ",confirmed"
-                            " FROM merchant_transfers mt"
-                            "  JOIN merchant_accounts USING (account_serial)"
-                            "  LEFT JOIN merchant_transfer_signatures USING 
(credit_serial)"
-                            " WHERE credit_serial > $2"
-                            "   AND merchant_serial ="
-                            "     (SELECT merchant_serial"
-                            "        FROM merchant_instances"
-                            "       WHERE merchant_id=$1)"
-                            " ORDER BY credit_serial ASC"
-                            " LIMIT $3"),
-    /* for postgres_lookup_transfers() */
-    GNUNET_PQ_make_prepare ("lookup_transfers_time_payto_desc",
-                            "SELECT"
-                            " mt.credit_amount_val"
-                            ",mt.credit_amount_frac"
-                            ",wtid"
-                            ",merchant_accounts.payto_uri"
-                            ",exchange_url"
-                            ",credit_serial"
-                            ",merchant_transfer_signatures.execution_time"
-                            ",verified"
-                            ",confirmed"
-                            " FROM merchant_transfers mt"
-                            "  JOIN merchant_accounts USING (account_serial)"
-                            "  JOIN merchant_transfer_signatures USING 
(credit_serial)"
-                            " WHERE execution_time < $2"
-                            "   AND execution_time >= $3"
-                            "   AND credit_serial < $4"
-                            "   AND payto_uri = $6"
-                            "   AND merchant_serial ="
-                            "     (SELECT merchant_serial"
-                            "        FROM merchant_instances"
-                            "       WHERE merchant_id=$1)"
-                            " ORDER BY credit_serial DESC"
-                            " LIMIT $5"),
-    /* for postgres_lookup_transfers() */
-    GNUNET_PQ_make_prepare ("lookup_transfers_time_desc",
-                            "SELECT"
-                            " mt.credit_amount_val"
-                            ",mt.credit_amount_frac"
-                            ",wtid"
-                            ",merchant_accounts.payto_uri"
-                            ",exchange_url"
-                            ",credit_serial"
-                            ",merchant_transfer_signatures.execution_time"
-                            ",verified"
-                            ",confirmed"
-                            " FROM merchant_transfers mt"
-                            "  JOIN merchant_accounts USING (account_serial)"
-                            "  JOIN merchant_transfer_signatures USING 
(credit_serial)"
-                            " WHERE execution_time < $2"
-                            "   AND execution_time >= $3"
-                            "   AND credit_serial < $4"
-                            "   AND merchant_serial ="
-                            "     (SELECT merchant_serial"
-                            "        FROM merchant_instances"
-                            "       WHERE merchant_id=$1)"
-                            " ORDER BY credit_serial DESC"
-                            " LIMIT $5"),
-    /* for postgres_lookup_transfers() */
-    GNUNET_PQ_make_prepare ("lookup_transfers_payto_desc",
-                            "SELECT"
-                            " mt.credit_amount_val"
-                            ",mt.credit_amount_frac"
-                            ",wtid"
-                            ",merchant_accounts.payto_uri"
-                            ",exchange_url"
-                            ",credit_serial"
-                            ",CASE WHEN 
(merchant_transfer_signatures.execution_time) IS NULL"
-                            "   THEN 9223372036854775807" /* largest BIGINT 
possible */
-                            "   ELSE 
merchant_transfer_signatures.execution_time"
-                            " END AS execution_time"
-                            ",verified"
-                            ",confirmed"
-                            " FROM merchant_transfers mt"
-                            "  JOIN merchant_accounts USING (account_serial)"
-                            "  LEFT JOIN merchant_transfer_signatures USING 
(credit_serial)"
-                            " WHERE credit_serial < $2"
-                            "   AND payto_uri = $4"
-                            "   AND merchant_serial ="
-                            "     (SELECT merchant_serial"
-                            "        FROM merchant_instances"
-                            "       WHERE merchant_id=$1)"
-                            " ORDER BY credit_serial DESC"
-                            " LIMIT $3"),
-    /* for postgres_lookup_transfers() */
-    GNUNET_PQ_make_prepare ("lookup_transfers_desc",
-                            "SELECT"
-                            " mt.credit_amount_val"
-                            ",mt.credit_amount_frac"
-                            ",wtid"
-                            ",merchant_accounts.payto_uri"
-                            ",exchange_url"
-                            ",credit_serial"
-                            ",CASE WHEN 
(merchant_transfer_signatures.execution_time) IS NULL"
-                            "   THEN 9223372036854775807" /* largest BIGINT 
possible */
-                            "   ELSE 
merchant_transfer_signatures.execution_time"
-                            " END AS execution_time"
-                            ",verified"
-                            ",confirmed"
-                            " FROM merchant_transfers mt"
-                            "  JOIN merchant_accounts USING (account_serial)"
-                            "  LEFT JOIN merchant_transfer_signatures USING 
(credit_serial)"
-                            " WHERE credit_serial < $2"
-                            "   AND merchant_serial ="
-                            "     (SELECT merchant_serial"
-                            "        FROM merchant_instances"
-                            "       WHERE merchant_id=$1)"
-                            " ORDER BY credit_serial DESC"
-                            " LIMIT $3"),
     /* For postgres_store_wire_fee_by_exchange() */
     GNUNET_PQ_make_prepare ("insert_wire_fee",
                             "INSERT INTO merchant_exchange_wire_fees"
@@ -10517,6 +10065,7 @@ postgres_connect (void *cls)
                                          NULL,
                                          es,
                                          ps);
+  pg->prep_gen++;
   if (NULL == pg->conn)
     return GNUNET_SYSERR;
   return GNUNET_OK;
@@ -10638,7 +10187,8 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
     &postgres_set_transfer_status_to_verified;
   plugin->lookup_transfer_summary = &postgres_lookup_transfer_summary;
   plugin->lookup_transfer_details = &postgres_lookup_transfer_details;
-  plugin->lookup_transfers = &postgres_lookup_transfers;
+  plugin->lookup_transfers
+    = &TMH_PG_lookup_transfers;
   plugin->store_wire_fee_by_exchange = &postgres_store_wire_fee_by_exchange;
   plugin->insert_reserve = &postgres_insert_reserve;
   plugin->activate_reserve = &postgres_activate_reserve;
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
index 507338e4..747902ea 100644
--- a/src/testing/test_kyc_api.c
+++ b/src/testing/test_kyc_api.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2022 Taler Systems SA
+  Copyright (C) 2014-2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as
@@ -43,8 +43,6 @@
  */
 #define CONFIG_FILE "test_kyc_api.conf"
 
-#define PAYTO_I1 "payto://x-taler-bank/localhost/3?receiver-name=3"
-
 /**
  * Exchange base URL.  Could also be taken from config.
  */
@@ -100,11 +98,6 @@ static struct GNUNET_OS_Process *merchantd;
  */
 #define USER_ACCOUNT_NAME "62"
 
-/**
- * Account number of some other user.
- */
-#define USER_ACCOUNT_NAME2 "63"
-
 /**
  * Account number used by the merchant
  */
@@ -112,7 +105,7 @@ static struct GNUNET_OS_Process *merchantd;
 
 
 /**
- * Execute the taler-exchange-aggregator, closer and transfer commands with
+ * Execute the taler-exchange-aggregator and transfer commands with
  * our configuration file.
  *
  * @param label label to use for the command.
@@ -257,7 +250,7 @@ run (void *cls,
                                            merchant_payto),
     TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1",
                                               &bc.exchange_auth,
-                                              PAYTO_I1,
+                                              merchant_payto,
                                               merchant_url,
                                               "EUR:4.98",
                                               MHD_HTTP_OK,
@@ -265,13 +258,111 @@ run (void *cls,
                                               NULL),
     TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1",
                                               merchant_url,
-                                              PAYTO_I1,
+                                              merchant_payto,
                                               MHD_HTTP_OK,
                                               "post-transfer-1",
                                               NULL),
     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-3"),
     TALER_TESTING_cmd_end ()
   };
+  struct TALER_TESTING_Command aml[] = {
+    TALER_TESTING_cmd_set_officer ("aml-officer",
+                                   NULL,
+                                   "Ernest&Young",
+                                   true,
+                                   false),
+    cmd_transfer_to_exchange ("create-reserve-big",
+                              "EUR:100.02"),
+    TALER_TESTING_cmd_exec_wirewatch ("wirewatch-big",
+                                      CONFIG_FILE),
+    TALER_TESTING_cmd_take_aml_decision ("freeze",
+                                         "aml-officer",
+                                         "post-transfer-1",
+                                         "EUR:1",
+                                         "suspicious",
+                                         TALER_AML_FROZEN,
+                                         NULL,
+                                         MHD_HTTP_NO_CONTENT),
+    TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-big",
+                                                 "EUR:100.02",
+                                                 payer_payto,
+                                                 exchange_payto,
+                                                 "create-reserve-big"),
+    TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aml",
+                                       "create-reserve-big",
+                                       "EUR:5",
+                                       0,
+                                       MHD_HTTP_OK),
+    TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-aml",
+                                             merchant_url,
+                                             MHD_HTTP_OK,
+                                             "10-aml", /* order ID */
+                                             GNUNET_TIME_UNIT_ZERO_TS,
+                                             GNUNET_TIME_UNIT_FOREVER_TS,
+                                             true,
+                                             "EUR:5.0",
+                                             "x-taler-bank",
+                                             "",
+                                             "",
+                                             NULL),
+    TALER_TESTING_cmd_merchant_claim_order ("reclaim-aml",
+                                            merchant_url,
+                                            MHD_HTTP_OK,
+                                            "create-proposal-aml",
+                                            NULL),
+    TALER_TESTING_cmd_merchant_pay_order ("deposit-simple",
+                                          merchant_url,
+                                          MHD_HTTP_OK,
+                                          "create-proposal-aml",
+                                          "withdraw-coin-aml",
+                                          "EUR:5",
+                                          "EUR:4.99",
+                                          "session-aml"),
+    TALER_TESTING_cmd_merchant_post_orders_paid ("verify-order-aml-paid",
+                                                 merchant_url,
+                                                 "deposit-simple",
+                                                 "session-aml",
+                                                 MHD_HTTP_NO_CONTENT),
+    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-aml-1"),
+    CMD_EXEC_AGGREGATOR ("run-aggregator-aml-frozen"),
+    /* AML-frozen: hence nothing happened at the bank yet: */
+    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-aml-2"),
+
+    /* FIXME-7684: add logic to get AML state from merchant here */
+    TALER_TESTING_cmd_sleep ("sleep to de-collide AML timestamps",
+                             1),
+    TALER_TESTING_cmd_take_aml_decision ("unfreeze",
+                                         "aml-officer",
+                                         "post-transfer-1",
+                                         "EUR:100",
+                                         "fine",
+                                         TALER_AML_NORMAL,
+                                         NULL,
+                                         MHD_HTTP_NO_CONTENT),
+    CMD_EXEC_AGGREGATOR ("run-aggregator-aml-normal"),
+    TALER_TESTING_cmd_check_bank_transfer (
+      "check_bank_transfer-498c-post-unfreeze",
+      EXCHANGE_URL,
+      "EUR:4.98",
+      exchange_payto,
+      merchant_payto),
+    TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-aml",
+                                              &bc.exchange_auth,
+                                              merchant_payto,
+                                              merchant_url,
+                                              "EUR:4.98",
+                                              MHD_HTTP_OK,
+                                              "deposit-simple",
+                                              NULL),
+    TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-aml",
+                                              merchant_url,
+                                              merchant_payto,
+                                              MHD_HTTP_OK,
+                                              "post-transfer-1",
+                                              "post-transfer-aml",
+                                              NULL),
+    TALER_TESTING_cmd_end ()
+  }; /* end of aml batch */
 
   struct TALER_TESTING_Command commands[] = {
     /* general setup */
@@ -295,11 +386,13 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_instances ("instance-create-default-setup",
                                                merchant_url,
                                                "default",
-                                               PAYTO_I1,
+                                               merchant_payto,
                                                "EUR",
                                                MHD_HTTP_NO_CONTENT),
     TALER_TESTING_cmd_batch ("pay",
                              pay),
+    TALER_TESTING_cmd_batch ("aml",
+                             aml),
     TALER_TESTING_cmd_end ()
   };
 
diff --git a/src/testing/testing_api_cmd_post_transfers.c 
b/src/testing/testing_api_cmd_post_transfers.c
index dee1b183..4cff2348 100644
--- a/src/testing/testing_api_cmd_post_transfers.c
+++ b/src/testing/testing_api_cmd_post_transfers.c
@@ -69,6 +69,11 @@ struct PostTransfersState
    */
   const char *payto_uri;
 
+  /**
+   * Set to the hash of the @e payto_uri.
+   */
+  struct TALER_PaytoHashP h_payto;
+
   /**
    * Authentication details to authenticate to the bank.
    */
@@ -338,6 +343,7 @@ post_transfers_traits (void *cls,
     TALER_TESTING_make_trait_wtid (&pts->wtid),
     TALER_TESTING_make_trait_credit_payto_uri (
       (const char **) &pts->credit_account),
+    TALER_TESTING_make_trait_h_payto (&pts->h_payto),
     TALER_TESTING_make_trait_amount (&pts->credit_amount),
     TALER_TESTING_make_trait_fee (&pts->wire_fee),
     TALER_TESTING_make_trait_exchange_url (
@@ -529,6 +535,8 @@ TALER_TESTING_cmd_merchant_post_transfer (
   pts->merchant_url = merchant_url;
   pts->auth = *auth;
   pts->payto_uri = payto_uri;
+  TALER_payto_hash (payto_uri,
+                    &pts->h_payto);
   GNUNET_assert (GNUNET_OK ==
                  TALER_string_to_amount (credit_amount,
                                          &pts->credit_amount));

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