add test case (currently fails) for deposit idempotency
This commit is contained in:
parent
d923f29144
commit
6620a5b691
@ -1330,6 +1330,20 @@ TALER_TESTING_cmd_deposit (const char *label,
|
|||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_deposit_with_retry (struct TALER_TESTING_Command cmd);
|
TALER_TESTING_cmd_deposit_with_retry (struct TALER_TESTING_Command cmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a "deposit" command that repeats an existing
|
||||||
|
* deposit command.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param expected_response_code expected HTTP response code.
|
||||||
|
*
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_deposit_replay (const char *label,
|
||||||
|
const char *deposit_reference,
|
||||||
|
unsigned int expected_response_code);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a "refresh melt" command.
|
* Create a "refresh melt" command.
|
||||||
|
@ -176,7 +176,10 @@ run (void *cls,
|
|||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
/**
|
TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay",
|
||||||
|
"deposit-simple",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
/*
|
||||||
* Try to overdraw.
|
* Try to overdraw.
|
||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
|
||||||
|
@ -137,6 +137,12 @@ struct DepositState
|
|||||||
* deposit confirmation.
|
* deposit confirmation.
|
||||||
*/
|
*/
|
||||||
struct TALER_ExchangeSignatureP exchange_sig;
|
struct TALER_ExchangeSignatureP exchange_sig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to previous deposit operation.
|
||||||
|
* Only present if we're supposed to replay the previous deposit.
|
||||||
|
*/
|
||||||
|
const char *deposit_reference;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -269,6 +275,29 @@ deposit_run (void *cls,
|
|||||||
|
|
||||||
(void) cmd;
|
(void) cmd;
|
||||||
ds->is = is;
|
ds->is = is;
|
||||||
|
if (NULL != ds->deposit_reference)
|
||||||
|
{
|
||||||
|
// We're copying another deposit operation, initialize here.
|
||||||
|
const struct TALER_TESTING_Command *cmd;
|
||||||
|
struct DepositState *ods;
|
||||||
|
cmd = TALER_TESTING_interpreter_lookup_command
|
||||||
|
(is,
|
||||||
|
ds->deposit_reference);
|
||||||
|
if (NULL == cmd)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
TALER_TESTING_interpreter_fail (is);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ods = cmd->cls;
|
||||||
|
ds->coin_reference = ods->coin_reference;
|
||||||
|
ds->coin_index = ods->coin_index;
|
||||||
|
ds->wire_details = ods->wire_details;
|
||||||
|
ds->contract_terms = ods->contract_terms;
|
||||||
|
ds->timestamp = ods->timestamp;
|
||||||
|
ds->refund_deadline = ods->refund_deadline;
|
||||||
|
ds->amount = ods->amount;
|
||||||
|
}
|
||||||
GNUNET_assert (ds->coin_reference);
|
GNUNET_assert (ds->coin_reference);
|
||||||
coin_cmd = TALER_TESTING_interpreter_lookup_command
|
coin_cmd = TALER_TESTING_interpreter_lookup_command
|
||||||
(is,
|
(is,
|
||||||
@ -562,6 +591,38 @@ TALER_TESTING_cmd_deposit (const char *label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a "deposit" command that repeats an existing
|
||||||
|
* deposit command.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param expected_response_code expected HTTP response code.
|
||||||
|
*
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_deposit_replay (const char *label,
|
||||||
|
const char *deposit_reference,
|
||||||
|
unsigned int expected_response_code)
|
||||||
|
{
|
||||||
|
struct DepositState *ds;
|
||||||
|
ds = GNUNET_new (struct DepositState);
|
||||||
|
ds->deposit_reference = deposit_reference;
|
||||||
|
ds->expected_response_code = expected_response_code;
|
||||||
|
{
|
||||||
|
struct TALER_TESTING_Command cmd = {
|
||||||
|
.cls = ds,
|
||||||
|
.label = label,
|
||||||
|
.run = &deposit_run,
|
||||||
|
.cleanup = &deposit_cleanup,
|
||||||
|
.traits = &deposit_traits
|
||||||
|
};
|
||||||
|
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify a deposit command to enable retries when we get transient
|
* Modify a deposit command to enable retries when we get transient
|
||||||
* errors from the exchange.
|
* errors from the exchange.
|
||||||
|
Loading…
Reference in New Issue
Block a user