aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-01-15 13:22:28 +0100
committerChristian Grothoff <christian@grothoff.org>2020-01-15 13:22:37 +0100
commit8a3f0e3f8d998d1badc9767fb207e7a07d645150 (patch)
tree5218909386830dcd800d277cf9243be455571376
parente77ccd03906bd2db068136bb383976f714b3289e (diff)
clean up payto credit/debit distincition
-rw-r--r--src/include/taler_testing_lib.h48
-rw-r--r--src/lib/testing_api_cmd_bank_admin_add_incoming.c6
-rw-r--r--src/lib/testing_api_cmd_bank_check.c21
-rw-r--r--src/lib/testing_api_cmd_bank_history_debit.c35
-rw-r--r--src/lib/testing_api_cmd_bank_transfer.c6
-rw-r--r--src/lib/testing_api_trait_string.c68
6 files changed, 93 insertions, 91 deletions
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 9499526af..7e097ff13 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -49,30 +49,15 @@
} 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)
-// FIXME: replace these!
-#define TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT(cmd,out) \
- TALER_TESTING_get_trait_string (cmd, 4, out)
-
-// FIXME: replace these!
-#define TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT(data) \
- TALER_TESTING_make_trait_string (4, data)
-
-// FIXME: replace these!
-#define TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT(cmd,out) \
- TALER_TESTING_get_trait_string (cmd, 5, out)
-
-// FIXME: replace these!
-#define TALER_TESTING_MAKE_TRAIT_DEBIT_ACCOUNT(data) \
- TALER_TESTING_make_trait_string (5, data)
-
-
/**
* Allocate and return a piece of wire-details. Combines
* a @a payto -URL and adds some salt to create the JSON.
@@ -2358,15 +2343,36 @@ TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd,
/**
+ * Used as the "index" in payto traits, to identify what kind of
+ * payto URL we are returning.
+ */
+enum TALER_TESTING_PaytoType
+{
+ /**
+ * We don't know / not credit or debit.
+ */
+ TALER_TESTING_PT_NEUTRAL,
+ /**
+ * Credit side of a transaction.
+ */
+ TALER_TESTING_PT_CREDIT,
+ /**
+ * Debit side of a transaction.
+ */
+ TALER_TESTING_PT_DEBIT
+};
+
+
+/**
* Offer PAYTO url in a trait.
*
- * @param index which url is to be picked,
+ * @param pt which url is to be picked,
* in case multiple are offered.
* @param url the url to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_payto (unsigned int index,
+TALER_TESTING_make_trait_payto (enum TALER_TESTING_PaytoType pt,
const char *url);
@@ -2374,14 +2380,14 @@ TALER_TESTING_make_trait_payto (unsigned int index,
* Obtain a PAYTO url from @a cmd.
*
* @param cmd command to extract the url from.
- * @param index which url is to be picked, in case
+ * @param pt which url is to be picked, in case
* multiple are offered.
* @param url[out] where to write the url.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_payto (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
+ enum TALER_TESTING_PaytoType pt,
const char **url);
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 d2f6cd2c6..e490fce25 100644
--- a/src/lib/testing_api_cmd_bank_admin_add_incoming.c
+++ b/src/lib/testing_api_cmd_bank_admin_add_incoming.c
@@ -398,9 +398,11 @@ admin_add_incoming_traits (void *cls,
{
struct AdminAddIncomingState *fts = cls;
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_payto (1, fts->payto_debit_account),
TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id),
- TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT (fts->exchange_credit_url),
+ TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
+ fts->payto_debit_account),
+ TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
+ fts->exchange_credit_url),
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
TALER_TESTING_make_trait_reserve_priv (0,
diff --git a/src/lib/testing_api_cmd_bank_check.c b/src/lib/testing_api_cmd_bank_check.c
index e443833a4..6a14e6b0f 100644
--- a/src/lib/testing_api_cmd_bank_check.c
+++ b/src/lib/testing_api_cmd_bank_check.c
@@ -135,17 +135,20 @@ check_bank_transfer_run (void *cls,
&amount_ptr));
amount = *amount_ptr;
- GNUNET_assert
- (GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
- (deposit_cmd, &debit_account));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_payto (deposit_cmd,
+ TALER_TESTING_PT_DEBIT,
+ &debit_account));
- GNUNET_assert
- (GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
- (deposit_cmd, &credit_account));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_payto (deposit_cmd,
+ TALER_TESTING_PT_CREDIT,
+ &credit_account));
- GNUNET_assert
- (GNUNET_OK == TALER_TESTING_get_trait_url
- (deposit_cmd, 0, &exchange_base_url)); // check 0 works!
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_url (deposit_cmd,
+ 0, /* TODO: check 0 works! */
+ &exchange_base_url));
}
if (GNUNET_OK !=
diff --git a/src/lib/testing_api_cmd_bank_history_debit.c b/src/lib/testing_api_cmd_bank_history_debit.c
index ec4a323e6..8459c9771 100644
--- a/src/lib/testing_api_cmd_bank_history_debit.c
+++ b/src/lib/testing_api_cmd_bank_history_debit.c
@@ -311,20 +311,20 @@ build_history (struct TALER_TESTING_Interpreter *is,
break;
}
- GNUNET_assert
- (GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
- (pos, &debit_account));
-
- GNUNET_assert
- (GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
- (pos, &credit_account));
-
+ GNUNET_assert (GNUNET_OK ==
+ 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,
+ &credit_account));
TALER_LOG_INFO ("Potential history element:"
" %s->%s; my account: %s\n",
debit_account,
credit_account,
hs->account_url);
-
if (0 == strcasecmp (hs->account_url,
debit_account))
{
@@ -398,19 +398,18 @@ build_history (struct TALER_TESTING_Interpreter *is,
break;
}
- GNUNET_assert
- (GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
- (pos, &debit_account));
-
- GNUNET_assert
- (GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
- (pos, &credit_account));
-
+ GNUNET_assert (GNUNET_OK ==
+ 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,
+ &credit_account));
TALER_LOG_INFO ("Potential history bit: %s->%s; my account: %s\n",
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!
diff --git a/src/lib/testing_api_cmd_bank_transfer.c b/src/lib/testing_api_cmd_bank_transfer.c
index 575c09c56..efa22d745 100644
--- a/src/lib/testing_api_cmd_bank_transfer.c
+++ b/src/lib/testing_api_cmd_bank_transfer.c
@@ -299,8 +299,10 @@ transfer_traits (void *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_CREDIT_ACCOUNT (fts->payto_credit_account),
- TALER_TESTING_MAKE_TRAIT_DEBIT_ACCOUNT (fts->account_debit_url),
+ TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
+ fts->payto_credit_account),
+ TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
+ fts->account_debit_url),
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
TALER_TESTING_make_trait_wtid (0,
diff --git a/src/lib/testing_api_trait_string.c b/src/lib/testing_api_trait_string.c
index 066a661e6..2b0822ddf 100644
--- a/src/lib/testing_api_trait_string.c
+++ b/src/lib/testing_api_trait_string.c
@@ -65,10 +65,9 @@
* @return #GNUNET_OK on success.
*/
int
-TALER_TESTING_get_trait_contract_terms
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const json_t **contract_terms)
+TALER_TESTING_get_trait_contract_terms (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const json_t **contract_terms)
{
return cmd->traits (cmd->cls,
(const void **) contract_terms,
@@ -85,9 +84,8 @@ TALER_TESTING_get_trait_contract_terms
* @return the trait.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_contract_terms
- (unsigned int index,
- const json_t *contract_terms)
+TALER_TESTING_make_trait_contract_terms (unsigned int index,
+ const json_t *contract_terms)
{
struct TALER_TESTING_Trait ret = {
.index = index,
@@ -109,10 +107,9 @@ TALER_TESTING_make_trait_contract_terms
* @return #GNUNET_OK on success.
*/
int
-TALER_TESTING_get_trait_string
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const char **s)
+TALER_TESTING_get_trait_string (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const char **s)
{
return cmd->traits (cmd->cls,
(const void **) s,
@@ -130,9 +127,8 @@ TALER_TESTING_get_trait_string
* @return the trait.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_string
- (unsigned int index,
- const char *s)
+TALER_TESTING_make_trait_string (unsigned int index,
+ const char *s)
{
struct TALER_TESTING_Trait ret = {
.index = index,
@@ -154,10 +150,9 @@ TALER_TESTING_make_trait_string
* @return #GNUNET_OK on success.
*/
int
-TALER_TESTING_get_trait_url
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const char **url)
+TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const char **url)
{
return cmd->traits (cmd->cls,
(const void **) url,
@@ -176,9 +171,8 @@ TALER_TESTING_get_trait_url
* @return the trait.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_url
- (unsigned int index,
- const char *url)
+TALER_TESTING_make_trait_url (unsigned int index,
+ const char *url)
{
struct TALER_TESTING_Trait ret = {
.index = index,
@@ -205,10 +199,9 @@ TALER_TESTING_make_trait_url
* @return #GNUNET_OK on success.
*/
int
-TALER_TESTING_get_trait_order_id
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const char **order_id)
+TALER_TESTING_get_trait_order_id (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const char **order_id)
{
return cmd->traits (cmd->cls,
(const void **) order_id,
@@ -227,9 +220,8 @@ TALER_TESTING_get_trait_order_id
* @return the trait.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_order_id
- (unsigned int index,
- const char *order_id)
+TALER_TESTING_make_trait_order_id (unsigned int index,
+ const char *order_id)
{
struct TALER_TESTING_Trait ret = {
.index = index,
@@ -244,39 +236,37 @@ TALER_TESTING_make_trait_order_id
* Obtain a PAYTO-url from @a cmd.
*
* @param cmd command to extract the url from.
- * @param index which url is to be picked, in case
+ * @param pt which url is to be picked, in case
* multiple are offered.
* @param url[out] where to write the url.
* @return #GNUNET_OK on success.
*/
int
-TALER_TESTING_get_trait_payto
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const char **url)
+TALER_TESTING_get_trait_payto (const struct TALER_TESTING_Command *cmd,
+ enum TALER_TESTING_PaytoType pt,
+ const char **url)
{
return cmd->traits (cmd->cls,
(const void **) url,
TALER_TESTING_TRAIT_PAYTO,
- index);
+ (unsigned int) pt);
}
/**
* Offer a "payto" URL reference.
*
- * @param index which reference is to be offered,
+ * @param pt which reference is to be offered,
* in case multiple are offered.
* @param payto the payto URL
* @return the trait.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_payto
- (unsigned int index,
- const char *payto)
+TALER_TESTING_make_trait_payto (enum TALER_TESTING_PaytoType pt,
+ const char *payto)
{
struct TALER_TESTING_Trait ret = {
- .index = index,
+ .index = (unsigned int) pt,
.trait_name = TALER_TESTING_TRAIT_PAYTO,
.ptr = (const void *) payto
};