/withdraw: #5284.
This commit is contained in:
parent
e634c877e3
commit
93ff2d93cc
@ -422,7 +422,6 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_withdraw_with_retry
|
TALER_TESTING_cmd_withdraw_with_retry
|
||||||
(TALER_TESTING_cmd_withdraw_amount
|
(TALER_TESTING_cmd_withdraw_amount
|
||||||
(withdraw_label,
|
(withdraw_label,
|
||||||
is->exchange,
|
|
||||||
create_reserve_label,
|
create_reserve_label,
|
||||||
AMOUNT_5,
|
AMOUNT_5,
|
||||||
MHD_HTTP_OK));
|
MHD_HTTP_OK));
|
||||||
|
@ -193,7 +193,6 @@ run (void *cls,
|
|||||||
* Withdraw EUR:5.
|
* Withdraw EUR:5.
|
||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
|
||||||
is->exchange,
|
|
||||||
"create-reserve-1",
|
"create-reserve-1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -224,7 +223,6 @@ run (void *cls,
|
|||||||
* Try to overdraw.
|
* Try to overdraw.
|
||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
|
||||||
is->exchange,
|
|
||||||
"create-reserve-1",
|
"create-reserve-1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_FORBIDDEN),
|
MHD_HTTP_FORBIDDEN),
|
||||||
@ -290,7 +288,6 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
("refresh-withdraw-coin-1",
|
("refresh-withdraw-coin-1",
|
||||||
is->exchange,
|
|
||||||
"refresh-create-reserve-1",
|
"refresh-create-reserve-1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -484,7 +481,6 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
("withdraw-coin-unaggregated",
|
("withdraw-coin-unaggregated",
|
||||||
is->exchange,
|
|
||||||
"create-reserve-unaggregated",
|
"create-reserve-unaggregated",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -529,7 +525,6 @@ run (void *cls,
|
|||||||
|
|
||||||
/* Withdraw a 5 EUR coin, at fee of 1 ct */
|
/* Withdraw a 5 EUR coin, at fee of 1 ct */
|
||||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1",
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1",
|
||||||
is->exchange,
|
|
||||||
"create-reserve-r1",
|
"create-reserve-r1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -626,7 +621,6 @@ run (void *cls,
|
|||||||
CMD_EXEC_WIREWATCH ("wirewatch-rb"),
|
CMD_EXEC_WIREWATCH ("wirewatch-rb"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb",
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb",
|
||||||
is->exchange,
|
|
||||||
"create-reserve-rb",
|
"create-reserve-rb",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -681,7 +675,6 @@ run (void *cls,
|
|||||||
|
|
||||||
/* Withdraw a 5 EUR coin, at fee of 1 ct */
|
/* Withdraw a 5 EUR coin, at fee of 1 ct */
|
||||||
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-1",
|
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-1",
|
||||||
is->exchange,
|
|
||||||
"payback-create-reserve-1",
|
"payback-create-reserve-1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -705,7 +698,6 @@ run (void *cls,
|
|||||||
|
|
||||||
/* Re-withdraw from this reserve */
|
/* Re-withdraw from this reserve */
|
||||||
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2",
|
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2",
|
||||||
is->exchange,
|
|
||||||
"payback-create-reserve-1",
|
"payback-create-reserve-1",
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -716,7 +708,6 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
("payback-withdraw-coin-2-over",
|
("payback-withdraw-coin-2-over",
|
||||||
is->exchange,
|
|
||||||
"payback-create-reserve-1",
|
"payback-create-reserve-1",
|
||||||
"EUR:10",
|
"EUR:10",
|
||||||
MHD_HTTP_FORBIDDEN),
|
MHD_HTTP_FORBIDDEN),
|
||||||
@ -750,7 +741,6 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
("expired-withdraw",
|
("expired-withdraw",
|
||||||
is->exchange,
|
|
||||||
"short-lived-reserve",
|
"short-lived-reserve",
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
MHD_HTTP_FORBIDDEN),
|
MHD_HTTP_FORBIDDEN),
|
||||||
@ -784,14 +774,12 @@ run (void *cls,
|
|||||||
|
|
||||||
/* Withdraw a 1 EUR coin, at fee of 1 ct */
|
/* Withdraw a 1 EUR coin, at fee of 1 ct */
|
||||||
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2a",
|
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2a",
|
||||||
is->exchange,
|
|
||||||
"payback-create-reserve-2",
|
"payback-create-reserve-2",
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
|
|
||||||
/* Withdraw a 1 EUR coin, at fee of 1 ct */
|
/* Withdraw a 1 EUR coin, at fee of 1 ct */
|
||||||
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2b",
|
TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2b",
|
||||||
is->exchange,
|
|
||||||
"payback-create-reserve-2",
|
"payback-create-reserve-2",
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -851,7 +839,6 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
("payback-withdraw-coin-3-revoked",
|
("payback-withdraw-coin-3-revoked",
|
||||||
is->exchange,
|
|
||||||
"payback-create-reserve-3",
|
"payback-create-reserve-3",
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
MHD_HTTP_NOT_FOUND),
|
MHD_HTTP_NOT_FOUND),
|
||||||
|
@ -167,7 +167,6 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
("refresh-withdraw-coin",
|
("refresh-withdraw-coin",
|
||||||
is->exchange,
|
|
||||||
"refresh-create-reserve",
|
"refresh-create-reserve",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
@ -226,7 +225,6 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
("withdraw-coin-r1",
|
("withdraw-coin-r1",
|
||||||
is->exchange,
|
|
||||||
"create-reserve-r1",
|
"create-reserve-r1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
|
@ -59,12 +59,7 @@ struct WithdrawState
|
|||||||
const struct TALER_EXCHANGE_DenomPublicKey *pk;
|
const struct TALER_EXCHANGE_DenomPublicKey *pk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange we should use for the withdrawal.
|
* Exchange base URL. Only used as offered trait.
|
||||||
*/
|
|
||||||
struct TALER_EXCHANGE_Handle *exchange;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exchange base URL.
|
|
||||||
*/
|
*/
|
||||||
char *exchange_url;
|
char *exchange_url;
|
||||||
|
|
||||||
@ -110,7 +105,6 @@ struct WithdrawState
|
|||||||
* enable retries?
|
* enable retries?
|
||||||
*/
|
*/
|
||||||
int do_retry;
|
int do_retry;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -268,13 +262,24 @@ withdraw_run (void *cls,
|
|||||||
}
|
}
|
||||||
TALER_planchet_setup_random (&ws->ps);
|
TALER_planchet_setup_random (&ws->ps);
|
||||||
ws->is = is;
|
ws->is = is;
|
||||||
ws->wsh
|
|
||||||
= TALER_EXCHANGE_reserve_withdraw (ws->exchange,
|
ws->pk = TALER_TESTING_find_pk
|
||||||
ws->pk,
|
(TALER_EXCHANGE_get_keys (is->exchange),
|
||||||
rp,
|
&ws->amount);
|
||||||
&ws->ps,
|
if (NULL == ws->pk)
|
||||||
&reserve_withdraw_cb,
|
{
|
||||||
ws);
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Failed to determine denomination key at %s\n",
|
||||||
|
cmd->label);
|
||||||
|
GNUNET_assert (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ws->wsh = TALER_EXCHANGE_reserve_withdraw (is->exchange,
|
||||||
|
ws->pk,
|
||||||
|
rp,
|
||||||
|
&ws->ps,
|
||||||
|
&reserve_withdraw_cb,
|
||||||
|
ws);
|
||||||
if (NULL == ws->wsh)
|
if (NULL == ws->wsh)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -361,6 +366,9 @@ withdraw_traits (void *cls,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ws->exchange_url = GNUNET_strdup
|
||||||
|
(TALER_EXCHANGE_get_base_url (ws->is->exchange));
|
||||||
|
|
||||||
struct TALER_TESTING_Trait traits[] = {
|
struct TALER_TESTING_Trait traits[] = {
|
||||||
TALER_TESTING_make_trait_coin_priv (0 /* only one coin */,
|
TALER_TESTING_make_trait_coin_priv (0 /* only one coin */,
|
||||||
&ws->ps.coin_priv),
|
&ws->ps.coin_priv),
|
||||||
@ -391,7 +399,6 @@ withdraw_traits (void *cls,
|
|||||||
* the desired amount as string.
|
* the desired amount as string.
|
||||||
*
|
*
|
||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param exchange handle to the exchange.
|
|
||||||
* @param amount how much we withdraw.
|
* @param amount how much we withdraw.
|
||||||
* @param expected_response_code which HTTP response code
|
* @param expected_response_code which HTTP response code
|
||||||
* we expect from the exchange.
|
* we expect from the exchange.
|
||||||
@ -401,7 +408,6 @@ withdraw_traits (void *cls,
|
|||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
(const char *label,
|
(const char *label,
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
|
||||||
const char *reserve_reference,
|
const char *reserve_reference,
|
||||||
const char *amount,
|
const char *amount,
|
||||||
unsigned int expected_response_code)
|
unsigned int expected_response_code)
|
||||||
@ -422,19 +428,8 @@ TALER_TESTING_cmd_withdraw_amount
|
|||||||
label);
|
label);
|
||||||
GNUNET_assert (0);
|
GNUNET_assert (0);
|
||||||
}
|
}
|
||||||
ws->pk = TALER_TESTING_find_pk
|
|
||||||
(TALER_EXCHANGE_get_keys (exchange),
|
|
||||||
&ws->amount);
|
|
||||||
if (NULL == ws->pk)
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Failed to determine denomination key at %s\n",
|
|
||||||
label);
|
|
||||||
GNUNET_assert (0);
|
|
||||||
}
|
|
||||||
ws->expected_response_code = expected_response_code;
|
ws->expected_response_code = expected_response_code;
|
||||||
ws->exchange = exchange;
|
|
||||||
ws->exchange_url = TEAH_path_to_url (exchange, "/");
|
|
||||||
|
|
||||||
cmd.cls = ws;
|
cmd.cls = ws;
|
||||||
cmd.label = label;
|
cmd.label = label;
|
||||||
@ -461,7 +456,6 @@ TALER_TESTING_cmd_withdraw_amount
|
|||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_withdraw_denomination
|
TALER_TESTING_cmd_withdraw_denomination
|
||||||
(const char *label,
|
(const char *label,
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
|
||||||
const char *reserve_reference,
|
const char *reserve_reference,
|
||||||
const struct TALER_EXCHANGE_DenomPublicKey *dk,
|
const struct TALER_EXCHANGE_DenomPublicKey *dk,
|
||||||
unsigned int expected_response_code)
|
unsigned int expected_response_code)
|
||||||
@ -480,8 +474,6 @@ TALER_TESTING_cmd_withdraw_denomination
|
|||||||
ws->reserve_reference = reserve_reference;
|
ws->reserve_reference = reserve_reference;
|
||||||
ws->pk = dk;
|
ws->pk = dk;
|
||||||
ws->expected_response_code = expected_response_code;
|
ws->expected_response_code = expected_response_code;
|
||||||
ws->exchange = exchange;
|
|
||||||
ws->exchange_url = TEAH_path_to_url (exchange, "/");
|
|
||||||
|
|
||||||
cmd.cls = ws;
|
cmd.cls = ws;
|
||||||
cmd.label = label;
|
cmd.label = label;
|
||||||
|
@ -923,7 +923,6 @@ TALER_TESTING_cmd_exec_auditor_sign (const char *label,
|
|||||||
* the desired amount as string.
|
* the desired amount as string.
|
||||||
*
|
*
|
||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param exchange handle to the exchange.
|
|
||||||
* @param amount how much we withdraw.
|
* @param amount how much we withdraw.
|
||||||
* @param expected_response_code which HTTP response code
|
* @param expected_response_code which HTTP response code
|
||||||
* we expect from the exchange.
|
* we expect from the exchange.
|
||||||
@ -933,7 +932,6 @@ TALER_TESTING_cmd_exec_auditor_sign (const char *label,
|
|||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
(const char *label,
|
(const char *label,
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
|
||||||
const char *reserve_reference,
|
const char *reserve_reference,
|
||||||
const char *amount,
|
const char *amount,
|
||||||
unsigned int expected_response_code);
|
unsigned int expected_response_code);
|
||||||
@ -944,7 +942,6 @@ TALER_TESTING_cmd_withdraw_amount
|
|||||||
* amount by a denomination key.
|
* amount by a denomination key.
|
||||||
*
|
*
|
||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param exchange connection handle to the exchange.
|
|
||||||
* @param reserve_reference reference to the reserve to withdraw
|
* @param reserve_reference reference to the reserve to withdraw
|
||||||
* from; will provide reserve priv to sign the request.
|
* from; will provide reserve priv to sign the request.
|
||||||
* @param dk denomination public key.
|
* @param dk denomination public key.
|
||||||
@ -955,7 +952,6 @@ TALER_TESTING_cmd_withdraw_amount
|
|||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_withdraw_denomination
|
TALER_TESTING_cmd_withdraw_denomination
|
||||||
(const char *label,
|
(const char *label,
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
|
||||||
const char *reserve_reference,
|
const char *reserve_reference,
|
||||||
const struct TALER_EXCHANGE_DenomPublicKey *dk,
|
const struct TALER_EXCHANGE_DenomPublicKey *dk,
|
||||||
unsigned int expected_response_code);
|
unsigned int expected_response_code);
|
||||||
|
Loading…
Reference in New Issue
Block a user