[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: add test case (currently fails)
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: add test case (currently fails) for deposit idempotency |
Date: |
Fri, 27 Mar 2020 14:45:01 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 6620a5b6 add test case (currently fails) for deposit idempotency
6620a5b6 is described below
commit 6620a5b6919856bf6b3fc1154a380c5c79be73d9
Author: Florian Dold <address@hidden>
AuthorDate: Fri Mar 27 19:14:55 2020 +0530
add test case (currently fails) for deposit idempotency
---
src/include/taler_testing_lib.h | 14 ++++++++
src/testing/test_exchange_api.c | 5 ++-
src/testing/testing_api_cmd_deposit.c | 61 +++++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 6f422969..c3a3cea1 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 941873e9..5162e1dd 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 8e6e34a5..ead99949 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,
@@ -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
* errors from the exchange.
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: add test case (currently fails) for deposit idempotency,
gnunet <=