clean up payto credit/debit distincition
This commit is contained in:
parent
e77ccd0390
commit
8a3f0e3f8d
@ -49,30 +49,15 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME: replace these
|
||||||
#define TALER_TESTING_GET_TRAIT_ROW_ID(cmd,out) \
|
#define TALER_TESTING_GET_TRAIT_ROW_ID(cmd,out) \
|
||||||
TALER_TESTING_get_trait_uint64 (cmd, 3, out)
|
TALER_TESTING_get_trait_uint64 (cmd, 3, out)
|
||||||
|
|
||||||
|
// FIXME: replace these
|
||||||
#define TALER_TESTING_MAKE_TRAIT_ROW_ID(data) \
|
#define TALER_TESTING_MAKE_TRAIT_ROW_ID(data) \
|
||||||
TALER_TESTING_make_trait_uint64 (3, 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
|
* Allocate and return a piece of wire-details. Combines
|
||||||
* a @a payto -URL and adds some salt to create the JSON.
|
* 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);
|
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.
|
* 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.
|
* in case multiple are offered.
|
||||||
* @param url the url to offer.
|
* @param url the url to offer.
|
||||||
* @return the trait.
|
* @return the trait.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_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);
|
const char *url);
|
||||||
|
|
||||||
|
|
||||||
@ -2374,14 +2380,14 @@ TALER_TESTING_make_trait_payto (unsigned int index,
|
|||||||
* Obtain a PAYTO url from @a cmd.
|
* Obtain a PAYTO url from @a cmd.
|
||||||
*
|
*
|
||||||
* @param cmd command to extract the url from.
|
* @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.
|
* multiple are offered.
|
||||||
* @param url[out] where to write the url.
|
* @param url[out] where to write the url.
|
||||||
* @return #GNUNET_OK on success.
|
* @return #GNUNET_OK on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_get_trait_payto (const struct TALER_TESTING_Command *cmd,
|
TALER_TESTING_get_trait_payto (const struct TALER_TESTING_Command *cmd,
|
||||||
unsigned int index,
|
enum TALER_TESTING_PaytoType pt,
|
||||||
const char **url);
|
const char **url);
|
||||||
|
|
||||||
|
|
||||||
|
@ -398,9 +398,11 @@ admin_add_incoming_traits (void *cls,
|
|||||||
{
|
{
|
||||||
struct AdminAddIncomingState *fts = cls;
|
struct AdminAddIncomingState *fts = cls;
|
||||||
struct TALER_TESTING_Trait traits[] = {
|
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_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_amount_obj (0, &fts->amount),
|
||||||
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
|
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
|
||||||
TALER_TESTING_make_trait_reserve_priv (0,
|
TALER_TESTING_make_trait_reserve_priv (0,
|
||||||
|
@ -135,17 +135,20 @@ check_bank_transfer_run (void *cls,
|
|||||||
&amount_ptr));
|
&amount_ptr));
|
||||||
amount = *amount_ptr;
|
amount = *amount_ptr;
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
|
TALER_TESTING_get_trait_payto (deposit_cmd,
|
||||||
(deposit_cmd, &debit_account));
|
TALER_TESTING_PT_DEBIT,
|
||||||
|
&debit_account));
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
|
TALER_TESTING_get_trait_payto (deposit_cmd,
|
||||||
(deposit_cmd, &credit_account));
|
TALER_TESTING_PT_CREDIT,
|
||||||
|
&credit_account));
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_get_trait_url
|
TALER_TESTING_get_trait_url (deposit_cmd,
|
||||||
(deposit_cmd, 0, &exchange_base_url)); // check 0 works!
|
0, /* TODO: check 0 works! */
|
||||||
|
&exchange_base_url));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
|
@ -311,20 +311,20 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
|
TALER_TESTING_get_trait_payto (pos,
|
||||||
(pos, &debit_account));
|
TALER_TESTING_PT_DEBIT,
|
||||||
|
&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_CREDIT,
|
||||||
|
&credit_account));
|
||||||
TALER_LOG_INFO ("Potential history element:"
|
TALER_LOG_INFO ("Potential history element:"
|
||||||
" %s->%s; my account: %s\n",
|
" %s->%s; my account: %s\n",
|
||||||
debit_account,
|
debit_account,
|
||||||
credit_account,
|
credit_account,
|
||||||
hs->account_url);
|
hs->account_url);
|
||||||
|
|
||||||
if (0 == strcasecmp (hs->account_url,
|
if (0 == strcasecmp (hs->account_url,
|
||||||
debit_account))
|
debit_account))
|
||||||
{
|
{
|
||||||
@ -398,19 +398,18 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
|
TALER_TESTING_get_trait_payto (pos,
|
||||||
(pos, &debit_account));
|
TALER_TESTING_PT_DEBIT,
|
||||||
|
&debit_account));
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
|
TALER_TESTING_get_trait_payto (pos,
|
||||||
(pos, &credit_account));
|
TALER_TESTING_PT_CREDIT,
|
||||||
|
&credit_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,
|
debit_account,
|
||||||
credit_account,
|
credit_account,
|
||||||
hs->account_url);
|
hs->account_url);
|
||||||
|
|
||||||
/* Discard transactions where the audited account played _both_ the debit
|
/* Discard transactions where the audited account played _both_ the debit
|
||||||
* and the debit roles, but _only if_ the audit goes on both directions..
|
* and the debit roles, but _only if_ the audit goes on both directions..
|
||||||
* This needs more explaination!
|
* This needs more explaination!
|
||||||
|
@ -299,8 +299,10 @@ transfer_traits (void *cls,
|
|||||||
struct TALER_TESTING_Trait traits[] = {
|
struct TALER_TESTING_Trait traits[] = {
|
||||||
TALER_TESTING_make_trait_url (1, fts->account_debit_url),
|
TALER_TESTING_make_trait_url (1, fts->account_debit_url),
|
||||||
TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id),
|
TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id),
|
||||||
TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT (fts->payto_credit_account),
|
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
|
||||||
TALER_TESTING_MAKE_TRAIT_DEBIT_ACCOUNT (fts->account_debit_url),
|
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_amount_obj (0, &fts->amount),
|
||||||
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
|
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
|
||||||
TALER_TESTING_make_trait_wtid (0,
|
TALER_TESTING_make_trait_wtid (0,
|
||||||
|
@ -65,10 +65,9 @@
|
|||||||
* @return #GNUNET_OK on success.
|
* @return #GNUNET_OK on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_get_trait_contract_terms
|
TALER_TESTING_get_trait_contract_terms (const struct TALER_TESTING_Command *cmd,
|
||||||
(const struct TALER_TESTING_Command *cmd,
|
unsigned int index,
|
||||||
unsigned int index,
|
const json_t **contract_terms)
|
||||||
const json_t **contract_terms)
|
|
||||||
{
|
{
|
||||||
return cmd->traits (cmd->cls,
|
return cmd->traits (cmd->cls,
|
||||||
(const void **) contract_terms,
|
(const void **) contract_terms,
|
||||||
@ -85,9 +84,8 @@ TALER_TESTING_get_trait_contract_terms
|
|||||||
* @return the trait.
|
* @return the trait.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Trait
|
struct TALER_TESTING_Trait
|
||||||
TALER_TESTING_make_trait_contract_terms
|
TALER_TESTING_make_trait_contract_terms (unsigned int index,
|
||||||
(unsigned int index,
|
const json_t *contract_terms)
|
||||||
const json_t *contract_terms)
|
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Trait ret = {
|
struct TALER_TESTING_Trait ret = {
|
||||||
.index = index,
|
.index = index,
|
||||||
@ -109,10 +107,9 @@ TALER_TESTING_make_trait_contract_terms
|
|||||||
* @return #GNUNET_OK on success.
|
* @return #GNUNET_OK on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_get_trait_string
|
TALER_TESTING_get_trait_string (const struct TALER_TESTING_Command *cmd,
|
||||||
(const struct TALER_TESTING_Command *cmd,
|
unsigned int index,
|
||||||
unsigned int index,
|
const char **s)
|
||||||
const char **s)
|
|
||||||
{
|
{
|
||||||
return cmd->traits (cmd->cls,
|
return cmd->traits (cmd->cls,
|
||||||
(const void **) s,
|
(const void **) s,
|
||||||
@ -130,9 +127,8 @@ TALER_TESTING_get_trait_string
|
|||||||
* @return the trait.
|
* @return the trait.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Trait
|
struct TALER_TESTING_Trait
|
||||||
TALER_TESTING_make_trait_string
|
TALER_TESTING_make_trait_string (unsigned int index,
|
||||||
(unsigned int index,
|
const char *s)
|
||||||
const char *s)
|
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Trait ret = {
|
struct TALER_TESTING_Trait ret = {
|
||||||
.index = index,
|
.index = index,
|
||||||
@ -154,10 +150,9 @@ TALER_TESTING_make_trait_string
|
|||||||
* @return #GNUNET_OK on success.
|
* @return #GNUNET_OK on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_get_trait_url
|
TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd,
|
||||||
(const struct TALER_TESTING_Command *cmd,
|
unsigned int index,
|
||||||
unsigned int index,
|
const char **url)
|
||||||
const char **url)
|
|
||||||
{
|
{
|
||||||
return cmd->traits (cmd->cls,
|
return cmd->traits (cmd->cls,
|
||||||
(const void **) url,
|
(const void **) url,
|
||||||
@ -176,9 +171,8 @@ TALER_TESTING_get_trait_url
|
|||||||
* @return the trait.
|
* @return the trait.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Trait
|
struct TALER_TESTING_Trait
|
||||||
TALER_TESTING_make_trait_url
|
TALER_TESTING_make_trait_url (unsigned int index,
|
||||||
(unsigned int index,
|
const char *url)
|
||||||
const char *url)
|
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Trait ret = {
|
struct TALER_TESTING_Trait ret = {
|
||||||
.index = index,
|
.index = index,
|
||||||
@ -205,10 +199,9 @@ TALER_TESTING_make_trait_url
|
|||||||
* @return #GNUNET_OK on success.
|
* @return #GNUNET_OK on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_get_trait_order_id
|
TALER_TESTING_get_trait_order_id (const struct TALER_TESTING_Command *cmd,
|
||||||
(const struct TALER_TESTING_Command *cmd,
|
unsigned int index,
|
||||||
unsigned int index,
|
const char **order_id)
|
||||||
const char **order_id)
|
|
||||||
{
|
{
|
||||||
return cmd->traits (cmd->cls,
|
return cmd->traits (cmd->cls,
|
||||||
(const void **) order_id,
|
(const void **) order_id,
|
||||||
@ -227,9 +220,8 @@ TALER_TESTING_get_trait_order_id
|
|||||||
* @return the trait.
|
* @return the trait.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Trait
|
struct TALER_TESTING_Trait
|
||||||
TALER_TESTING_make_trait_order_id
|
TALER_TESTING_make_trait_order_id (unsigned int index,
|
||||||
(unsigned int index,
|
const char *order_id)
|
||||||
const char *order_id)
|
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Trait ret = {
|
struct TALER_TESTING_Trait ret = {
|
||||||
.index = index,
|
.index = index,
|
||||||
@ -244,39 +236,37 @@ TALER_TESTING_make_trait_order_id
|
|||||||
* Obtain a PAYTO-url from @a cmd.
|
* Obtain a PAYTO-url from @a cmd.
|
||||||
*
|
*
|
||||||
* @param cmd command to extract the url from.
|
* @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.
|
* multiple are offered.
|
||||||
* @param url[out] where to write the url.
|
* @param url[out] where to write the url.
|
||||||
* @return #GNUNET_OK on success.
|
* @return #GNUNET_OK on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_get_trait_payto
|
TALER_TESTING_get_trait_payto (const struct TALER_TESTING_Command *cmd,
|
||||||
(const struct TALER_TESTING_Command *cmd,
|
enum TALER_TESTING_PaytoType pt,
|
||||||
unsigned int index,
|
const char **url)
|
||||||
const char **url)
|
|
||||||
{
|
{
|
||||||
return cmd->traits (cmd->cls,
|
return cmd->traits (cmd->cls,
|
||||||
(const void **) url,
|
(const void **) url,
|
||||||
TALER_TESTING_TRAIT_PAYTO,
|
TALER_TESTING_TRAIT_PAYTO,
|
||||||
index);
|
(unsigned int) pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offer a "payto" URL reference.
|
* 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.
|
* in case multiple are offered.
|
||||||
* @param payto the payto URL
|
* @param payto the payto URL
|
||||||
* @return the trait.
|
* @return the trait.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Trait
|
struct TALER_TESTING_Trait
|
||||||
TALER_TESTING_make_trait_payto
|
TALER_TESTING_make_trait_payto (enum TALER_TESTING_PaytoType pt,
|
||||||
(unsigned int index,
|
const char *payto)
|
||||||
const char *payto)
|
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Trait ret = {
|
struct TALER_TESTING_Trait ret = {
|
||||||
.index = index,
|
.index = (unsigned int) pt,
|
||||||
.trait_name = TALER_TESTING_TRAIT_PAYTO,
|
.trait_name = TALER_TESTING_TRAIT_PAYTO,
|
||||||
.ptr = (const void *) payto
|
.ptr = (const void *) payto
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user