aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-05-17 15:50:50 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-05-17 15:50:50 +0200
commit381ac75ae0a29edb6585cc68fbd2b81b1aeaff85 (patch)
tree83c31b8d6099395924bdcf902a020f46545932d3 /src
parent5e1178a74b9d581910bb1067a195e59f3c6ddcd2 (diff)
Trigger conflicting refunds
Diffstat (limited to 'src')
-rw-r--r--src/exchange-lib/exchange_api_refund.c4
-rw-r--r--src/exchange-lib/test_exchange_api_new.c5
-rw-r--r--src/exchange-lib/testing_api_cmd_refund.c39
-rw-r--r--src/include/taler_testing_lib.h20
4 files changed, 68 insertions, 0 deletions
diff --git a/src/exchange-lib/exchange_api_refund.c b/src/exchange-lib/exchange_api_refund.c
index 1ddf642d6..c91952f13 100644
--- a/src/exchange-lib/exchange_api_refund.c
+++ b/src/exchange-lib/exchange_api_refund.c
@@ -184,6 +184,10 @@ handle_refund_finished (void *cls,
/* Client request was inconsistent; might be a currency missmatch
problem. */
break;
+ case MHD_HTTP_CONFLICT:
+ /* Two refund requests were made about the same deposit, but
+ carrying different refund transaction ids. */
+ break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
diff --git a/src/exchange-lib/test_exchange_api_new.c b/src/exchange-lib/test_exchange_api_new.c
index eeead787d..c5e62a0e5 100644
--- a/src/exchange-lib/test_exchange_api_new.c
+++ b/src/exchange-lib/test_exchange_api_new.c
@@ -500,6 +500,11 @@ run (void *cls,
("refund-ok-double", MHD_HTTP_OK,
"EUR:5", "EUR:0.01", "deposit-refund-1"),
+ /* Previous /refund(s) had id == 0. */
+ TALER_TESTING_cmd_refund_with_id
+ ("refund-conflicting", MHD_HTTP_CONFLICT,
+ "EUR:5", "EUR:0.01", "deposit-refund-1", 1),
+
/**
* Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone
* due to refund) (merchant would receive EUR:4.98 due to
diff --git a/src/exchange-lib/testing_api_cmd_refund.c b/src/exchange-lib/testing_api_cmd_refund.c
index d0f48bb22..ed3bd7c07 100644
--- a/src/exchange-lib/testing_api_cmd_refund.c
+++ b/src/exchange-lib/testing_api_cmd_refund.c
@@ -298,3 +298,42 @@ TALER_TESTING_cmd_refund (const char *label,
return cmd;
}
+
+/**
+ * Create a /refund test command, allows to specify refund
+ * transaction id. Mainly used to create conflicting requests.
+ *
+ * @param label command label
+ * @param expected_response_code expected HTTP status code
+ * @param refund_amount the amount to ask a refund for
+ * @param refund_fee expected refund fee
+ * @param coin_reference reference to a command that can
+ * provide a coin to be refunded.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_refund_with_id
+ (const char *label,
+ unsigned int expected_response_code,
+ const char *refund_amount,
+ const char *refund_fee,
+ const char *coin_reference,
+ uint64_t refund_transaction_id)
+{
+ struct RefundState *rs;
+ struct TALER_TESTING_Command cmd;
+
+ rs = GNUNET_new (struct RefundState);
+
+ rs->expected_response_code = expected_response_code;
+ rs->refund_amount = refund_amount;
+ rs->refund_fee = refund_fee;
+ rs->coin_reference = coin_reference;
+ rs->refund_transaction_id = refund_transaction_id;
+
+ cmd.cls = rs;
+ cmd.label = label;
+ cmd.run = &refund_run;
+ cmd.cleanup = &refund_cleanup;
+
+ return cmd;
+}
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 910495e4b..f7d3cca76 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -829,6 +829,26 @@ struct TALER_TESTING_Command
TALER_TESTING_cmd_check_bank_empty (const char *label);
/**
+ * Create a /refund test command, allows to specify refund
+ * transaction id.
+ *
+ * @param label command label
+ * @param expected_response_code expected HTTP status code
+ * @param refund_amount the amount to ask a refund for
+ * @param refund_fee expected refund fee
+ * @param coin_reference reference to a command that can
+ * provide a coin to be refunded.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_refund_with_id
+ (const char *label,
+ unsigned int expected_response_code,
+ const char *refund_amount,
+ const char *refund_fee,
+ const char *deposit_reference,
+ uint64_t refund_transaction_id);
+
+/**
* Create a /refund test command.
*
* @param label command label