[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: clean up payto credit/debit dist
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: clean up payto credit/debit distincition |
Date: |
Wed, 15 Jan 2020 13:22:39 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 8a3f0e3f clean up payto credit/debit distincition
8a3f0e3f is described below
commit 8a3f0e3f8d998d1badc9767fb207e7a07d645150
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Jan 15 13:22:28 2020 +0100
clean up payto credit/debit distincition
---
src/include/taler_testing_lib.h | 48 +++++++++-------
src/lib/testing_api_cmd_bank_admin_add_incoming.c | 6 +-
src/lib/testing_api_cmd_bank_check.c | 21 ++++---
src/lib/testing_api_cmd_bank_history_debit.c | 35 ++++++------
src/lib/testing_api_cmd_bank_transfer.c | 6 +-
src/lib/testing_api_trait_string.c | 68 ++++++++++-------------
6 files changed, 93 insertions(+), 91 deletions(-)
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 9499526a..7e097ff1 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.
@@ -2357,16 +2342,37 @@ TALER_TESTING_get_trait_url (const struct
TALER_TESTING_Command *cmd,
const char **url);
+/**
+ * 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 d2f6cd2c..e490fce2 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 e443833a..6a14e6b0 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 ec4a323e..8459c977 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 575c09c5..efa22d74 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 066a661e..2b0822dd 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
};
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: clean up payto credit/debit distincition,
gnunet <=