aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/taler_testing_lib.h14
-rw-r--r--src/testing/test_exchange_api.c5
-rw-r--r--src/testing/testing_api_cmd_deposit.c61
3 files changed, 79 insertions, 1 deletions
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 6f422969a..c3a3cea11 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -1330,6 +1330,20 @@ TALER_TESTING_cmd_deposit (const char *label,
struct TALER_TESTING_Command
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.
diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c
index 941873e92..5162e1ddb 100644
--- a/src/testing/test_exchange_api.c
+++ b/src/testing/test_exchange_api.c
@@ -176,7 +176,10 @@ run (void *cls,
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
MHD_HTTP_OK),
- /**
+ TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay",
+ "deposit-simple",
+ MHD_HTTP_OK),
+ /*
* Try to overdraw.
*/
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c
index 8e6e34a57..ead99949b 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -137,6 +137,12 @@ struct DepositState
* deposit confirmation.
*/
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;
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);
coin_cmd = TALER_TESTING_interpreter_lookup_command
(is,
@@ -563,6 +592,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
* errors from the exchange.
*