add test for reserve GET long polling
This commit is contained in:
parent
532fabf20a
commit
65808106c7
@ -1406,11 +1406,13 @@ TALER_TESTING_cmd_reserve_poll (const char *label,
|
|||||||
* Fail if it did not conclude by the timeout.
|
* Fail if it did not conclude by the timeout.
|
||||||
*
|
*
|
||||||
* @param label our label
|
* @param label our label
|
||||||
|
* @param timeout how long to give the long poll to finish
|
||||||
* @param poll_reference reference to a #TALER_TESTING_cmd_reserve_poll() command
|
* @param poll_reference reference to a #TALER_TESTING_cmd_reserve_poll() command
|
||||||
* @return the command.
|
* @return the command.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_reserve_poll_finish (const char *label,
|
TALER_TESTING_cmd_reserve_poll_finish (const char *label,
|
||||||
|
struct GNUNET_TIME_Relative timeout,
|
||||||
const char *poll_reference);
|
const char *poll_reference);
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,6 +134,11 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
|
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
|
||||||
"EUR:6.02"),
|
"EUR:6.02"),
|
||||||
|
TALER_TESTING_cmd_reserve_poll ("poll-reserve-1",
|
||||||
|
"create-reserve-1",
|
||||||
|
"EUR:6.02",
|
||||||
|
GNUNET_TIME_UNIT_MINUTES,
|
||||||
|
MHD_HTTP_OK),
|
||||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
|
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
|
||||||
"EUR:6.02",
|
"EUR:6.02",
|
||||||
bc.user42_payto,
|
bc.user42_payto,
|
||||||
@ -144,6 +149,9 @@ run (void *cls,
|
|||||||
* transfer.
|
* transfer.
|
||||||
*/
|
*/
|
||||||
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
||||||
|
TALER_TESTING_cmd_reserve_poll_finish ("finish-poll-reserve-1",
|
||||||
|
GNUNET_TIME_UNIT_SECONDS,
|
||||||
|
"poll-reserve-1"),
|
||||||
/**
|
/**
|
||||||
* Withdraw EUR:5.
|
* Withdraw EUR:5.
|
||||||
*/
|
*/
|
||||||
@ -290,7 +298,8 @@ run (void *cls,
|
|||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
/* Try to partially spend (deposit) 1 EUR of the 5 EUR coin
|
/* Try to partially spend (deposit) 1 EUR of the 5 EUR coin
|
||||||
* (in full) (merchant would receive EUR:0.99 due to 1 ct
|
* (in full) (merchant would receive EUR:0.99 due to 1 ct
|
||||||
* deposit fee) *///
|
* deposit fee)
|
||||||
|
*/
|
||||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
|
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
|
||||||
"refresh-withdraw-coin-1",
|
"refresh-withdraw-coin-1",
|
||||||
0,
|
0,
|
||||||
@ -587,7 +596,8 @@ run (void *cls,
|
|||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
/* Try to partially spend (deposit) 1 EUR of the 5 EUR coin
|
/* Try to partially spend (deposit) 1 EUR of the 5 EUR coin
|
||||||
* (in full) (merchant would receive EUR:0.99 due to 1 ct
|
* (in full) (merchant would receive EUR:0.99 due to 1 ct
|
||||||
* deposit fee) *///
|
* deposit fee)
|
||||||
|
*/
|
||||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age",
|
TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age",
|
||||||
"refresh-withdraw-coin-age-1",
|
"refresh-withdraw-coin-age-1",
|
||||||
0,
|
0,
|
||||||
|
@ -33,6 +33,11 @@
|
|||||||
struct PollState
|
struct PollState
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How long do we give the exchange to respond?
|
||||||
|
*/
|
||||||
|
struct GNUNET_TIME_Relative timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label to the command which created the reserve to check,
|
* Label to the command which created the reserve to check,
|
||||||
* needed to resort the reserve key.
|
* needed to resort the reserve key.
|
||||||
@ -331,7 +336,7 @@ finish_run (void *cls,
|
|||||||
}
|
}
|
||||||
GNUNET_assert (NULL == ss->ps);
|
GNUNET_assert (NULL == ss->ps);
|
||||||
ss->ps = ps;
|
ss->ps = ps;
|
||||||
ps->tt = GNUNET_SCHEDULER_add_delayed (ss->timeout,
|
ps->tt = GNUNET_SCHEDULER_add_delayed (ps->timeout,
|
||||||
&finish_timeout,
|
&finish_timeout,
|
||||||
ps);
|
ps);
|
||||||
}
|
}
|
||||||
@ -347,29 +352,31 @@ static void
|
|||||||
finish_cleanup (void *cls,
|
finish_cleanup (void *cls,
|
||||||
const struct TALER_TESTING_Command *cmd)
|
const struct TALER_TESTING_Command *cmd)
|
||||||
{
|
{
|
||||||
struct PollState *ss = cls;
|
struct PollState *ps = cls;
|
||||||
|
|
||||||
if (NULL != ss->tt)
|
if (NULL != ps->tt)
|
||||||
{
|
{
|
||||||
GNUNET_SCHEDULER_cancel (ss->tt);
|
GNUNET_SCHEDULER_cancel (ps->tt);
|
||||||
ss->tt = NULL;
|
ps->tt = NULL;
|
||||||
}
|
}
|
||||||
GNUNET_free (ss);
|
GNUNET_free (ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_reserve_poll_finish (const char *label,
|
TALER_TESTING_cmd_reserve_poll_finish (const char *label,
|
||||||
|
struct GNUNET_TIME_Relative timeout,
|
||||||
const char *poll_reference)
|
const char *poll_reference)
|
||||||
{
|
{
|
||||||
struct PollState *ss;
|
struct PollState *ps;
|
||||||
|
|
||||||
GNUNET_assert (NULL != poll_reference);
|
GNUNET_assert (NULL != poll_reference);
|
||||||
ss = GNUNET_new (struct PollState);
|
ps = GNUNET_new (struct PollState);
|
||||||
ss->poll_reference = poll_reference;
|
ps->timeout = timeout;
|
||||||
|
ps->poll_reference = poll_reference;
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Command cmd = {
|
struct TALER_TESTING_Command cmd = {
|
||||||
.cls = ss,
|
.cls = ps,
|
||||||
.label = label,
|
.label = label,
|
||||||
.run = &finish_run,
|
.run = &finish_run,
|
||||||
.cleanup = &finish_cleanup
|
.cleanup = &finish_cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user