aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/taler_testing_lib.h34
-rw-r--r--src/lib/testing_api_cmd_bank_admin_add_incoming.c2
-rw-r--r--src/lib/testing_api_cmd_bank_history_credit.c41
-rw-r--r--src/lib/testing_api_cmd_bank_history_debit.c46
-rw-r--r--src/lib/testing_api_cmd_bank_transfer.c2
-rw-r--r--src/lib/testing_api_trait_number.c64
6 files changed, 113 insertions, 76 deletions
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 554106cd8..877647bbf 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -49,15 +49,6 @@
} while (0)
-// FIXME: replace these
-#define TALER_TESTING_GET_TRAIT_ROW_ID(cmd,out) \
- TALER_TESTING_get_trait_uint64 (cmd, 3, out)
-
-// FIXME: replace these
-#define TALER_TESTING_MAKE_TRAIT_ROW_ID(data) \
- TALER_TESTING_make_trait_uint64 (3, data)
-
-
/**
* Allocate and return a piece of wire-details. Combines
* a @a payto -URL and adds some salt to create the JSON.
@@ -1728,6 +1719,27 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
/**
+ * Obtain a bank transaction row value from @a cmd.
+ *
+ * @param cmd command to extract the number from.
+ * @param row[out] set to the number coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+TALER_TESTING_get_trait_bank_row (const struct TALER_TESTING_Command *cmd,
+ const uint64_t **row);
+
+
+/**
+ * Offer bank transaction row trait.
+ *
+ * @param row number to offer.
+ */
+struct TALER_TESTING_Trait
+TALER_TESTING_make_trait_bank_row (const uint64_t *row);
+
+
+/**
* Offer a reserve private key.
*
* @param index reserve priv's index number.
@@ -1857,7 +1869,7 @@ TALER_TESTING_get_trait_exchange_pub (const struct TALER_TESTING_Command *cmd,
int
TALER_TESTING_get_trait_process (const struct TALER_TESTING_Command *cmd,
unsigned int index,
- struct GNUNET_OS_Process ***processp); // FIXME: why is this a ***!? ** should do!
+ struct GNUNET_OS_Process ***processp);
/**
@@ -1871,7 +1883,7 @@ TALER_TESTING_get_trait_process (const struct TALER_TESTING_Command *cmd,
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_process (unsigned int index,
- struct GNUNET_OS_Process **processp); // FIXME: why is this a "**"? * should do!
+ struct GNUNET_OS_Process **processp);
/**
diff --git a/src/lib/testing_api_cmd_bank_admin_add_incoming.c b/src/lib/testing_api_cmd_bank_admin_add_incoming.c
index 04e7d5637..a5c8d684d 100644
--- a/src/lib/testing_api_cmd_bank_admin_add_incoming.c
+++ b/src/lib/testing_api_cmd_bank_admin_add_incoming.c
@@ -404,7 +404,7 @@ admin_add_incoming_traits (void *cls,
{
struct AdminAddIncomingState *fts = cls;
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id),
+ TALER_TESTING_make_trait_bank_row (&fts->serial_id),
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
fts->payto_debit_account),
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
diff --git a/src/lib/testing_api_cmd_bank_history_credit.c b/src/lib/testing_api_cmd_bank_history_credit.c
index fbabc77ba..8c85bc17c 100644
--- a/src/lib/testing_api_cmd_bank_history_credit.c
+++ b/src/lib/testing_api_cmd_bank_history_credit.c
@@ -217,7 +217,7 @@ build_history (struct TALER_TESTING_Interpreter *is,
GNUNET_assert (0 != hs->num_results);
if (0 == is->ip)
{
- TALER_LOG_DEBUG ("Checking history at first CMD (empty history)\n");
+ TALER_LOG_DEBUG ("Checking history at FIRST transaction (EMPTY)\n");
*rh = NULL;
return 0;
}
@@ -241,6 +241,9 @@ build_history (struct TALER_TESTING_Interpreter *is,
if (NULL == row_id_start)
ok = GNUNET_YES;
+ // FIXME: simplify logic by folding the TWO loops into ONE,
+ // (first doubling h if needed, and finally shrinking h to required size)
+
/* This loop counts how many commands _later than "start"_ belong
* to the history of the caller. This is stored in the @var total
* variable. */
@@ -251,13 +254,12 @@ build_history (struct TALER_TESTING_Interpreter *is,
const char *credit_account;
const char *debit_account;
- /**
- * The following command allows us to skip over those CMDs
+ /* The following command allows us to skip over those CMDs
* that do not offer a "row_id" trait. Such skipped CMDs are
- * not interesting for building a history.
- */if (GNUNET_OK != TALER_TESTING_get_trait_uint64 (pos,
- 0,
- &row_id))
+ * not interesting for building a history. *///
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_bank_row (pos,
+ &row_id))
continue;
/* Seek "/history" starting row. */
@@ -309,7 +311,7 @@ build_history (struct TALER_TESTING_Interpreter *is,
if (0 == total)
{
- TALER_LOG_DEBUG ("Checking history at first CMD.. (2)\n");
+ TALER_LOG_DEBUG ("Checking history with ZERO transactions\n");
*rh = NULL;
return 0;
}
@@ -334,8 +336,8 @@ build_history (struct TALER_TESTING_Interpreter *is,
const char *debit_account;
if (GNUNET_OK !=
- TALER_TESTING_GET_TRAIT_ROW_ID (pos,
- &row_id))
+ TALER_TESTING_get_trait_bank_row (pos,
+ &row_id))
continue;
if (NULL != row_id_start)
@@ -377,8 +379,7 @@ build_history (struct TALER_TESTING_Interpreter *is,
TALER_TESTING_get_trait_payto (pos,
TALER_TESTING_PT_DEBIT,
&debit_account));
- TALER_LOG_INFO ("Potential history bit:"
- " %s->%s; my account: %s\n",
+ TALER_LOG_INFO ("Potential history bit: %s->%s; my account: %s\n",
debit_account,
credit_account,
hs->account_url);
@@ -399,15 +400,17 @@ build_history (struct TALER_TESTING_Interpreter *is,
const char *account_url;
GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_amount_obj
- (pos, 0, &amount));
+ TALER_TESTING_get_trait_amount_obj (pos,
+ 0,
+ &amount));
GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_reserve_pub
- (pos, 0, &reserve_pub));
+ TALER_TESTING_get_trait_reserve_pub (pos,
+ 0,
+ &reserve_pub));
GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_url
- (pos, 1,
- &account_url));
+ TALER_TESTING_get_trait_url (pos,
+ 1,
+ &account_url));
h[total].url = GNUNET_strdup (debit_account);
h[total].details.debit_account_url = h[total].url;
h[total].details.amount = *amount;
diff --git a/src/lib/testing_api_cmd_bank_history_debit.c b/src/lib/testing_api_cmd_bank_history_debit.c
index c98eb26a1..2b80ca83b 100644
--- a/src/lib/testing_api_cmd_bank_history_debit.c
+++ b/src/lib/testing_api_cmd_bank_history_debit.c
@@ -239,6 +239,9 @@ build_history (struct TALER_TESTING_Interpreter *is,
if (NULL == row_id_start)
ok = GNUNET_YES;
+ // FIXME: simplify logic by folding the TWO loops into ONE,
+ // (first doubling h if needed, and finally shrinking h to required size)
+
/* This loop counts how many commands _later than "start"_ belong
* to the history of the caller. This is stored in the @var total
* variable. */
@@ -251,11 +254,10 @@ build_history (struct TALER_TESTING_Interpreter *is,
/* The following command allows us to skip over those CMDs
* that do not offer a "row_id" trait. Such skipped CMDs are
- * not interesting for building a history.
- */
- if (GNUNET_OK != TALER_TESTING_get_trait_uint64 (pos,
- 0,
- &row_id))
+ * not interesting for building a history. *///
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_bank_row (pos,
+ &row_id))
continue;
/* Seek "/history" starting row. */
@@ -275,7 +277,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
continue; /* skip until we find the marker */
TALER_LOG_DEBUG ("Found first row\n");
-
if (total >= GNUNET_MAX (hs->num_results,
-hs->num_results) )
{
@@ -287,7 +288,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
TALER_TESTING_get_trait_payto (pos,
TALER_TESTING_PT_DEBIT,
&debit_account));
-
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_payto (pos,
TALER_TESTING_PT_CREDIT,
@@ -333,8 +333,8 @@ build_history (struct TALER_TESTING_Interpreter *is,
const char *debit_account;
if (GNUNET_OK !=
- TALER_TESTING_GET_TRAIT_ROW_ID (pos,
- &row_id))
+ TALER_TESTING_get_trait_bank_row (pos,
+ &row_id))
continue;
if (NULL != row_id_start)
@@ -353,7 +353,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
}
TALER_LOG_INFO ("Found first row (2)\n");
-
if (GNUNET_NO == ok)
{
TALER_LOG_INFO ("Skip on `%s'\n",
@@ -380,17 +379,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
debit_account,
credit_account,
hs->account_url);
- /* Discard transactions where the audited account played _both_ the debit
- * and the debit roles, but _only if_ the audit goes on both directions..
- * This needs more explaination!
- */
- if (0 == strcasecmp (hs->account_url,
- debit_account))
- {
- GNUNET_break (0);
- continue;
- }
-
bank_hostname = strchr (hs->account_url, ':');
GNUNET_assert (NULL != bank_hostname);
bank_hostname += 3;
@@ -407,15 +395,17 @@ build_history (struct TALER_TESTING_Interpreter *is,
const char *account_url;
GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_amount_obj
- (pos, 0, &amount));
+ TALER_TESTING_get_trait_amount_obj (pos,
+ 0,
+ &amount));
GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_wtid
- (pos, 0, &wtid));
+ TALER_TESTING_get_trait_wtid (pos,
+ 0,
+ &wtid));
GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_url
- (pos, 1,
- &account_url));
+ TALER_TESTING_get_trait_url (pos,
+ 1,
+ &account_url));
h[total].url = GNUNET_strdup (credit_account);
h[total].details.credit_account_url = h[total].url;
h[total].details.amount = *amount;
diff --git a/src/lib/testing_api_cmd_bank_transfer.c b/src/lib/testing_api_cmd_bank_transfer.c
index efa22d745..bad707aa7 100644
--- a/src/lib/testing_api_cmd_bank_transfer.c
+++ b/src/lib/testing_api_cmd_bank_transfer.c
@@ -298,7 +298,7 @@ transfer_traits (void *cls,
struct TransferState *fts = cls;
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_url (1, fts->account_debit_url),
- TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id),
+ TALER_TESTING_make_trait_bank_row (&fts->serial_id),
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
fts->payto_credit_account),
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
diff --git a/src/lib/testing_api_trait_number.c b/src/lib/testing_api_trait_number.c
index ff7741650..82aa34704 100644
--- a/src/lib/testing_api_trait_number.c
+++ b/src/lib/testing_api_trait_number.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2018 Taler Systems SA
+ Copyright (C) 2018-2020 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
@@ -16,7 +16,6 @@
License along with TALER; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
-
/**
* @file exchange-lib/testing_api_trait_number.c
* @brief traits to offer numbers
@@ -31,6 +30,8 @@
#define TALER_TESTING_TRAIT_UINT "uint"
#define TALER_TESTING_TRAIT_UINT64 "uint-64"
+#define TALER_TESTING_TRAIT_BANK_ROW "bank-transaction-row"
+
/**
* Obtain a number from @a cmd.
@@ -41,10 +42,9 @@
* @return #GNUNET_OK on success.
*/
int
-TALER_TESTING_get_trait_uint
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const unsigned int **n)
+TALER_TESTING_get_trait_uint (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const unsigned int **n)
{
return cmd->traits (cmd->cls,
(const void **) n,
@@ -61,9 +61,8 @@ TALER_TESTING_get_trait_uint
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_uint
- (unsigned int index,
- const unsigned int *n)
+TALER_TESTING_make_trait_uint (unsigned int index,
+ const unsigned int *n)
{
struct TALER_TESTING_Trait ret = {
.index = index,
@@ -84,10 +83,9 @@ TALER_TESTING_make_trait_uint
* @return #GNUNET_OK on success.
*/
int
-TALER_TESTING_get_trait_uint64
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const uint64_t **n)
+TALER_TESTING_get_trait_uint64 (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const uint64_t **n)
{
return cmd->traits (cmd->cls,
(const void **) n,
@@ -103,9 +101,8 @@ TALER_TESTING_get_trait_uint64
* @param n number to offer.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_uint64
- (unsigned int index,
- const uint64_t *n)
+TALER_TESTING_make_trait_uint64 (unsigned int index,
+ const uint64_t *n)
{
struct TALER_TESTING_Trait ret = {
.index = index,
@@ -116,4 +113,39 @@ TALER_TESTING_make_trait_uint64
}
+/**
+ * Obtain a bank transaction row value from @a cmd.
+ *
+ * @param cmd command to extract the number from.
+ * @param row[out] set to the number coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+TALER_TESTING_get_trait_bank_row (const struct TALER_TESTING_Command *cmd,
+ const uint64_t **row)
+{
+ return cmd->traits (cmd->cls,
+ (const void **) row,
+ TALER_TESTING_TRAIT_BANK_ROW,
+ 0);
+}
+
+
+/**
+ * Offer bank transaction row trait.
+ *
+ * @param row number to offer.
+ */
+struct TALER_TESTING_Trait
+TALER_TESTING_make_trait_bank_row (const uint64_t *row)
+{
+ struct TALER_TESTING_Trait ret = {
+ .index = 0,
+ .trait_name = TALER_TESTING_TRAIT_BANK_ROW,
+ .ptr = (const void *) row
+ };
+ return ret;
+}
+
+
/* end of testing_api_trait_number.c */