sort out URL types more nicely
This commit is contained in:
parent
fad5a22680
commit
90c411bc19
@ -2351,6 +2351,29 @@ TALER_TESTING_make_trait_wtid (unsigned int index,
|
||||
TALER_WireTransferIdentifierRawP *wtid);
|
||||
|
||||
|
||||
/**
|
||||
* Different types of URLs that appear in traits.
|
||||
*/
|
||||
enum TALER_TESTING_URL_Type
|
||||
{
|
||||
/**
|
||||
* Category of last resort. Should not be used.
|
||||
*/
|
||||
TALER_TESTING_UT_UNDEFINED = 0,
|
||||
|
||||
/**
|
||||
* HTTP base URL of an exchange (API), as for example
|
||||
* given in wire transfers subjects made by the aggregator.
|
||||
*/
|
||||
TALER_TESTING_UT_EXCHANGE_BASE_URL = 1,
|
||||
|
||||
/**
|
||||
* HTTP URL of the exchange's bank account at the bank.
|
||||
*/
|
||||
TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL = 2
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Offer HTTP url in a trait.
|
||||
*
|
||||
@ -2360,7 +2383,7 @@ TALER_TESTING_make_trait_wtid (unsigned int index,
|
||||
* @return the trait.
|
||||
*/
|
||||
struct TALER_TESTING_Trait
|
||||
TALER_TESTING_make_trait_url (unsigned int index,
|
||||
TALER_TESTING_make_trait_url (enum TALER_TESTING_URL_Type index,
|
||||
const char *url);
|
||||
|
||||
|
||||
@ -2375,7 +2398,7 @@ TALER_TESTING_make_trait_url (unsigned int index,
|
||||
*/
|
||||
int
|
||||
TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd,
|
||||
unsigned int index,
|
||||
enum TALER_TESTING_URL_Type index,
|
||||
const char **url);
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ TALER_EXCHANGE_verify_coin_history (const struct
|
||||
&dr.deposit_fee);
|
||||
if ( (GNUNET_YES !=
|
||||
TALER_amount_cmp_currency (&fee,
|
||||
&dki->fee_deposit)) ||
|
||||
&dk->fee_deposit)) ||
|
||||
(0 !=
|
||||
TALER_amount_cmp (&fee,
|
||||
&dk->fee_deposit)) )
|
||||
@ -193,7 +193,7 @@ TALER_EXCHANGE_verify_coin_history (const struct
|
||||
&rm.melt_fee);
|
||||
if ( (GNUNET_YES !=
|
||||
TALER_amount_cmp_currency (&fee,
|
||||
&dki->fee_refresh)) ||
|
||||
&dk->fee_refresh)) ||
|
||||
(0 !=
|
||||
TALER_amount_cmp (&fee,
|
||||
&dk->fee_refresh)) )
|
||||
@ -257,7 +257,7 @@ TALER_EXCHANGE_verify_coin_history (const struct
|
||||
&rr.refund_fee);
|
||||
if ( (GNUNET_YES !=
|
||||
TALER_amount_cmp_currency (&fee,
|
||||
&dki->fee_refund)) ||
|
||||
&dk->fee_refund)) ||
|
||||
(0 !=
|
||||
TALER_amount_cmp (&fee,
|
||||
&dk->fee_refund)) )
|
||||
|
@ -409,7 +409,8 @@ admin_add_incoming_traits (void *cls,
|
||||
fts->payto_debit_account),
|
||||
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
|
||||
fts->payto_credit_account),
|
||||
TALER_TESTING_make_trait_url (0, fts->exchange_credit_url),
|
||||
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL,
|
||||
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,
|
||||
|
@ -124,29 +124,29 @@ check_bank_transfer_run (void *cls,
|
||||
(is),
|
||||
bcs->deposit_reference,
|
||||
bcs->deposit_reference);
|
||||
deposit_cmd = TALER_TESTING_interpreter_lookup_command
|
||||
(is, bcs->deposit_reference);
|
||||
|
||||
deposit_cmd
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
bcs->deposit_reference);
|
||||
if (NULL == deposit_cmd)
|
||||
TALER_TESTING_FAIL (is);
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_amount_obj (deposit_cmd,
|
||||
0,
|
||||
&amount_ptr));
|
||||
if ( (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_amount_obj (deposit_cmd,
|
||||
0,
|
||||
&amount_ptr)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_payto (deposit_cmd,
|
||||
TALER_TESTING_PT_DEBIT,
|
||||
&debit_payto)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_payto (deposit_cmd,
|
||||
TALER_TESTING_PT_CREDIT,
|
||||
&credit_payto)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_url (deposit_cmd,
|
||||
TALER_TESTING_UT_EXCHANGE_BASE_URL,
|
||||
&exchange_base_url)) )
|
||||
TALER_TESTING_FAIL (is);
|
||||
amount = *amount_ptr;
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_payto (deposit_cmd,
|
||||
TALER_TESTING_PT_DEBIT,
|
||||
&debit_payto));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_payto (deposit_cmd,
|
||||
TALER_TESTING_PT_CREDIT,
|
||||
&credit_payto));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_url (deposit_cmd,
|
||||
0, /* TODO: check 0 works! */
|
||||
&exchange_base_url));
|
||||
}
|
||||
|
||||
|
||||
@ -218,8 +218,10 @@ check_bank_transfer_traits (void *cls,
|
||||
struct BankCheckState *bcs = cls;
|
||||
struct TALER_WireTransferIdentifierRawP *wtid_ptr = &bcs->wtid;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_wtid (0, wtid_ptr),
|
||||
TALER_TESTING_make_trait_url (0, bcs->exchange_base_url),
|
||||
TALER_TESTING_make_trait_wtid (0,
|
||||
wtid_ptr),
|
||||
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL,
|
||||
bcs->exchange_base_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
|
@ -279,7 +279,7 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
&reserve_pub)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_url (cmd,
|
||||
0,
|
||||
TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL,
|
||||
&exchange_credit_url)) )
|
||||
continue; /* not an interesting event */
|
||||
/* Seek "/history" starting row. */
|
||||
|
@ -285,7 +285,7 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
&wtid)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_url (cmd,
|
||||
0,
|
||||
TALER_TESTING_UT_EXCHANGE_BASE_URL,
|
||||
&exchange_base_url)) )
|
||||
continue; /* not an event we care about */
|
||||
/* Seek "/history" starting row. */
|
||||
|
@ -308,7 +308,7 @@ transfer_traits (void *cls,
|
||||
{
|
||||
struct TransferState *fts = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_url (0,
|
||||
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL,
|
||||
fts->exchange_base_url),
|
||||
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
|
||||
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
|
||||
|
@ -144,7 +144,8 @@ serialize_keys_traits (void *cls,
|
||||
struct SerializeKeysState *sks = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_exchange_keys (0, sks->keys),
|
||||
TALER_TESTING_make_trait_url (0, sks->exchange_url),
|
||||
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL,
|
||||
sks->exchange_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
@ -192,12 +193,10 @@ connect_with_state_run (void *cls,
|
||||
return;
|
||||
}
|
||||
|
||||
GNUNET_assert
|
||||
(GNUNET_OK == TALER_TESTING_get_trait_exchange_keys
|
||||
(state_cmd,
|
||||
0,
|
||||
&serialized_keys));
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_keys (state_cmd,
|
||||
0,
|
||||
&serialized_keys));
|
||||
{
|
||||
char *dump;
|
||||
|
||||
@ -208,21 +207,17 @@ connect_with_state_run (void *cls,
|
||||
free (dump);
|
||||
}
|
||||
|
||||
GNUNET_assert
|
||||
(GNUNET_OK == TALER_TESTING_get_trait_url
|
||||
(state_cmd,
|
||||
0,
|
||||
&exchange_url));
|
||||
|
||||
is->exchange = TALER_EXCHANGE_connect
|
||||
(is->ctx,
|
||||
exchange_url,
|
||||
TALER_TESTING_cert_cb,
|
||||
cwss,
|
||||
TALER_EXCHANGE_OPTION_DATA,
|
||||
serialized_keys,
|
||||
TALER_EXCHANGE_OPTION_END);
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_url (state_cmd,
|
||||
TALER_TESTING_UT_EXCHANGE_BASE_URL,
|
||||
&exchange_url));
|
||||
is->exchange = TALER_EXCHANGE_connect (is->ctx,
|
||||
exchange_url,
|
||||
TALER_TESTING_cert_cb,
|
||||
cwss,
|
||||
TALER_EXCHANGE_OPTION_DATA,
|
||||
serialized_keys,
|
||||
TALER_EXCHANGE_OPTION_END);
|
||||
cwss->consumed = GNUNET_YES;
|
||||
}
|
||||
|
||||
@ -235,9 +230,8 @@ connect_with_state_run (void *cls,
|
||||
* @param cmd the command which is being cleaned up.
|
||||
*/
|
||||
static void
|
||||
connect_with_state_cleanup
|
||||
(void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
connect_with_state_cleanup (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct ConnectWithStateState *cwss = cls;
|
||||
|
||||
|
@ -385,30 +385,32 @@ withdraw_traits (void *cls,
|
||||
if (NULL == ws->exchange_url)
|
||||
ws->exchange_url
|
||||
= GNUNET_strdup (TALER_EXCHANGE_get_base_url (ws->is->exchange));
|
||||
{
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_coin_priv (0 /* only one coin */,
|
||||
&ws->ps.coin_priv),
|
||||
TALER_TESTING_make_trait_blinding_key (0 /* only one coin */,
|
||||
&ws->ps.blinding_key),
|
||||
TALER_TESTING_make_trait_denom_pub (0 /* only one coin */,
|
||||
ws->pk),
|
||||
TALER_TESTING_make_trait_denom_sig (0 /* only one coin */,
|
||||
&ws->sig),
|
||||
TALER_TESTING_make_trait_reserve_priv (0,
|
||||
reserve_priv),
|
||||
TALER_TESTING_make_trait_reserve_pub (0,
|
||||
reserve_pub),
|
||||
TALER_TESTING_make_trait_amount_obj (0,
|
||||
&ws->amount),
|
||||
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL,
|
||||
ws->exchange_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_coin_priv (0 /* only one coin */,
|
||||
&ws->ps.coin_priv),
|
||||
TALER_TESTING_make_trait_blinding_key (0 /* only one coin */,
|
||||
&ws->ps.blinding_key),
|
||||
TALER_TESTING_make_trait_denom_pub (0 /* only one coin */,
|
||||
ws->pk),
|
||||
TALER_TESTING_make_trait_denom_sig (0 /* only one coin */,
|
||||
&ws->sig),
|
||||
TALER_TESTING_make_trait_reserve_priv (0,
|
||||
reserve_priv),
|
||||
TALER_TESTING_make_trait_reserve_pub (0,
|
||||
reserve_pub),
|
||||
TALER_TESTING_make_trait_amount_obj (0,
|
||||
&ws->amount),
|
||||
TALER_TESTING_make_trait_url (0, ws->exchange_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
return TALER_TESTING_get_trait (traits,
|
||||
ret,
|
||||
trait,
|
||||
index);
|
||||
return TALER_TESTING_get_trait (traits,
|
||||
ret,
|
||||
trait,
|
||||
index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user